Bug 991969 - Event not fired when description changes, r=jwei

--HG--
rename : accessible/tests/mochitest/events/test_name.xul => accessible/tests/mochitest/events/test_namechange.xul
This commit is contained in:
Alexander Surkov 2014-04-12 00:03:22 -04:00
parent 88d2df771a
commit 72f5f29a8d
6 changed files with 231 additions and 8 deletions

View File

@ -970,17 +970,50 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible,
}
}
if (aAttribute == nsGkAtoms::alt ||
aAttribute == nsGkAtoms::title ||
aAttribute == nsGkAtoms::aria_label ||
aAttribute == nsGkAtoms::aria_labelledby) {
// Fire name change and description change events. XXX: it's not complete and
// dupes the code logic of accessible name and description calculation, we do
// that for performance reasons.
if (aAttribute == nsGkAtoms::aria_label) {
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
return;
}
if (aAttribute == nsGkAtoms::aria_describedby) {
FireDelayedEvent(nsIAccessibleEvent::EVENT_DESCRIPTION_CHANGE, aAccessible);
return;
}
nsIContent* elm = aAccessible->GetContent();
if (aAttribute == nsGkAtoms::aria_labelledby &&
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_label)) {
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
return;
}
if (aAttribute == nsGkAtoms::alt &&
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_label) &&
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_labelledby)) {
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
return;
}
if (aAttribute == nsGkAtoms::title) {
if (!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_label) &&
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_labelledby) &&
!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::alt)) {
FireDelayedEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, aAccessible);
return;
}
if (!elm->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_describedby))
FireDelayedEvent(nsIAccessibleEvent::EVENT_DESCRIPTION_CHANGE, aAccessible);
return;
}
if (aAttribute == nsGkAtoms::aria_busy) {
bool isOn = aAccessible->GetContent()->
AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true, eCaseMatters);
bool isOn = elm->AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true,
eCaseMatters);
nsRefPtr<AccEvent> event =
new AccStateChangeEvent(aAccessible, states::BUSY, isOn);
FireDelayedEvent(event);
@ -993,7 +1026,6 @@ DocAccessible::AttributeChangedImpl(Accessible* aAccessible,
Accessible* widget =
nsAccUtils::GetSelectableContainer(aAccessible, aAccessible->State());
if (widget) {
nsIContent* elm = aAccessible->GetContent();
AccSelChangeEvent::SelChangeType selChangeType =
elm->AttrValueIs(aNameSpaceID, aAttribute, nsGkAtoms::_true, eCaseMatters) ?
AccSelChangeEvent::eSelectionAdd : AccSelChangeEvent::eSelectionRemove;

View File

@ -2,6 +2,7 @@
// Constants
const EVENT_ALERT = nsIAccessibleEvent.EVENT_ALERT;
const EVENT_DESCRIPTION_CHANGE = nsIAccessibleEvent.EVENT_DESCRIPTION_CHANGE;
const EVENT_DOCUMENT_LOAD_COMPLETE = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_COMPLETE;
const EVENT_DOCUMENT_RELOAD = nsIAccessibleEvent.EVENT_DOCUMENT_RELOAD;
const EVENT_DOCUMENT_LOAD_STOPPED = nsIAccessibleEvent.EVENT_DOCUMENT_LOAD_STOPPED;

View File

@ -13,6 +13,7 @@ support-files =
[test_caretmove.xul]
[test_coalescence.html]
[test_contextmenu.html]
[test_descrchange.html]
[test_docload.html]
[test_docload.xul]
[test_docload_aria.html]
@ -41,7 +42,8 @@ skip-if = os == 'win' || os == 'linux'
[test_menu.xul]
[test_mutation.html]
[test_mutation.xhtml]
[test_name.xul]
[test_namechange.xul]
[test_namechange.html]
[test_scroll.xul]
[test_selection.html]
[test_selection.xul]

View File

@ -0,0 +1,85 @@
<html>
<head>
<title>Accessible description 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"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../states.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Invokers
function setAttr(aID, aAttr, aValue, aChecker)
{
this.eventSeq = [ aChecker ];
this.invoke = function setAttr_invoke()
{
getNode(aID).setAttribute(aAttr, aValue);
}
this.getID = function setAttr_getID()
{
return "set attr '" + aAttr + "', value '" + aValue + "'";
}
}
////////////////////////////////////////////////////////////////////////////
// Do tests
//gA11yEventDumpToConsole = true; // debuggin
var gQueue = null;
function doTests()
{
gQueue = new eventQueue();
gQueue.push(new setAttr("tst1", "aria-describedby", "display",
new invokerChecker(EVENT_DESCRIPTION_CHANGE, "tst1")));
gQueue.push(new setAttr("tst1", "title", "title",
new unexpectedInvokerChecker(EVENT_DESCRIPTION_CHANGE, "tst1")));
gQueue.push(new setAttr("tst2", "title", "title",
new invokerChecker(EVENT_NAME_CHANGE, "tst2")));
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=991969"
title="Event not fired when description changes">
Bug 991969
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<button id="tst1">btn1</button>
<button id="tst2">btn2</button>
<div id="eventdump"></div>
</body>
</html>

View File

@ -0,0 +1,103 @@
<html>
<head>
<title>Accessible name 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"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../states.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Invokers
function setAttr(aID, aAttr, aValue, aChecker)
{
this.eventSeq = [ aChecker ];
this.invoke = function setAttr_invoke()
{
getNode(aID).setAttribute(aAttr, aValue);
}
this.getID = function setAttr_getID()
{
return "set attr '" + aAttr + "', value '" + aValue + "'";
}
}
////////////////////////////////////////////////////////////////////////////
// Do tests
//gA11yEventDumpToConsole = true; // debuggin
var gQueue = null;
function doTests()
{
gQueue = new eventQueue();
gQueue.push(new setAttr("tst1", "aria-label", "hi",
new invokerChecker(EVENT_NAME_CHANGE, "tst1")));
gQueue.push(new setAttr("tst1", "aria-labelledby", "display",
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst1")));
gQueue.push(new setAttr("tst1", "alt", "alt",
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst1")));
gQueue.push(new setAttr("tst1", "title", "title",
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst1")));
gQueue.push(new setAttr("tst2", "aria-labelledby", "display",
new invokerChecker(EVENT_NAME_CHANGE, "tst2")));
gQueue.push(new setAttr("tst2", "alt", "alt",
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst2")));
gQueue.push(new setAttr("tst2", "title", "title",
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst2")));
gQueue.push(new setAttr("tst3", "alt", "alt",
new invokerChecker(EVENT_NAME_CHANGE, "tst3")));
gQueue.push(new setAttr("tst3", "title", "title",
new unexpectedInvokerChecker(EVENT_NAME_CHANGE, "tst3")));
gQueue.push(new setAttr("tst4", "title", "title",
new invokerChecker(EVENT_NAME_CHANGE, "tst4")));
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=991969"
title="Event not fired when description changes">
Bug 991969
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<img id="tst1">
<img id="tst2">
<img id="tst3">
<img id="tst4">
<div id="eventdump"></div>
</body>
</html>