bee5ea12deb75fb44dab3f48bb89f38dd4fff3ea
[WebKit-https.git] / LayoutTests / platform / mac / accessibility / aria-listbox-selectedchildren-change.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../fast/js/resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
8 <div role="group" tabindex=0 id="listbox" role="listbox">
9 <div id="option1" role="option" aria-selected="true">Option</div>
10 <div id="option2" role="option">Option</div>
11 <div id="option3" role="option">Option</div>
12 </div>
13
14 <p id="description"></p>
15 <div id="console"></div>
16
17 <script>
18
19     description("This tests that when aria-selected is changed in a listbox, the correct notification is sent.");
20
21     var listbox = 0;
22     var notificationCount = 0;
23     function ariaCallback(notification) {
24         if (notification == "AXSelectedChildrenChanged") {
25             notificationCount++;
26
27             // We should get a total of 4 live region changes.
28             if (notificationCount == 2) {
29                listbox.removeNotificationListener();
30                window.layoutTestController.notifyDone();
31             }
32         }
33     }
34
35     if (window.accessibilityController) {
36         window.layoutTestController.waitUntilDone();
37
38         document.getElementById("listbox").focus();
39         listbox = window.accessibilityController.focusedElement;
40
41         var addedNotification = listbox.addNotificationListener(ariaCallback);
42         shouldBe("addedNotification", "true");
43
44         // These should each trigger a notification that the selected children changed.
45         document.getElementById("option2").setAttribute("aria-selected", "true");
46         document.getElementById("option2").setAttribute("aria-selected", "false");
47     }
48
49 </script>
50
51 <script src="../../../fast/js/resources/js-test-post.js"></script>
52 </body>
53 </html>