gecko/accessible/tests/mochitest/test_aria_activedescendant.html

77 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=429547
-->
<head>
<title>Table indexes chrome tests</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">
const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
const ELEMENT_NODE = Components.interfaces.nsIDOMNode.ELEMENT_NODE;
var gAccRetrieval = null;
var gContainerFocused = false;
function doTest()
{
var focusHandler = {
handleEvent: function handleEvent(aEvent) {
var target = aEvent.target;
if (target.nodeType == ELEMENT_NODE &&
target.getAttribute("id") == "container")
gContainerFocused = true;
}
};
var container = document.getElementById("container");
container.addEventListener("focus", focusHandler, false);
gAccRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
getService(nsIAccessibleRetrieval);
var item2 = document.getElementById("item2");
var item2Acc = null;
try {
item2Acc = gAccRetrieval.getAccessibleFor(item2);
} catch (e) {}
ok (item2Acc,
"The element with ID and an ancestor with 'aria-activedescedant' attribute should be accessible.");
if (item2Acc)
item2Acc.takeFocus();
ok(gContainerFocused,
"Container with active descedant didn't recieved the focus.");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=429547"
title="Support aria-activedescendant usage in nsIAccesible::TakeFocus()">
Mozilla Bug 429547
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div aria-activedescendant="item1" id="container" tabindex="1">
<div id="item1">item1</div>
<div id="item2">item2</div>
<div id="item3">item3</div>
</div>
</body>
</html>