Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / multiselect-list-reports-active-option.html
1 <html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 <script>
5     jsTestIsAsync = true;
6
7     function runTest() {
8         description("This tests that navigating in a multiselect list updates selection and the active selected option and sends a notification.");
9
10         if (window.accessibilityController) {
11             var menulist = document.getElementById("menulist");
12             menulist.focus();
13             window.accessibleMenulist = accessibilityController.focusedElement;
14             window.accessibleOne = accessibleMenulist.childAtIndex(0);
15             window.accessibleTwo = accessibleMenulist.childAtIndex(1);
16             window.accessibleThree = accessibleMenulist.childAtIndex(2);
17
18             function listListener(notification) {
19                 document.getElementById("console").innerText += "List notification: " + notification + "\n";
20             }
21             accessibleMenulist.addNotificationListener(listListener);
22
23             shouldBe("accessibleOne.isSelected", "true");
24             shouldBe("accessibleOne.isSelectedOptionActive", "true");
25             shouldBe("accessibleTwo.isSelected", "false");
26             shouldBe("accessibleTwo.isSelectedOptionActive", "false");
27             shouldBe("accessibleThree.isSelected", "false");
28             shouldBe("accessibleThree.isSelectedOptionActive", "false");
29
30             // Change the selected index by simulating a down arrow keydown event.
31             var event = document.createEvent('KeyboardEvents');
32             event.initKeyboardEvent('keydown', true, true, document.defaultView, 'Down', 0, false, false, false, false, false);
33             menulist.dispatchEvent(event);
34
35             shouldBe("accessibleOne.isSelected", "false");
36             shouldBe("accessibleOne.isSelectedOptionActive", "false");
37             shouldBe("accessibleTwo.isSelected", "true");
38             shouldBe("accessibleTwo.isSelectedOptionActive", "true");
39             shouldBe("accessibleThree.isSelected", "false");
40             shouldBe("accessibleThree.isSelectedOptionActive", "false");
41
42             // Extend the selection by simulating a Shift + Down Arrow keydown event.
43             var event = document.createEvent('KeyboardEvents');
44             event.initKeyboardEvent('keydown', true, true, document.defaultView, 'Down', 0, false, false, true, false, false);
45             menulist.dispatchEvent(event);
46
47             shouldBe("accessibleOne.isSelected", "false");
48             shouldBe("accessibleOne.isSelectedOptionActive", "false");
49             shouldBe("accessibleTwo.isSelected", "true");
50             shouldBe("accessibleTwo.isSelectedOptionActive", "false");
51             shouldBe("accessibleThree.isSelected", "true");
52             shouldBe("accessibleThree.isSelectedOptionActive", "true");
53         }
54
55         // Make the test finish quickly whether we get the notification or not.
56         window.setTimeout(function() {
57             if (window.accessibilityController)
58                 accessibleMenulist.removeNotificationListener();
59             finishJSTest();
60         }, 10);
61     }
62
63     window.addEventListener('load', function() {
64         setTimeout(runTest, 10);
65     }, false);
66 </script>
67 </head>
68 <body>
69
70 <select multiple id="menulist">
71   <option selected>One</option>
72   <option>Two</option>
73   <option>Three</option>
74   <option>Four</option>
75 </select>
76
77 <p id="description"></p>
78 <div id="console"></div>
79
80 </body>
81 </html>