blob: 06de2181b736f28ac7d4fceccd358b07373f21f6 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body id="body">
<iframe width=500 height=500 id="frame1" title="frame1"></iframe>
<iframe width=500 height=500 id="frame2" title="frame2"></iframe>
<iframe width=500 height=500 id="frame3" title="frame3"></iframe>
<p id="description"></p>
<div id="console"></div>
<script>
jsTestIsAsync = true;
// We have to play some games to get these frames to load their sources in a timely fashion.
document.getElementById("frame1").src = "data:text/html,<body id='body1'><button id=button1>button1</button><BR><BR><BR></body>";
document.getElementById("frame2").src = "data:text/html,<body>text<BR><BR><BR></body>";
document.getElementById("frame3").src = "data:text/html,<body><button id=button3>button3</button><BR><BR><BR></body>";
</script>
<script>
var frame1aLoaded = false;
var frame2aLoaded = false;
var frame3aLoaded = false;
for (var k = 1; k <= 3; k++) {
// This block adds sub frames to each of the frames, with some content in them.
// When the last frame loads, it runs the test.
document.getElementById("frame" + k).onload = function(e) {
var iframe = document.createElement("iframe");
iframe.setAttribute("name", e.target.id + "a");
iframe.onload = function() {
if (iframe.name == "frame1a")
frame1aLoaded = true;
else if (iframe.name == "frame2a")
frame2aLoaded = true;
else if (iframe.name == "frame3a")
frame3aLoaded = true;
// Call runTest() when all frames have been loaded.
if (frame1aLoaded && frame2aLoaded && frame3aLoaded)
runTest();
};
if (e.target.id == "frame2") {
iframe.setAttribute("src", "data:text/html,<body><button id=button2>button2</button></body>");
} else {
iframe.setAttribute("src", "data:text/html,<body>text</body>");
}
iframe.style.width = "200";
iframe.style.height = "200";
this.contentDocument.childNodes[0].childNodes[1].appendChild(iframe);
};
}
</script>
<script>
description("This tests whether searching works to find frames and to find elements within frames.");
function runTest() {
if (window.accessibilityController) {
document.getElementById("body").focus();
var body = accessibilityController.focusedElement;
// Search for the buttons. This tests searching through the frames.
searchKey = "AXButtonSearchKey";
resultElement = body.uiElementForSearchPredicate("", true, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXButton'");
shouldBe("resultElement.title", "'AXTitle: button1'");
resultElement = body.uiElementForSearchPredicate(resultElement, true, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXButton'");
shouldBe("resultElement.title", "'AXTitle: button2'");
resultElement = body.uiElementForSearchPredicate(resultElement, true, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXButton'");
shouldBe("resultElement.title", "'AXTitle: button3'");
// Now search backwards.
resultElement = body.uiElementForSearchPredicate(resultElement, false, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXButton'");
shouldBe("resultElement.title", "'AXTitle: button2'");
// Search for the frames. First one is frame1
searchKey = "AXFrameSearchKey";
resultElement = body.uiElementForSearchPredicate("", true, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXWebArea'");
shouldBe("resultElement.description", "'AXDescription: frame1'");
// Next we should find the frame inside of frame1.
resultElement = body.uiElementForSearchPredicate(resultElement, true, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXWebArea'");
shouldBe("resultElement.description", "'AXDescription: frame1a'");
// Then we should find the frame after frame1.
resultElement = body.uiElementForSearchPredicate(resultElement, true, searchKey, "", false);
shouldBe("resultElement.role", "'AXRole: AXWebArea'");
shouldBe("resultElement.description", "'AXDescription: frame2'");
}
successfullyParsed = true;
finishJSTest();
}
</script>
</body>
</html>