|
| 1 | +<!doctype html> |
| 2 | +<meta charset="utf-8"> |
| 3 | +<title>Spatnav sanity check</title> |
| 4 | +<link rel="author" title="Jihye Hong" href="jh.hong@lge.com"> |
| 5 | +<meta name=flags content=""> |
| 6 | +<link rel=help href="https://wicg.github.io/spatial-navigation/#high-level-api"> |
| 7 | + |
| 8 | +<script src="../resources/testharness.js"></script> |
| 9 | +<script src="../resources/testharnessreport.js"></script> |
| 10 | + |
| 11 | +<!--load polyfill. To be removed before submitting to WPT--> |
| 12 | +<script src="../polyfill/spatnav-heuristic.js"></script> |
| 13 | + |
| 14 | +<style> |
| 15 | + :focus { |
| 16 | + outline: 4px #3582ff solid; |
| 17 | + } |
| 18 | + |
| 19 | + .container { |
| 20 | + margin: 10px; |
| 21 | + } |
| 22 | + |
| 23 | + .box { |
| 24 | + position: relative; |
| 25 | + box-sizing: border-box; |
| 26 | + width: 50px; |
| 27 | + height: 50px; |
| 28 | + border: 1px black solid; |
| 29 | + background: #6ac; |
| 30 | + } |
| 31 | + |
| 32 | + #initial_focus { |
| 33 | + background: #F08080; |
| 34 | + } |
| 35 | +</style> |
| 36 | + |
| 37 | +<div class="container"> |
| 38 | + <div tabindex="0" class="box"></div> |
| 39 | + <div tabindex="0" class="box" style="left: 50px; top: -50px;"></div> |
| 40 | + <div tabindex="0" class="box" id="up_focus" style="left: calc(50px * 2); top: calc(-50px * 2);"></div> |
| 41 | + <div tabindex="0" class="box" style="top: calc(-50px * 2);"></div> |
| 42 | + <div tabindex="0" class="box" id="left_focus" style="left: 50px; top: calc(-50px * 3);"></div> |
| 43 | + <div tabindex="0" class="box" id="initial_focus" style="left: calc(50px * 2); top: calc(-50px * 4);"></div> |
| 44 | + <div tabindex="0" class="box" style="top: calc(-50px * 4);"></div> |
| 45 | + <div tabindex="0" class="box" style="left: 50px; top: calc(-50px * 5);"></div> |
| 46 | + <div tabindex="0" class="box" id="down_focus" style="left: calc(50px * 2); top: calc(-50px * 6);"></div> |
| 47 | +</div> |
| 48 | + |
| 49 | +<script> |
| 50 | +test(function() { |
| 51 | + document.getElementById("initial_focus").focus(); |
| 52 | + window.navigate("left"); |
| 53 | + assert_equals(document.activeElement.id, "left_focus"); |
| 54 | +}, "Move focus left from the initially focused element") |
| 55 | + |
| 56 | +test(function() { |
| 57 | + document.getElementById("initial_focus").focus(); |
| 58 | + window.navigate("up"); |
| 59 | + assert_equals(document.activeElement.id, "up_focus"); |
| 60 | +}, "Move focus up from the initially focused element") |
| 61 | + |
| 62 | +test(function() { |
| 63 | + document.getElementById("initial_focus").focus(); |
| 64 | + window.navigate("down"); |
| 65 | + assert_equals(document.activeElement.id, "down_focus"); |
| 66 | +}, "Move focus down from the initially focused element") |
| 67 | + |
| 68 | +</script> |
0 commit comments