Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / spatial-navigation / snav-multiple-select.html
blobc149038c5c594b4a07281cab21c89707fc79d90a
1 <html>
2 <!--
3 This test ensures the correctness of Spatial Navigation (SNav) algorithm over multiple select element.
5 * Pre-conditions:
6 1) DRT support for SNav enable/disable.
8 * Navigation steps:
9 1) Loads this page, focus goes to "start" automatically.
10 2) Focus moves away from select in 4 different directions to neighbor nodes and back.
11 -->
12 <head>
13 <script src="../../resources/js-test.js"></script>
14 <script src="resources/spatial-navigation-utils.js"></script>
15 <script type="application/javascript">
17 var resultMap = [
18 ["Down", "start"],
19 ["Down", "start"],
20 ["Down", "start"],
21 ["Down", "8"],
22 ["Up", "start"],
23 ["Up", "start"],
24 ["Up", "start"],
25 ["Up", "2"],
26 ["Down", "start"],
27 ["Right", "6"],
28 ["Left", "start"],
29 ["Left", "4"],
30 ["Right", "start"],
31 ["DONE", "DONE"]
34 if (window.testRunner) {
35 testRunner.dumpAsText();
36 testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1);
37 window.internals.settings.setSpatialNavigationEnabled(true);
38 testRunner.waitUntilDone();
41 function runTest()
43 // starting the test itself: get to a known place.
44 document.getElementById("start").focus();
46 initTest(resultMap, additionalTest);
49 function additionalTest()
51 document.getElementById("start").focus(); //move to 1st item
52 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
53 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "false");
54 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
55 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "false");
56 eventSender.keyDown("downArrow"); //move to 2nd item
57 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
58 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "false");
59 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
60 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "false");
61 eventSender.keyDown(" "); //select 2nd item
62 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
63 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "true");
64 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
65 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "false");
66 eventSender.keyDown("downArrow"); //move to 4th item (3rd item is disabled)
67 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
68 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "true");
69 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
70 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "false");
71 eventSender.keyDown(" "); //select 4th item
72 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
73 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "true");
74 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
75 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "true");
76 eventSender.keyDown("upArrow"); //move back to 2nd item
77 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
78 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "true");
79 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
80 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "true");
81 eventSender.keyDown(" "); //deselect 2nd item
82 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
83 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "false");
84 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
85 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "true");
86 eventSender.keyDown("upArrow"); //move back to 1st item
87 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
88 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "false");
89 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
90 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "true");
91 eventSender.keyDown("downArrow", ["shiftKey"]); //shift-down to 2nd item
92 shouldBe("gFocusedDocument.getElementById(\"start\").options[0].selected", "false");
93 shouldBe("gFocusedDocument.getElementById(\"start\").options[1].selected", "true");
94 shouldBe("gFocusedDocument.getElementById(\"start\").options[2].selected", "false");
95 shouldBe("gFocusedDocument.getElementById(\"start\").options[3].selected", "true");
97 testCompleted();
100 function testCompleted()
102 if (window.testRunner)
103 testRunner.notifyDone();
106 window.onload = runTest;
108 </script>
109 </head>
110 <body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
111 <table style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="1">
112 <tbody>
113 <tr>
114 <td style="vertical-align: top; text-align: center;"></td>
115 <td style="vertical-align: top; text-align: center;"><a id="2" href="a">2</a></td>
116 <td style="vertical-align: top; text-align: center;"></td>
117 </tr>
118 <tr>
119 <td style="vertical-align: top; text-align: center;"><a id="4" href="a">4</a></td>
120 <td style="vertical-align: top; text-align: center;"><select id="start" multiple><option>1</option><option>2</option><option disabled>3</option><option>4</option></select></td>
121 <td style="vertical-align: top; text-align: center;"><a id="6" href="a">6</a></td>
122 </tr>
123 <tr>
124 <td style="vertical-align: top; text-align: center;"></td>
125 <td style="vertical-align: top; text-align: center;"><a id="8" href="a">8</a></td>
126 <td style="vertical-align: top; text-align: center;"></td>
127 </tr>
128 </tbody>
129 </table>
130 <div id="console"></div>
131 </body>
132 </html>