Bug 512908 - Don't expose empty live attribute if there is no aria-live and ARIA role hasn't default live value, r=marcoz, davidb

This commit is contained in:
Alexander Surkov 2009-08-28 13:27:27 +08:00
parent e1a92dde70
commit e961b19f17
5 changed files with 32 additions and 19 deletions

View File

@ -706,17 +706,19 @@ nsAccUtils::GetAttributeCharacteristics(nsIAtom* aAtom)
return 0;
}
void
PRBool
nsAccUtils::GetLiveAttrValue(PRUint32 aRule, nsAString& aValue)
{
switch (aRule) {
case eOffLiveAttr:
aValue = NS_LITERAL_STRING("off");
break;
return PR_TRUE;
case ePoliteLiveAttr:
aValue = NS_LITERAL_STRING("polite");
break;
return PR_TRUE;
}
return PR_FALSE;
}
already_AddRefed<nsAccessible>

View File

@ -283,10 +283,15 @@ public:
static PRUint8 GetAttributeCharacteristics(nsIAtom* aAtom);
/**
* Return the 'live' or 'container-live' object attribute value from the given
* Get the 'live' or 'container-live' object attribute value from the given
* ELiveAttrRule constant.
*
* @param aRule [in] rule constant (see ELiveAttrRule in nsAccMap.h)
* @param aValue [out] object attribute value
*
* @return true if object attribute should be exposed
*/
static void GetLiveAttrValue(PRUint32 aRule, nsAString& aValue);
static PRBool GetLiveAttrValue(PRUint32 aRule, nsAString& aValue);
/**
* Query DestinationType from the given SourceType.

View File

@ -1748,8 +1748,8 @@ nsAccessible::GetAttributes(nsIPersistentProperties **aAttributes)
nsAutoString live;
nsAccUtils::GetAccAttr(attributes, nsAccessibilityAtoms::live, live);
if (live.IsEmpty()) {
nsAccUtils::GetLiveAttrValue(mRoleMapEntry->liveAttRule, live);
nsAccUtils::SetAccAttr(attributes, nsAccessibilityAtoms::live, live);
if (nsAccUtils::GetLiveAttrValue(mRoleMapEntry->liveAttRule, live))
nsAccUtils::SetAccAttr(attributes, nsAccessibilityAtoms::live, live);
}
}

View File

@ -22,7 +22,7 @@ function testAttrs(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs)
* @param aAbsentAttrs [in] map of attributes that should not be
* present (name/value pairs)
*/
function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs, aSkipUnexpectedAttrs)
function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs)
{
testAttrsInternal(aAccOrElmOrID, {}, true, aAbsentAttrs);
}
@ -190,6 +190,7 @@ function testAttrsInternal(aAccOrElmOrID, aAttrs, aSkipUnexpectedAttrs,
function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs,
aAbsentAttrs)
{
// Check if all obtained attributes are expected and have expected value.
var enumerate = aAttrs.enumerate();
while (enumerate.hasMoreElements()) {
var prop = enumerate.getNext().QueryInterface(nsIPropertyElement);
@ -209,6 +210,7 @@ function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs,
}
}
// Check if all expected attributes are presented.
for (var name in aExpectedAttrs) {
var value = "";
try {
@ -220,18 +222,20 @@ function compareAttrs(aErrorMsg, aAttrs, aExpectedAttrs, aSkipUnexpectedAttrs,
"There is no expected attribute '" + name + "' " + aErrorMsg);
}
if (aAbsentAttrs)
// Check if all unexpected attributes are absent.
if (aAbsentAttrs) {
for (var name in aAbsentAttrs) {
var value = "";
try {
value = aAttrs.getStringProperty(name);
} catch(e) { }
var wasFound = false;
if (value)
ok(false,
"There is an unexpected attribute '" + name + "' " + aErrorMsg);
else
ok(true,
"There is no unexpected attribute '" + name + "' " + aErrorMsg);
var enumerate = aAttrs.enumerate();
while (enumerate.hasMoreElements()) {
var prop = enumerate.getNext().QueryInterface(nsIPropertyElement);
if (prop.key == name)
wasFound = true;
}
}
ok(!wasFound,
"There is an unexpected attribute '" + name + "' " + aErrorMsg);
}
}

View File

@ -40,6 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
// live object attribute
testAttrs("live", {"live" : "polite"}, true);
testAttrs("live2", {"live" : "polite"}, true);
testAbsentAttrs("live3", {"live" : ""});
testAttrs("log", {"live" : "polite"}, true);
testAttrs("logAssertive", {"live" : "assertive"}, true);
testAttrs("marquee", {"live" : "off"}, true);
@ -121,6 +122,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=391829
<div id="live" aria-live="polite">excuse <div id="liveChild">me</div></div>
<div id="live2" role="marquee" aria-live="polite">excuse <div id="live2Child">me</div></div>
<div id="live3" role="section">excuse</div>
<div id="log" role="log">excuse <div id="logChild">me</div></div>
<div id="logAssertive" role="log" aria-live="assertive">excuse <div id="logAssertiveChild">me</div></div>
<div id="marquee" role="marquee">excuse <div id="marqueeChild">me</div></div>