Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / children-changed-sends-notification.html
1 <html>
2 <head>
3 <script src="../resources/js-test-pre.js"></script>
4 <script src="../resources/accessibility-helper.js"></script>
5 </head>
6 <body>
7
8 <p id="description"></p>
9 <p id="paragraph">Plain text paragraph <a id="testLink" href="#">with a link at the end</a></p>
10
11 <div id="console"></div>
12
13 <script>
14 window.jsTestIsAsync = true;
15
16 description("This test ensures that a notification is being emitted when children are added or removed for an accessibility object");
17
18 function runTest() {
19     window.paragraphNotificationCount = 0;
20     window.globalNotificationCount = 0;
21
22     if (window.accessibilityController) {
23         var axWebArea = accessibilityController.rootElement.childAtIndex(0);
24
25         // Ensure the accessibility hierarchy is generated.
26         touchAccessibilityTree(axWebArea);
27
28         window.paragraph = axWebArea.childAtIndex(1);
29         paragraph.addNotificationListener(function(notification) {
30             paragraphNotificationCount++;
31             debug("PARAGRAPH notification: " + notification);
32         });
33
34         accessibilityController.addNotificationListener(function(element, notification) {
35             if (!element.isEqual(paragraph))
36                 return;
37
38             globalNotificationCount++;
39             debug("GLOBAL notification: " + notification + " on element with role " + element.role);
40         });
41     }
42
43     var par = document.getElementById('paragraph');
44     window.newChild = document.createElement('button');
45     par.appendChild(newChild);
46
47     // Ensure the new child is added.
48     touchAccessibilityTree(axWebArea);
49
50     window.setTimeout(function() {
51         var link = document.getElementById('testLink');
52         link.style.display = 'none';
53
54         // Ensure the accessibility hierarchy is regenerated.
55         touchAccessibilityTree(axWebArea);
56
57         shouldBe("paragraphNotificationCount", "globalNotificationCount");
58         shouldBe("globalNotificationCount", "2");
59
60         if (window.accessibilityController) {
61             paragraph.removeNotificationListener();
62             accessibilityController.removeNotificationListener();
63         }
64
65         finishJSTest();
66     }, 0);
67 }
68
69 runTest();
70 </script>
71
72 <script src="../resources/js-test-post.js"></script>
73 </body>
74 </html>