Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<html>
<head>
<title>Accessible events testing for document</title>
<link rel="stylesheet" type="text/css"
<script type="application/javascript"
src="../../common.js"></script>
<script type="application/javascript"
src="../../role.js"></script>
<script type="application/javascript"
src="../../promisified-events.js"></script>
<script type="application/javascript">
const { TestUtils } = ChromeUtils.importESModule(
let gDialog;
let gDialogDoc;
let gRootAcc;
async function doTests() {
if (Services.appShell.hasHiddenWindow) {
// Front end stuff sometimes likes to stuff things in the hidden window(s)
// in which case we should repress all accessibles for those.
// Try to create an accessible for the hidden window's document.
let doc = Services.appShell.hiddenDOMWindow.document;
let hiddenDocAcc = gAccService.getAccessibleFor(doc);
ok(!hiddenDocAcc, "hiddenDOMWindow should not have an accessible.");
}
// Get application root accessible.
let docAcc = getAccessible(document);
while (docAcc) {
gRootAcc = docAcc;
try {
docAcc = docAcc.parent;
} catch (e) {
ok(false, `Can't get parent for ${prettyName(docAcc)}`);
throw e;
}
}
const evts = waitForEvents([
[EVENT_REORDER, gRootAcc],
[EVENT_FOCUS, e => {
let doc = e.accessible.QueryInterface(Ci.nsIAccessibleDocument);
return doc.URL == "about:about";
}]
]);
gDialog = window.browsingContext.topChromeWindow.openDialog("about:about");
await evts;
testAccessibleTree(gRootAcc, {
role: ROLE_APP_ROOT,
children: [
{ role: ROLE_CHROME_WINDOW },
{ role: ROLE_CHROME_WINDOW },
],
});
gDialogDoc = gDialog.document;
ok(isAccessibleInCache(gDialogDoc),
"The document accessible for 'about:about' is not in cache!");
const focused = waitForEvent(EVENT_FOCUS, getAccessible(document));
gDialog.close();
window.focus();
await focused;
await TestUtils.waitForTick();
ok(!isAccessibleInCache(gDialogDoc),
"The document accessible for dialog is in cache still!");
gDialog = gDialogDoc = gRootAcc = null;
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
title="Fire event_reorder application root accessible">
Mozilla Bug 506206
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
</html>