Bug 563862 - Expand support for aria attribute change events. r=marcoz,surkov

This commit is contained in:
David Bolter 2012-04-24 13:39:03 -04:00
parent 9b1190f3f6
commit 03f7557124
3 changed files with 37 additions and 38 deletions

View File

@ -1137,16 +1137,6 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
return;
}
// For aria drag and drop changes we fire a generic attribute change event;
// at least until native API comes up with a more meaningful event.
if (aAttribute == nsGkAtoms::aria_grabbed ||
aAttribute == nsGkAtoms::aria_dropeffect ||
aAttribute == nsGkAtoms::aria_hidden ||
aAttribute == nsGkAtoms::aria_sort) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
aContent);
}
// We treat aria-expanded as a global ARIA state for historical reasons
if (aAttribute == nsGkAtoms::aria_expanded) {
nsRefPtr<AccEvent> event =
@ -1155,6 +1145,13 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
return;
}
// For aria attributes like drag and drop changes we fire a generic attribute
// change event; at least until native API comes up with a more meaningful event.
PRUint8 attrFlags = nsAccUtils::GetAttributeCharacteristics(aAttribute);
if (!(attrFlags & ATTR_BYPASSOBJ))
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
aContent);
if (!aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::role)) {
// We don't care about these other ARIA attribute changes unless there is
// an ARIA role set for the element

View File

@ -109,6 +109,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036
// no object attributes
testAbsentAttrs(getAccessible("listitem").firstChild, { "tag": "" });
// experimental aria
testAttrs("experimental", {"blah" : "true"}, true);
SimpleTest.finish();
}
@ -142,6 +145,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036
title="Add test coverage for tablist as implicit live region">
Mozilla Bug 663136
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=563862"
title="Expand support for nsIAccessibleEvent::OBJECT_ATTRIBUTE_CHANGE">
Mozilla Bug 563862
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -201,5 +209,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=558036
<ul>
<li id="listitem">item
</ul>
<!-- experimental aria -->
<div id="experimental" aria-blah="true">Fake beer</div>
</body>
</html>

View File

@ -21,7 +21,7 @@
*/
var gQueue = null;
function hideNode(aID, bHide)
function updateAttribute(aID, aAttr, aValue)
{
this.node = getNode(aID);
this.accessible = getAccessible(this.node);
@ -30,34 +30,14 @@
new invokerChecker(EVENT_OBJECT_ATTRIBUTE_CHANGED, this.accessible),
];
this.invoke = function hideNode_invoke()
this.invoke = function updateAttribute_invoke()
{
this.node.setAttribute("aria-hidden", bHide);
this.node.setAttribute(aAttr, aValue);
}
this.getID = function hideNode_getID()
this.getID = function updateAttribute_getID()
{
return "aria-hidden for " + aID + " " + bHide;
}
}
function updateSort(aID, aSort)
{
this.node = getNode(aID);
this.accessible = getAccessible(this.node);
this.eventSeq = [
new invokerChecker(EVENT_OBJECT_ATTRIBUTE_CHANGED, this.accessible),
];
this.invoke = function updateSort_invoke()
{
this.node.setAttribute("aria-sort", aSort);
}
this.getID = function updateSort_getID()
{
return "aria-sort for " + aID + " " + aSort;
return aAttr + " for " + aID + " " + aValue;
}
}
@ -69,9 +49,12 @@
{
gQueue = new eventQueue();
gQueue.push(new hideNode("hideable", "true"));
gQueue.push(new updateAttribute("hideable", "aria-hidden", "true"));
gQueue.push(new updateSort("sortable", "ascending"));
gQueue.push(new updateAttribute("sortable", "aria-sort", "ascending"));
// For experimental ARIA extensions
gQueue.push(new updateAttribute("custom", "aria-blah", "true"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -95,6 +78,12 @@
Mozilla Bug 640707
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=640707"
title="Expand support for aria attribute change events">
Mozilla Bug 563862
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
@ -103,6 +92,8 @@
<div id="hideable"><div>Hi</div><div>there</div></div>
<div id="sortable" role="columnheader" aria-sort"none">aria-sort</div>
<div id="sortable" role="columnheader" aria-sort="none">aria-sort</div>
<div id="custom" role="custom" aria-blah="false">Fat free cheese</div>
</body>
</html>