WebCore: Bug 37040 - AX: need to send selected children change notification when...
[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 <link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
5 <script>
6 var successfullyParsed = false;
7 </script>
8 <script src="../../../fast/js/resources/js-test-pre.js"></script>
9 </head>
10 <body id="body">
11
12 <div role="group" tabindex=0 id="listbox" role="listbox">
13 <div id="option1" role="option" aria-selected="true">Option</div>
14 <div id="option2" role="option">Option</div>
15 <div id="option3" role="option">Option</div>
16 </div>
17
18 <p id="description"></p>
19 <div id="console"></div>
20
21 <script>
22
23     description("This tests that when aria-selected is changed in a listbox, the correct notification is sent.");
24
25     var notificationCount = 0;
26     function ariaCallback(notification) {
27         if (notification == "AXSelectedChildrenChanged") {
28             notificationCount++;
29
30             // We should get a total of 4 live region changes.
31             if (notificationCount == 2) {
32                window.layoutTestController.notifyDone();
33             }
34         }
35     }
36
37     if (window.accessibilityController) {
38         window.layoutTestController.waitUntilDone();
39
40         document.getElementById("listbox").focus();
41         var listbox = window.accessibilityController.focusedElement;
42
43         var addedNotification = listbox.addNotificationListener(ariaCallback);
44         shouldBe("addedNotification", "true");
45
46         // These should each trigger a notification that the selected children changed.
47         document.getElementById("option2").setAttribute("aria-selected", "true");
48         document.getElementById("option2").setAttribute("aria-selected", "false");
49     }
50
51     successfullyParsed = true;
52 </script>
53
54 <script src="../../../fast/js/resources/js-test-post.js"></script>
55 </body>
56 </html>