Git init
[framework/web/webkit-efl.git] / LayoutTests / fast / spatial-navigation / snav-unit-overflow-and-scroll-in-direction.html
1 <html>
2   <!--
3     This test ensures the correctness the following Spatial Navigation
4     (SNav) algorithm features.
5
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
10        Internet).
11
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.
15
16     * Pre-conditions:
17     1) DRT support for SNav enable/disable.
18
19     * Navigation steps:
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
23        a step down.
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. -->
27   <head>
28     <script src="../js/resources/js-test-pre.js"></script>
29     <script src="resources/spatial-navigation-utils.js"></script>
30     <script type="application/javascript">
31
32     var resultMap1 = [
33       ["Down", "start"],
34       ["DONE", "DONE"]
35     ];
36
37     var resultMap2 = [
38       ["Down", "end"],
39       ["DONE", "DONE"]
40     ];
41
42     if (window.layoutTestController) {
43       layoutTestController.dumpAsText();
44       layoutTestController.setSpatialNavigationEnabled(true);
45       layoutTestController.overridePreference("WebKitTabToLinksPreferenceKey", 1);
46       layoutTestController.waitUntilDone();
47     }
48
49     function runTest()
50     {
51       // starting the test itself: get to a known place.
52       document.getElementById("start").focus();
53
54       setTimeout(step1 , 0);
55     }
56
57     function step1()
58     {
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);
63     }
64
65     function step2()
66     {
67       shouldBeTrue(String(document.body.scrollTop != 0));
68
69       // Then it scrolls down to the end of the page ...
70       if (window.eventSender)
71         eventSender.keyDown("end");
72
73       // And 'resultMap2' re-tries to move focus down.
74       initTest(resultMap2, step2Completed);
75     }
76
77     function step1Completed()
78     {
79       setTimeout(step2 , 0);
80     }
81
82     function step2Completed()
83     {
84       if (window.layoutTestController)
85         layoutTestController.notifyDone();
86     }
87
88     window.onload = runTest;
89
90     </script>
91     <script src="js/resources/js-test-post.js"></script>
92   </head>
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>
97     </div>
98     <div id="console"></div>
99   </body>
100 </html>