Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / LayoutTests / accessibility / deleting-iframe-destroys-axcache.html
1 <html>
2 <head>
3 <script src="../resources/js-test.js"></script>
4 <script src="../resources/accessibility-helper.js"></script>
5 <script>
6     jsTestIsAsync = true;
7
8     function runTest()
9     {
10         description("This tests that deleting an iframe doesn't cause the accessibility cache to be destroyed and recreated.");
11
12         if (window.accessibilityController) {
13             window.root = accessibilityController.rootElement;
14             window.stopElement = accessibilityController.accessibleElementById("stopElement");
15
16             window.body = root.childAtIndex(0);
17             window.before = body.childAtIndex(0);
18             window.iframe = body.childAtIndex(1).childAtIndex(0);
19             window.after = body.childAtIndex(2);
20
21             window.frameBody = window.iframe.childAtIndex(0);
22             window.frameBodyRole = window.frameBody.role;
23             window.frameGroup = window.frameBody.childAtIndex(0);
24             window.frameGroupRole = window.frameGroup.role;
25             window.frameButton = window.frameGroup.childAtIndex(0);
26             window.frameButtonRole = window.frameButton.role;
27
28             document.getElementById("tree").innerText += "\nBefore:\n";
29             dumpAccessibilityTree(root, stopElement, 0, true);
30
31             // Remove the iframe.
32             document.body.removeChild(document.getElementById("iframe"));
33
34             window.newRoot = accessibilityController.rootElement;
35             window.newBody = newRoot.childAtIndex(0);
36             window.newBefore = newBody.childAtIndex(0);
37             window.newAfter = newBody.childAtIndex(1);
38
39             document.getElementById("tree").innerText += "\nAfter:\n";
40             dumpAccessibilityTree(newRoot, stopElement, 0, true);
41             document.getElementById("tree").innerText += "\n";
42
43             // Make sure that the accessibility objects from the iframe's nodes
44             // are now invalid by checking that their role is changed - this
45             // is because they've been deleted.
46             shouldBeFalse("frameBodyRole == frameBody.role");
47             shouldBeFalse("frameGroupRole == frameGroup.role");
48             shouldBeFalse("frameButtonRole == frameButton.role");
49
50             // Make sure that the other nodes are unchanged.
51             shouldBeTrue("root.isEqual(newRoot)");
52             shouldBeTrue("body.isEqual(newBody)");
53             shouldBeTrue("before.isEqual(newBefore)");
54             shouldBeTrue("after.isEqual(newAfter)");
55         }
56
57         finishJSTest();
58     }
59     
60     window.addEventListener('load', function() {
61         setTimeout(runTest, 10);
62     }, false);
63     
64   </script>
65 </head>
66 <body>
67
68 <p>Before</p>
69
70 <iframe id="iframe" src="data:text/html,<body><button>Click me</button></body>"></iframe>
71
72 <p>After</p>
73
74 <p id="stopElement">End of test</p>
75
76 <p id="description"></p>
77 <pre id="tree"></pre>
78 <div id="console"></div>
79
80 </body>
81 </html>