accessibility/mac/aria-expanded-notifications.html is flaky
[WebKit-https.git] / LayoutTests / accessibility / mac / 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         if (notification == "AXLoadComplete" || notification == "AXLayoutComplete")
34             return;
35         notifyName = notification;
36         if (notifyCount == 0)
37             shouldBeEqualToString("notifyName", "AXRowCountChanged");
38         else if (notifyCount == 1)
39             shouldBeEqualToString("notifyName", "AXRowCollapsed");
40         else if (notifyCount == 2)
41             shouldBeEqualToString("notifyName", "AXRowCountChanged");
42         else if (notifyCount == 3) {
43             shouldBeEqualToString("notifyName", "AXRowExpanded");
44             accessibilityController.removeNotificationListener();
45             var scriptElement = document.createElement("script");
46             scriptElement.src = "../../resources/js-test-post-async.js";
47             document.body.appendChild(scriptElement);
48         }
49         notifyCount++;
50     }
51
52     if (window.accessibilityController) {
53         window.testRunner.waitUntilDone();
54
55         var domTree = document.getElementById("tree0");
56         domTree.focus();
57
58         axTree = window.accessibilityController.focusedElement;
59
60         var addedNotification = accessibilityController.addNotificationListener(notifyCallback);
61         shouldBe("addedNotification", "true");
62
63         // the first aria-expanded should generate row count, row collapsed.
64         document.getElementById("tree0_item0").setAttribute("aria-expanded", "false");
65
66         // the second aria-expanded should generate row count, row expanded.
67         document.getElementById("tree0_item0").setAttribute("aria-expanded", "true");
68     }
69
70 </script>
71
72 </body>
73 </html>