Bug 551684 - No statechange event for aria-expanded on native HTML elements, is fired on ARIA widgets; r=MarcoZ,surkov

This commit is contained in:
David Bolter 2010-04-02 09:33:55 -04:00
parent 986b546ddd
commit 410cab1d6f
3 changed files with 107 additions and 17 deletions

View File

@ -1179,6 +1179,9 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
if (!targetNode)
return;
// Note: For universal/global ARIA states and properties we don't care if
// there is an ARIA role present or not.
if (aAttribute == nsAccessibilityAtoms::aria_required) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(targetNode,
@ -1209,6 +1212,24 @@ 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 == nsAccessibilityAtoms::aria_grabbed ||
aAttribute == nsAccessibilityAtoms::aria_dropeffect) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
targetNode);
}
// We treat aria-expanded as a global ARIA state for historical reasons
if (aAttribute == nsAccessibilityAtoms::aria_expanded) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE);
FireDelayedAccessibleEvent(event);
return;
}
if (!aContent->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::role)) {
// We don't care about these other ARIA attribute changes unless there is
// an ARIA role set for the element
@ -1249,15 +1270,6 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
return;
}
if (aAttribute == nsAccessibilityAtoms::aria_expanded) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(targetNode,
nsIAccessibleStates::STATE_EXPANDED,
PR_FALSE);
FireDelayedAccessibleEvent(event);
return;
}
if (aAttribute == nsAccessibilityAtoms::aria_readonly) {
nsRefPtr<nsAccEvent> event =
new nsAccStateChangeEvent(targetNode,
@ -1290,14 +1302,6 @@ nsDocAccessible::ARIAAttributeChanged(nsIContent* aContent, nsIAtom* aAttribute)
nsIAccessibilityService::NODE_SIGNIFICANT_CHANGE);
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 == nsAccessibilityAtoms::aria_grabbed ||
aAttribute == nsAccessibilityAtoms::aria_dropeffect) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_OBJECT_ATTRIBUTE_CHANGED,
targetNode);
}
}
void nsDocAccessible::ContentAppended(nsIDocument *aDocument,

View File

@ -48,6 +48,7 @@ include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
focus.html \
scroll.html \
test_aria_statechange.html \
test_attrs.html \
test_caretmove.html \
$(warning test_coalescence.html temporarily disabled) \

View File

@ -0,0 +1,85 @@
<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/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/states.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript">
/**
* Do tests.
*/
var gQueue = null;
function expandNode(aNodeOrID, bExpand)
{
this.DOMNode = getNode(aNodeOrID);
this.invoke = function expand_invoke() {
// Note: this should fire an EVENT_STATE_CHANGE
this.DOMNode.setAttribute("aria-expanded", bExpand);
};
this.check = function expand_check() {
testStates(aNodeOrID,
bExpand ? STATE_EXPANDED : STATE_COLLAPSED,
EXT_STATE_EXPANDABLE);
};
this.getID = function changeValue_getID() {
return prettyName(aNodeOrID) + " aria-expanded changed";
};
}
function doTests()
{
gQueue = new eventQueue(nsIAccessibleEvent.EVENT_STATE_CHANGE);
gQueue.push(new expandNode("section", true));
gQueue.push(new expandNode("section", false));
gQueue.push(new expandNode("div", true));
gQueue.push(new expandNode("div", false));
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
</a>
<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>
</body>
</html>