bug 761901 - HTML5 progress accessible should fire value change event r=tbsaunde

This commit is contained in:
James Kitchener 2012-10-15 23:05:20 -04:00
parent be00aa7981
commit 6b76c60285
5 changed files with 66 additions and 21 deletions

View File

@ -505,6 +505,8 @@ public:
inline bool IsMenuPopup() const { return mFlags & eMenuPopupAccessible; }
inline bool IsProgress() const { return mFlags & eProgressAccessible; }
inline bool IsRoot() const { return mFlags & eRootAccessible; }
mozilla::a11y::RootAccessible* AsRoot();
@ -776,10 +778,11 @@ protected:
eListControlAccessible = 1 << 17,
eMenuButtonAccessible = 1 << 18,
eMenuPopupAccessible = 1 << 19,
eRootAccessible = 1 << 20,
eTextLeafAccessible = 1 << 21,
eXULDeckAccessible = 1 << 22,
eXULTreeAccessible = 1 << 23
eProgressAccessible = 1 << 20,
eRootAccessible = 1 << 21,
eTextLeafAccessible = 1 << 22,
eXULDeckAccessible = 1 << 23,
eXULTreeAccessible = 1 << 24
};
//////////////////////////////////////////////////////////////////////////////

View File

@ -1122,6 +1122,14 @@ DocAccessible::AttributeChangedImpl(nsIContent* aContent, int32_t aNameSpaceID,
FireDelayedAccessibleEvent(editableChangeEvent);
return;
}
if (aAttribute == nsGkAtoms::value) {
Accessible* accessible = GetAccessible(aContent);
if(accessible->IsProgress()) {
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
aContent);
}
}
}
// DocAccessible protected member

View File

@ -21,7 +21,7 @@ public:
ProgressMeterAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc)
{
mFlags = mFlags | eHasNumericValue;
mFlags |= eHasNumericValue | eProgressAccessible;
}
NS_DECL_ISUPPORTS_INHERITED

View File

@ -475,9 +475,13 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
#endif
}
else if (eventType.EqualsLiteral("ValueChange")) {
//We don't process 'ValueChange' events for progress meters since we listen
//@value attribute change for them.
if (!accessible->IsProgress())
targetDocument->
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
targetNode, AccEvent::eRemoveDupes);
targetNode);
}
#ifdef DEBUG_DRAGDROPSTART
else if (eventType.EqualsLiteral("mouseover")) {

View File

@ -26,11 +26,11 @@
var gQueue = null;
// Value change invoker
function changeValue(aNodeOrID, aValuenow, aValuetext)
function changeARIAValue(aNodeOrID, aValuenow, aValuetext)
{
this.DOMNode = getNode(aNodeOrID);
this.invoke = function changeValue_invoke() {
this.invoke = function changeARIAValue_invoke() {
// Note: this should not fire an EVENT_VALUE_CHANGE when aria-valuetext
// is not empty
@ -42,7 +42,7 @@
this.DOMNode.setAttribute("aria-valuetext", aValuetext);
}
this.check = function changeValue_check() {
this.check = function changeARIAValue_check() {
var acc = getAccessible(aNodeOrID, [nsIAccessibleValue]);
if (!acc)
return;
@ -53,32 +53,49 @@
"Wrong value of " + prettyName(aNodeOrID));
}
this.getID = function changeValue_getID() {
this.getID = function changeARIAValue_getID() {
return prettyName(aNodeOrID) + " value changed";
}
}
function changeInputValue(aID, aValue)
function changeValue(aID, aValue)
{
this.DOMNode = getNode(aID);
this.invoke = function changeInputValue_invoke()
this.invoke = function changeValue_invoke()
{
this.DOMNode.value = aValue;
}
this.check = function changeInputValue_check()
this.check = function changeValue_check()
{
var acc = getAccessible(this.DOMNode);
is(acc.value, aValue, "Wrong value for " + prettyName(aID));
}
this.getID = function changeInputValue_getID()
this.getID = function changeValue_getID()
{
return prettyName(aID) + " value changed";
}
}
function changeProcessValue(aID, aValue) {
this.DOMNode = getNode(aID);
this.invoke = function changeProcessValue_invoke() {
this.DOMNode.value = aValue;
}
this.check = function changeProcessValue_check() {
var acc = getAccessible(this.DOMNode);
is(acc.value, aValue+"%", "Wrong value for " + prettyName(aID));
}
this.getID = function changeProcessValue_getID() {
return prettyName(aID) + " value changed";
}
}
function doTests()
{
// Test initial values
@ -86,16 +103,19 @@
testValue("slider_vnvt", "plain", 0, 0, 5, 0);
testValue("slider_vt", "hi", 0, 0, 3, 0);
testValue("scrollbar", "5", 5, 0, 1000, 0);
testValue("progress", "22%", 22, 0, 100, 0);
// Test value change events
gQueue = new eventQueue(nsIAccessibleEvent.EVENT_VALUE_CHANGE);
gQueue.push(new changeValue("slider_vn", "6", undefined));
gQueue.push(new changeValue("slider_vt", undefined, "hey!"));
gQueue.push(new changeValue("slider_vnvt", "3", "sweet"));
gQueue.push(new changeValue("scrollbar", "6", undefined));
gQueue.push(new changeARIAValue("slider_vn", "6", undefined));
gQueue.push(new changeARIAValue("slider_vt", undefined, "hey!"));
gQueue.push(new changeARIAValue("slider_vnvt", "3", "sweet"));
gQueue.push(new changeARIAValue("scrollbar", "6", undefined));
gQueue.push(new changeInputValue("combobox", "hello"));
gQueue.push(new changeValue("combobox", "hello"));
gQueue.push(new changeProcessValue("progress", "50"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -122,6 +142,12 @@
title="ARIA comboboxes don't fire value change events">
Mozilla Bug 703202
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=761901"
title=" HTML5 progress accessible should fire value change event">
Mozilla Bug 761901
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -145,5 +171,9 @@
<!-- ARIA combobox -->
<input id="combobox" role="combobox" aria-autocomplete="inline">
<!-- progress bar -->
<progress id="progress" value="22" max="100"></progress>
</body>
</html>