pjs/accessible/tests/mochitest/test_bug434464.html

89 строки
2.8 KiB
HTML

<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=434464
-->
<head>
<title>Test NSIAccessNode cache invalidation</title>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript">
function doTest()
{
var accRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
getService(Components.interfaces.nsIAccessibleRetrieval);
var parentElm = document.getElementById("parent");
if (!parentElm) {
ok(false, "no parent element for paragraph!");
SimpleTest.finish();
}
var elm = document.getElementById("para");
if (!elm) {
ok(false, "no element for paragraph!");
SimpleTest.finish();
}
// It's currently hidden. Ask for its parent's nsIAccessNode.
var parentElmAccNode = null;
try {
parentElmAccNode = accRetrieval.getAccessibleFor(parentElm).
QueryInterface(Components.interfaces.nsIAccessNode);
} catch(e) {}
if (!parentElmAccNode) {
ok(false, "No accessNode for parent of hidden paragraph!");
SimpleTest.finish();
}
// Get the paragraph's accessNode.
var elmAccNode = null;
try {
elmAccNode = parentElmAccNode.firstChildNode;
} catch(e) {}
if (!elmAccNode) {
ok(false, "No accessNode for hidden paragraph!");
SimpleTest.finish();
}
// Now make the paragraph visible. This invalidates the just-retrieved
// AccessNode. An nsIAccessible should then be retrievable.
elm.style.display = "block";
// Now, get an accessible for it. Use a timeout so the layout engine can
// catch up.
window.setTimeout(
function()
{
var elmAcc = null;
try {
elmAcc = accRetrieval.getAccessibleFor(elm);
} catch(e) {}
ok(elmAcc, "No accessible for paragraph after it became visible!");
SimpleTest.finish();
},
200);
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=434464">Mozilla Bug 434464</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="parent"><p style="display: none;" id="para">I'm hidden initially, but then made visible.</p></div>
</body>
</html>