3 This test ensures the correctness the following Spatial Navigation
4 (SNav) algorithm features.
6 1) There is no unit overflow in the Spatial Navigation algorithm while
7 calculating the best node candidate to move focus to. To test that this
8 page positions some elements 10000000 pixels far from each other (distance
9 that can considered large enough for most of the Web Pages on the
12 2) Make sure that a best focusable candidate only gets focused
13 if it is visible in the current Viewport. Scroll-in-direction
14 is performed otherwise.
17 1) DRT support for SNav enable/disable.
20 1) Loads this page, focus goes to "start" automatically.
21 2) Attempt to move focus down to "end. As it is too far and out of
22 viewport, focus change will not happen and page will be scrolled
24 3) By sending an "End" keypress, page gets scrolled down to a place
25 where the "end" node gets visible in the viewport.
26 4) Step _1_ is ran again, and "end" gets focused. -->
28 <script src=
"../../resources/js-test.js"></script>
29 <script src=
"resources/spatial-navigation-utils.js"></script>
30 <script type=
"application/javascript">
42 if (window.testRunner) {
43 testRunner.dumpAsText();
44 testRunner.overridePreference(
"WebKitTabToLinksPreferenceKey",
1);
45 window.internals.settings.setSpatialNavigationEnabled(true);
46 testRunner.waitUntilDone();
51 // starting the test itself: get to a known place.
52 document.getElementById(
"start").focus();
54 setTimeout(step1 ,
0);
59 // Actions in 'resultMap1' should keep the focus in the currently
60 // focused element ('start') once the best candidate ('end') is not
61 // visible in current viewport.
62 initTest(resultMap1, step1Completed);
67 shouldBeTrue(String(document.scrollingElement.scrollTop !=
0));
69 // Then it scrolls down to the end of the page ...
70 if (window.eventSender)
71 eventSender.keyDown(
"end");
73 // And 'resultMap2' re-tries to move focus down.
74 initTest(resultMap2, step2Completed);
77 function step1Completed()
79 setTimeout(step2 ,
0);
82 function step2Completed()
84 if (window.testRunner)
85 testRunner.notifyDone();
88 window.onload = runTest;
92 <body id=
"some-content" xmlns=
"http://www.w3.org/1999/xhtml">
93 <a id=
"start" href=
"a">Start
</a>
94 <div style='margin-top:
100000000px'
>
95 <a id=
"end" href=
"a">End
</a>
97 <div id=
"console"></div>