fec3d4ce2fd48be06e2fa878cd4c24dabcd3a521
[WebKit-https.git] / LayoutTests / platform / mac / accessibility / aria-expanded-notifications.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../../resources/js-test-pre.js"></script>
5 </head>
6 <body id="body">
7
8 <ul id="tree0" role="tree" aria-labelledby="treelabel" aria-activedescendant="tree0_item0_2_0_1" tabindex="0">
9     <li id="tree0_item0" role="treeitem" aria-level="1" aria-expanded="true">
10         <span>
11             <span class="expander"></span>
12         Animals
13         </span>
14         <ul role="group">
15              <li id="tree0_item0_0" role="treeitem" aria-level="2"><span>Birds</span></li>
16         </ul>
17      </li>
18 </ul>
19
20 <p id="description"></p>
21 <div id="console"></div>
22 <div id="notifications"></div>
23
24 <script>
25
26     description("This tests that when aria-expanded is toggled, the appropriate notifications are sent out");
27
28     var axTree = 0;
29     var notifyCount = 0;
30     var notifyName = 0;
31     // The order of notifications should be Row Count, Row Collapsed, Row Count, Row Expanded
32     function notifyCallback(element, notification) {  
33         notifyName = notification;
34         document.getElementById("notifications").innerHTML += "Notification: " + notifyName + "<br>";
35         if (notifyCount == 4) {
36             accessibilityController.removeNotificationListener();
37             window.testRunner.notifyDone();
38         }
39         notifyCount++;
40     }
41
42     if (window.accessibilityController) {
43         window.testRunner.waitUntilDone();
44
45         var domTree = document.getElementById("tree0");
46         domTree.focus();
47
48         axTree = window.accessibilityController.focusedElement;
49
50         var addedNotification = accessibilityController.addNotificationListener(notifyCallback);
51         shouldBe("addedNotification", "true");
52
53         // the first aria-expanded should generate row count, row collapsed.
54         document.getElementById("tree0_item0").setAttribute("aria-expanded", "false");
55
56         // the second aria-expanded should generate row count, row expanded.
57         document.getElementById("tree0_item0").setAttribute("aria-expanded", "true");
58     }
59
60 </script>
61
62 <script src="../../../resources/js-test-post.js"></script>
63 </body>
64 </html>