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="../js/resources/js-test-pre.js"></script>
29 <script src="resources/spatial-navigation-utils.js"></script>
30 <script type="application/javascript">
42 if (window.layoutTestController) {
43 layoutTestController.dumpAsText();
44 layoutTestController.setSpatialNavigationEnabled(true);
45 layoutTestController.overridePreference("WebKitTabToLinksPreferenceKey", 1);
46 layoutTestController.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.body.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.layoutTestController)
85 layoutTestController.notifyDone();
88 window.onload = runTest;
91 <script src="js/resources/js-test-post.js"></script>
93 <body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
94 <a id="start" href="a">Start</a>
95 <div style='margin-top:100000000px'>
96 <a id="end" href="a">End</a>
98 <div id="console"></div>