blob: d7c041093f67e3544bde197b97c3c4dc3dec50b4 [file] [log] [blame]
<html>
<head>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
function buildAccessibilityTree(accessibilityObject, indent) {
var str = "";
for (var i = 0; i < indent; i++)
str += " ";
str += accessibilityObject.role;
str += " " + accessibilityObject.stringValue;
if (accessibilityObject.role == '')
str += accessibilityObject.allAttributes();
str += "\n";
document.getElementById("console").innerText += str;
if (accessibilityObject.stringValue.indexOf('End of test') >= 0)
return false;
var count = accessibilityObject.childrenCount;
for (var i = 0; i < count; ++i) {
if (!buildAccessibilityTree(accessibilityObject.childAtIndex(i), indent + 1))
return false;
}
return true;
}
function runTest()
{
description("This tests that deleting an iframe doesn't cause the accessibility cache to be destroyed and recreated.");
if (window.accessibilityController) {
window.root = accessibilityController.rootElement;
window.body = root.childAtIndex(0);
window.before = body.childAtIndex(0).childAtIndex(0);
window.iframe = body.childAtIndex(1).childAtIndex(0);
window.after = body.childAtIndex(2).childAtIndex(0);
window.frameBody = window.iframe.childAtIndex(0);
window.frameBodyRole = window.frameBody.role;
window.frameGroup = window.frameBody.childAtIndex(0);
window.frameGroupRole = window.frameGroup.role;
window.frameButton = window.frameGroup.childAtIndex(0);
window.frameButtonRole = window.frameButton.role;
document.getElementById("console").innerText += "\nBefore:\n";
buildAccessibilityTree(root, 0);
// Remove the iframe.
document.body.removeChild(document.getElementById("iframe"));
window.newRoot = accessibilityController.rootElement;
window.newBody = newRoot.childAtIndex(0);
window.newBefore = newBody.childAtIndex(0).childAtIndex(0);
window.newAfter = newBody.childAtIndex(1).childAtIndex(0);
document.getElementById("console").innerText += "\nAfter:\n";
buildAccessibilityTree(newRoot, 0);
document.getElementById("console").innerText += "\n";
// Make sure that the accessibility objects from the iframe's nodes
// are now invalid by checking that their role is changed - this
// is because they've been deleted.
shouldBeFalse("frameBodyRole == frameBody.role");
shouldBeFalse("frameGroupRole == frameGroup.role");
shouldBeFalse("frameButtonRole == frameButton.role");
// Make sure that the other nodes are unchanged.
shouldBeTrue("root.isEqual(newRoot)");
shouldBeTrue("body.isEqual(newBody)");
shouldBeTrue("before.isEqual(newBefore)");
shouldBeTrue("after.isEqual(newAfter)");
}
debug('<br /><span class="pass">TEST COMPLETE</span>');
if (window.testRunner)
testRunner.notifyDone();
}
window.addEventListener('load', function() {
setTimeout(runTest, 10);
}, false);
</script>
</head>
<body>
<p>Before</p>
<iframe id="iframe" src="data:text/html,<body><button>Click me</button></body>"></iframe>
<p>After</p>
<p>End of test</p>
<p id="description"></p>
<div id="console"></div>
</body>
</html>