OLD | NEW |
1 <html> | 1 <html> |
2 <head> | |
3 <script src="../resources/js-test.js"></script> | 2 <script src="../resources/js-test.js"></script> |
| 3 <script src="../resources/accessibility-helper.js"></script> |
| 4 <body> |
4 | 5 |
5 <script> | 6 <p>Before</p> |
| 7 |
| 8 <iframe id="iframe" src="data:text/html,<body><button>Click me</button></body>">
</iframe> |
| 9 |
| 10 <p>After</p> |
| 11 |
| 12 <p>End of test</p> |
| 13 |
| 14 <p id="description"></p> |
| 15 <div id="console"></div> |
| 16 <script> |
6 if (window.testRunner) | 17 if (window.testRunner) |
7 testRunner.waitUntilDone(); | 18 testRunner.waitUntilDone(); |
8 | 19 |
9 function buildAccessibilityTree(accessibilityObject, indent) { | |
10 var str = ""; | |
11 for (var i = 0; i < indent; i++) | |
12 str += " "; | |
13 str += accessibilityObject.role; | |
14 str += " " + accessibilityObject.stringValue; | |
15 | |
16 if (accessibilityObject.role == '') | |
17 str += accessibilityObject.allAttributes(); | |
18 | |
19 str += "\n"; | |
20 document.getElementById("console").innerText += str; | |
21 | |
22 if (accessibilityObject.stringValue.indexOf('End of test') >= 0) | |
23 return false; | |
24 | |
25 var count = accessibilityObject.childrenCount; | |
26 for (var i = 0; i < count; ++i) { | |
27 if (!buildAccessibilityTree(accessibilityObject.childAtIndex(i), ind
ent + 1)) | |
28 return false; | |
29 } | |
30 | |
31 return true; | |
32 } | |
33 | |
34 function runTest() | 20 function runTest() |
35 { | 21 { |
36 description("This tests that deleting an iframe doesn't cause the access
ibility cache to be destroyed and recreated."); | 22 description("This tests that deleting an iframe doesn't cause the access
ibility cache to be destroyed and recreated."); |
37 | 23 |
38 if (window.accessibilityController) { | 24 if (window.accessibilityController) { |
39 window.root = accessibilityController.rootElement; | 25 window.root = accessibilityController.rootElement; |
40 window.body = root.childAtIndex(0); | 26 window.body = root.childAtIndex(0); |
41 window.before = body.childAtIndex(0).childAtIndex(0); | 27 window.before = body.childAtIndex(0).childAtIndex(0); |
42 window.iframe = body.childAtIndex(1).childAtIndex(0); | 28 window.iframe = body.childAtIndex(1).childAtIndex(0); |
43 window.after = body.childAtIndex(2).childAtIndex(0); | 29 window.after = body.childAtIndex(2).childAtIndex(0); |
44 | 30 |
45 window.frameBody = window.iframe.childAtIndex(0); | 31 window.frameBody = window.iframe.childAtIndex(0); |
46 window.frameBodyRole = window.frameBody.role; | 32 window.frameBodyRole = window.frameBody.role; |
47 window.frameGroup = window.frameBody.childAtIndex(0); | 33 window.frameGroup = window.frameBody.childAtIndex(0); |
48 window.frameGroupRole = window.frameGroup.role; | 34 window.frameGroupRole = window.frameGroup.role; |
49 window.frameButton = window.frameGroup.childAtIndex(0); | 35 window.frameButton = window.frameGroup.childAtIndex(0); |
50 window.frameButtonRole = window.frameButton.role; | 36 window.frameButtonRole = window.frameButton.role; |
51 | 37 |
52 document.getElementById("console").innerText += "\nBefore:\n"; | 38 document.getElementById("console").innerText += "\nBefore:\n"; |
53 buildAccessibilityTree(root, 0); | 39 buildAccessibilityTree(root, 0, 1); |
54 | 40 |
55 // Remove the iframe. | 41 // Remove the iframe. |
56 document.body.removeChild(document.getElementById("iframe")); | 42 document.body.removeChild(document.getElementById("iframe")); |
57 | 43 |
58 // Force layout now so that the childAtIndex calls below | 44 // Force layout now so that the childAtIndex calls below |
59 // reflect the new render tree. | 45 // reflect the new render tree. |
60 document.body.offsetTop; | 46 document.body.offsetTop; |
61 | 47 |
62 window.newRoot = accessibilityController.rootElement; | 48 window.newRoot = accessibilityController.rootElement; |
63 window.newBody = newRoot.childAtIndex(0); | 49 window.newBody = newRoot.childAtIndex(0); |
64 window.newBefore = newBody.childAtIndex(0).childAtIndex(0); | 50 window.newBefore = newBody.childAtIndex(0).childAtIndex(0); |
65 window.newAfter = newBody.childAtIndex(1).childAtIndex(0); | 51 window.newAfter = newBody.childAtIndex(1).childAtIndex(0); |
66 | 52 |
67 document.getElementById("console").innerText += "\nAfter:\n"; | 53 document.getElementById("console").innerText += "\nAfter:\n"; |
68 buildAccessibilityTree(newRoot, 0); | 54 buildAccessibilityTree(newRoot, 0, 1); |
69 document.getElementById("console").innerText += "\n"; | 55 document.getElementById("console").innerText += "\n"; |
70 | 56 |
71 // Make sure that the accessibility objects from the iframe's nodes | 57 // Make sure that the accessibility objects from the iframe's nodes |
72 // are now invalid by checking that their role is changed - this | 58 // are now invalid by checking that their role is changed - this |
73 // is because they've been deleted. | 59 // is because they've been deleted. |
74 shouldBeFalse("frameBodyRole == frameBody.role"); | 60 shouldBeFalse("frameBodyRole == frameBody.role"); |
75 shouldBeFalse("frameGroupRole == frameGroup.role"); | 61 shouldBeFalse("frameGroupRole == frameGroup.role"); |
76 shouldBeFalse("frameButtonRole == frameButton.role"); | 62 shouldBeFalse("frameButtonRole == frameButton.role"); |
77 | 63 |
78 // Make sure that the other nodes are unchanged. | 64 // Make sure that the other nodes are unchanged. |
79 shouldBeTrue("body.isEqual(newBody)"); | 65 shouldBeTrue("body.isEqual(newBody)"); |
80 shouldBeTrue("before.isEqual(newBefore)"); | 66 shouldBeTrue("before.isEqual(newBefore)"); |
81 shouldBeTrue("after.isEqual(newAfter)"); | 67 shouldBeTrue("after.isEqual(newAfter)"); |
82 } | 68 } |
83 | 69 |
84 debug('<br /><span class="pass">TEST COMPLETE</span>'); | 70 debug('<br /><span class="pass">TEST COMPLETE</span>'); |
85 if (window.testRunner) | 71 if (window.testRunner) |
86 testRunner.notifyDone(); | 72 testRunner.notifyDone(); |
87 } | 73 } |
88 | 74 |
89 window.addEventListener('load', function() { | 75 window.addEventListener('load', function() { |
90 setTimeout(runTest, 10); | 76 setTimeout(runTest, 10); |
91 }, false); | 77 }, false); |
92 | 78 </script> |
93 </script> | |
94 </head> | |
95 <body> | |
96 | |
97 <p>Before</p> | |
98 | |
99 <iframe id="iframe" src="data:text/html,<body><button>Click me</button></body>">
</iframe> | |
100 | |
101 <p>After</p> | |
102 | |
103 <p>End of test</p> | |
104 | |
105 <p id="description"></p> | |
106 <div id="console"></div> | |
107 | |
108 </body> | 79 </body> |
109 </html> | 80 </html> |
OLD | NEW |