2011-09-28 05:46:11 +04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=429547
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>aria-activedescendant focus tests</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="../common.js"></script>
|
2012-04-05 02:07:49 +04:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="../role.js"></script>
|
2011-09-28 05:46:11 +04:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="../states.js"></script>
|
|
|
|
<script type="application/javascript"
|
|
|
|
src="../events.js"></script>
|
|
|
|
|
|
|
|
<script type="application/javascript">
|
2017-08-01 19:15:51 +03:00
|
|
|
// gA11yEventDumpToConsole = true; // debugging
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
function changeARIAActiveDescendant(aID, aItemID) {
|
2011-09-28 05:46:11 +04:00
|
|
|
this.eventSeq = [
|
2018-10-19 15:55:39 +03:00
|
|
|
new focusChecker(aItemID),
|
2011-09-28 05:46:11 +04:00
|
|
|
];
|
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
this.invoke = function changeARIAActiveDescendant_invoke() {
|
2011-09-28 05:46:11 +04:00
|
|
|
getNode(aID).setAttribute("aria-activedescendant", aItemID);
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
this.getID = function changeARIAActiveDescendant_getID() {
|
2011-09-28 05:46:11 +04:00
|
|
|
return "change aria-activedescendant on " + aItemID;
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
|
2018-08-31 10:00:59 +03:00
|
|
|
function clearARIAActiveDescendant(aID) {
|
|
|
|
this.eventSeq = [
|
2018-10-19 15:55:39 +03:00
|
|
|
new focusChecker(aID),
|
2018-08-31 10:00:59 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
this.invoke = function clearARIAActiveDescendant_invoke() {
|
|
|
|
getNode(aID).removeAttribute("aria-activedescendant");
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getID = function clearARIAActiveDescendant_getID() {
|
|
|
|
return "clear aria-activedescendant on container " + aID;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-09-05 07:43:18 +03:00
|
|
|
/**
|
|
|
|
* Change aria-activedescendant to an invalid (non-existent) id.
|
|
|
|
* Ensure that focus is fired on the element itself.
|
|
|
|
*/
|
|
|
|
function changeARIAActiveDescendantInvalid(aID, aInvalidID) {
|
|
|
|
if (!aInvalidID) {
|
|
|
|
aInvalidID = "invalid";
|
|
|
|
}
|
|
|
|
|
2018-08-31 10:00:59 +03:00
|
|
|
this.eventSeq = [
|
2018-10-19 15:55:39 +03:00
|
|
|
new focusChecker(aID),
|
2018-08-31 10:00:59 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
this.invoke = function changeARIAActiveDescendant_invoke() {
|
2018-09-05 07:43:18 +03:00
|
|
|
getNode(aID).setAttribute("aria-activedescendant", aInvalidID);
|
2018-08-31 10:00:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
this.getID = function changeARIAActiveDescendant_getID() {
|
|
|
|
return "change aria-activedescendant to invalid id";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
function insertItemNFocus(aID, aNewItemID) {
|
2011-09-28 05:46:11 +04:00
|
|
|
this.eventSeq = [
|
|
|
|
new invokerChecker(EVENT_SHOW, aNewItemID),
|
2018-10-19 15:55:39 +03:00
|
|
|
new focusChecker(aNewItemID),
|
2011-09-28 05:46:11 +04:00
|
|
|
];
|
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
this.invoke = function insertItemNFocus_invoke() {
|
2011-09-28 05:46:11 +04:00
|
|
|
var container = getNode(aID);
|
2018-06-08 17:55:08 +03:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
var itemNode = document.createElement("div");
|
|
|
|
itemNode.setAttribute("id", aNewItemID);
|
2018-06-08 17:55:08 +03:00
|
|
|
itemNode.setAttribute("role", "listitem");
|
2015-11-03 19:03:34 +03:00
|
|
|
itemNode.textContent = aNewItemID;
|
2011-09-28 05:46:11 +04:00
|
|
|
container.appendChild(itemNode);
|
|
|
|
|
|
|
|
container.setAttribute("aria-activedescendant", aNewItemID);
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2017-08-01 21:08:02 +03:00
|
|
|
this.getID = function insertItemNFocus_getID() {
|
2011-09-28 05:46:11 +04:00
|
|
|
return "insert new node and focus it with ID: " + aNewItemID;
|
2017-10-15 21:50:30 +03:00
|
|
|
};
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
|
2018-09-05 07:43:18 +03:00
|
|
|
/**
|
|
|
|
* Change the id of an element to another id which is the target of
|
|
|
|
* aria-activedescendant.
|
|
|
|
* If another element already has the desired id, remove it from that
|
|
|
|
* element first.
|
|
|
|
* Ensure that focus is fired on the target element which was given the
|
|
|
|
* desired id.
|
|
|
|
* @param aFromID The existing id of the target element.
|
|
|
|
* @param aToID The desired id to be given to the target element.
|
|
|
|
*/
|
|
|
|
function moveARIAActiveDescendantID(aFromID, aToID) {
|
|
|
|
this.eventSeq = [
|
2018-10-19 15:55:39 +03:00
|
|
|
new focusChecker(aToID),
|
2018-09-05 07:43:18 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
this.invoke = function moveARIAActiveDescendantID_invoke() {
|
|
|
|
let orig = document.getElementById(aToID);
|
|
|
|
if (orig) {
|
|
|
|
orig.id = "";
|
|
|
|
}
|
|
|
|
document.getElementById(aFromID).id = aToID;
|
|
|
|
};
|
|
|
|
|
|
|
|
this.getID = function moveARIAActiveDescendantID_getID() {
|
|
|
|
return "move aria-activedescendant id " + aToID;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
var gQueue = null;
|
2017-08-01 21:08:02 +03:00
|
|
|
function doTest() {
|
2011-09-28 05:46:11 +04:00
|
|
|
gQueue = new eventQueue();
|
|
|
|
|
2015-11-03 19:03:34 +03:00
|
|
|
gQueue.push(new synthFocus("listbox", new focusChecker("item1")));
|
|
|
|
gQueue.push(new changeARIAActiveDescendant("listbox", "item2"));
|
|
|
|
gQueue.push(new changeARIAActiveDescendant("listbox", "item3"));
|
2012-09-05 15:03:39 +04:00
|
|
|
|
|
|
|
gQueue.push(new synthFocus("combobox_entry", new focusChecker("combobox_entry")));
|
|
|
|
gQueue.push(new changeARIAActiveDescendant("combobox", "combobox_option2"));
|
|
|
|
|
2018-06-08 17:55:08 +03:00
|
|
|
gQueue.push(new synthFocus("listbox", new focusChecker("item3")));
|
|
|
|
gQueue.push(new insertItemNFocus("listbox", "item4"));
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2018-08-31 10:00:59 +03:00
|
|
|
gQueue.push(new clearARIAActiveDescendant("listbox"));
|
|
|
|
gQueue.push(new changeARIAActiveDescendant("listbox", "item1"));
|
2018-09-05 07:43:18 +03:00
|
|
|
gQueue.push(new changeARIAActiveDescendantInvalid("listbox", "invalid"));
|
|
|
|
|
|
|
|
gQueue.push(new changeARIAActiveDescendant("listbox", "roaming"));
|
|
|
|
gQueue.push(new moveARIAActiveDescendantID("roaming2", "roaming"));
|
|
|
|
gQueue.push(new changeARIAActiveDescendantInvalid("listbox", "roaming3"));
|
|
|
|
gQueue.push(new moveARIAActiveDescendantID("roaming", "roaming3"));
|
2018-08-31 10:00:59 +03:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addA11yLoadEvent(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>
|
2012-09-05 15:03:39 +04:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=761102"
|
|
|
|
title="Focus may be missed when ARIA active-descendant is changed on active composite widget">
|
|
|
|
Mozilla Bug 761102
|
|
|
|
</a>
|
2011-09-28 05:46:11 +04:00
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
|
2015-11-03 19:03:34 +03:00
|
|
|
<div role="listbox" aria-activedescendant="item1" id="listbox" tabindex="1"
|
|
|
|
aria-owns="item3">
|
2011-09-28 05:46:11 +04:00
|
|
|
<div role="listitem" id="item1">item1</div>
|
|
|
|
<div role="listitem" id="item2">item2</div>
|
2018-09-05 07:43:18 +03:00
|
|
|
<div role="listitem" id="roaming">roaming</div>
|
|
|
|
<div role="listitem" id="roaming2">roaming2</div>
|
2011-09-28 05:46:11 +04:00
|
|
|
</div>
|
2015-11-03 19:03:34 +03:00
|
|
|
<div role="listitem" id="item3">item3</div>
|
2012-09-05 15:03:39 +04:00
|
|
|
|
|
|
|
<div role="combobox" id="combobox">
|
|
|
|
<input id="combobox_entry">
|
|
|
|
<ul>
|
|
|
|
<li role="option" id="combobox_option1">option1</li>
|
|
|
|
<li role="option" id="combobox_option2">option2</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2011-09-28 05:46:11 +04:00
|
|
|
</body>
|
|
|
|
</html>
|