2010-04-02 13:33:55 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>ARIA state change event testing</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"
|
2010-09-01 22:09:56 +00:00
|
|
|
src="../common.js"></script>
|
2012-04-04 22:07:49 +00:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="../role.js"></script>
|
2010-04-02 13:33:55 +00:00
|
|
|
<script type="application/javascript"
|
2010-09-01 22:09:56 +00:00
|
|
|
src="../states.js"></script>
|
2010-04-02 13:33:55 +00:00
|
|
|
<script type="application/javascript"
|
2010-09-01 22:09:56 +00:00
|
|
|
src="../events.js"></script>
|
2010-04-02 13:33:55 +00:00
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do tests.
|
|
|
|
*/
|
|
|
|
var gQueue = null;
|
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
//gA11yEventDumpID = "eventdump"; // debugging
|
|
|
|
//gA11yEventDumpToConsole = true; // debugging
|
2011-05-24 14:02:30 +00:00
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
function expandNode(aID, aIsExpanded)
|
2010-04-02 13:33:55 +00:00
|
|
|
{
|
2011-08-11 11:45:36 +00:00
|
|
|
this.DOMNode = getNode(aID);
|
2010-04-02 13:33:55 +00:00
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
this.eventSeq = [
|
|
|
|
new expandedStateChecker(aIsExpanded, this.DOMNode)
|
|
|
|
];
|
2010-04-02 13:33:55 +00:00
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
this.invoke = function expandNode_invoke()
|
|
|
|
{
|
|
|
|
this.DOMNode.setAttribute("aria-expanded",
|
|
|
|
(aIsExpanded ? "true" : "false"));
|
2010-04-02 13:33:55 +00:00
|
|
|
};
|
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
this.getID = function expandNode_getID()
|
|
|
|
{
|
|
|
|
return prettyName(aID) + " aria-expanded changed to '" + aIsExpanded + "'";
|
2010-04-02 13:33:55 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
function busyify(aID, aIsBusy)
|
2011-05-24 14:02:30 +00:00
|
|
|
{
|
2011-08-11 11:45:36 +00:00
|
|
|
this.DOMNode = getNode(aID);
|
|
|
|
|
|
|
|
this.eventSeq = [
|
|
|
|
new stateChangeChecker(STATE_BUSY, kOrdinalState, aIsBusy, this.DOMNode)
|
|
|
|
];
|
|
|
|
|
|
|
|
this.invoke = function busyify_invoke()
|
|
|
|
{
|
|
|
|
this.DOMNode.setAttribute("aria-busy", (aIsBusy ? "true" : "false"));
|
|
|
|
};
|
2011-05-24 14:02:30 +00:00
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
this.getID = function busyify_getID()
|
|
|
|
{
|
|
|
|
return prettyName(aID) + " aria-busy changed to '" + aIsBusy + "'";
|
2011-05-24 14:02:30 +00:00
|
|
|
};
|
2011-08-11 11:45:36 +00:00
|
|
|
}
|
2011-05-24 14:02:30 +00:00
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
function setAttrOfMixedType(aID, aAttr, aState, aValue)
|
|
|
|
{
|
|
|
|
this.DOMNode = getNode(aID);
|
|
|
|
|
|
|
|
this.eventSeq = [
|
|
|
|
new stateChangeChecker(aState, kOrdinalState,
|
|
|
|
aValue == "true", this.DOMNode)
|
|
|
|
];
|
|
|
|
|
|
|
|
if (hasState(aID, STATE_MIXED) || aValue == "mixed") {
|
|
|
|
this.eventSeq.push(
|
|
|
|
new stateChangeChecker(STATE_MIXED, kOrdinalState,
|
|
|
|
aValue == "mixed", this.DOMNode)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.invoke = function setAttrOfMixedType_invoke()
|
|
|
|
{
|
|
|
|
this.DOMNode.setAttribute(aAttr, aValue);
|
2011-05-24 14:02:30 +00:00
|
|
|
};
|
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
this.getID = function setAttrOfMixedType_getID()
|
|
|
|
{
|
|
|
|
return prettyName(aID) + " " + aAttr + " changed to '" + aValue + "'";
|
2011-05-24 14:02:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-08-11 11:45:36 +00:00
|
|
|
function setPressed(aID, aValue)
|
|
|
|
{
|
|
|
|
this.__proto__ =
|
|
|
|
new setAttrOfMixedType(aID, "aria-pressed", STATE_PRESSED, aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setChecked(aID, aValue)
|
|
|
|
{
|
|
|
|
this.__proto__ =
|
|
|
|
new setAttrOfMixedType(aID, "aria-checked", STATE_CHECKED, aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildQueueForAttrOfMixedType(aQueue, aID, aInvokerFunc)
|
|
|
|
{
|
|
|
|
var list = [ "", "undefined", "false", "true", "mixed" ];
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
|
for (var j = i + 1; j < list.length; j++) {
|
|
|
|
// XXX: changes from/to "undefined"/"" shouldn't fire state change
|
|
|
|
// events, bug 472142.
|
|
|
|
aQueue.push(new aInvokerFunc(aID, list[i]));
|
|
|
|
aQueue.push(new aInvokerFunc(aID, list[j]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-02 13:33:55 +00:00
|
|
|
function doTests()
|
|
|
|
{
|
2011-08-11 11:45:36 +00:00
|
|
|
gQueue = new eventQueue();
|
2010-04-02 13:33:55 +00:00
|
|
|
|
|
|
|
gQueue.push(new expandNode("section", true));
|
|
|
|
gQueue.push(new expandNode("section", false));
|
|
|
|
gQueue.push(new expandNode("div", true));
|
|
|
|
gQueue.push(new expandNode("div", false));
|
|
|
|
|
2011-05-24 14:02:30 +00:00
|
|
|
gQueue.push(new busyify("aria_doc", true));
|
|
|
|
gQueue.push(new busyify("aria_doc", false));
|
2011-08-11 11:45:36 +00:00
|
|
|
|
|
|
|
buildQueueForAttrOfMixedType(gQueue, "pressable", setPressed);
|
|
|
|
buildQueueForAttrOfMixedType(gQueue, "checkable", setChecked);
|
|
|
|
|
2010-04-02 13:33:55 +00:00
|
|
|
gQueue.invoke(); // Will call SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
addA11yLoadEvent(doTests);
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=551684"
|
|
|
|
title="No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets">
|
|
|
|
Mozilla Bug 551684
|
2011-08-11 11:45:36 +00:00
|
|
|
</a><br>
|
2011-05-24 14:02:30 +00:00
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=648133"
|
|
|
|
title="fire state change event for aria-busy"
|
|
|
|
Mozilla Bug 648133
|
2011-08-11 11:45:36 +00:00
|
|
|
</a><br>
|
|
|
|
<a target="_blank"
|
|
|
|
href="https://bugzilla.mozilla.org/show_bug.cgi?id=467143"
|
|
|
|
title="mixed state change event is fired for focused accessible only"
|
|
|
|
Mozilla Bug 467143
|
2011-05-24 14:02:30 +00:00
|
|
|
</a>
|
2011-08-11 11:45:36 +00:00
|
|
|
|
2010-04-02 13:33:55 +00:00
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none"></div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
<div id="eventdump"></div>
|
|
|
|
|
|
|
|
<!-- aria-expanded -->
|
|
|
|
<div id="section" role="section" aria-expanded="false">expandable section</div>
|
|
|
|
<div id="div" aria-expanded="false">expandable native div</div>
|
|
|
|
|
2011-05-24 14:02:30 +00:00
|
|
|
<!-- aria-busy -->
|
|
|
|
<div id="aria_doc" role="document" tabindex="0">A document</div>
|
2011-08-11 11:45:36 +00:00
|
|
|
|
|
|
|
<!-- aria-pressed -->
|
|
|
|
<div id="pressable" role="button"></div>
|
|
|
|
|
|
|
|
<!-- aria-checked -->
|
|
|
|
<div id="checkable" role="checkbox"></div>
|
2010-04-02 13:33:55 +00:00
|
|
|
</body>
|
|
|
|
</html>
|