test for bug 434464 - invalidate access node cache, r=aaronlev

This commit is contained in:
Marco Zehe 2008-08-25 21:23:37 +02:00
Родитель 010c533993
Коммит c1472f7092
2 изменённых файлов: 89 добавлений и 0 удалений

Просмотреть файл

@ -78,6 +78,7 @@ _TEST_FILES =\
testTextboxes.js \
test_bug428479.html \
test_bug429285.html \
test_bug434464.html \
$(NULL)
libs:: $(_TEST_FILES)

Просмотреть файл

@ -0,0 +1,88 @@
<!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>