mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 489944 - @title attribute no longer exposed on accDescription, r=davidb, r=MarcoZ
This commit is contained in:
parent
283ed25b1f
commit
af5087052d
@ -319,21 +319,27 @@ nsAccessible::GetName(nsAString& aName)
|
||||
|
||||
NS_IMETHODIMP nsAccessible::GetDescription(nsAString& aDescription)
|
||||
{
|
||||
if (IsDefunct())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// There are 4 conditions that make an accessible have no accDescription:
|
||||
// 1. it's a text node; or
|
||||
// 2. It has no DHTML describedby property
|
||||
// 3. it doesn't have an accName; or
|
||||
// 4. its title attribute already equals to its accName nsAutoString name;
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
||||
if (!content) {
|
||||
return NS_ERROR_FAILURE; // Node shut down
|
||||
}
|
||||
NS_ASSERTION(content, "No content of valid accessible!");
|
||||
if (!content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!content->IsNodeOfType(nsINode::eTEXT)) {
|
||||
nsAutoString description;
|
||||
nsresult rv = nsTextEquivUtils::
|
||||
GetTextEquivFromIDRefs(this, nsAccessibilityAtoms::aria_describedby,
|
||||
description);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (description.IsEmpty()) {
|
||||
PRBool isXUL = content->IsNodeOfType(nsINode::eXUL);
|
||||
if (isXUL) {
|
||||
// Try XUL <description control="[id]">description text</description>
|
||||
|
@ -75,6 +75,7 @@ _TEST_FILES =\
|
||||
test_bug420863.html \
|
||||
$(warning test_childAtPoint.xul temporarily disabled) \
|
||||
test_cssattrs.html \
|
||||
test_descr.html \
|
||||
test_elm_filectrl.html \
|
||||
test_elm_media.html \
|
||||
test_elm_txtcntnr.html \
|
||||
|
65
accessible/tests/mochitest/test_descr.html
Normal file
65
accessible/tests/mochitest/test_descr.html
Normal file
@ -0,0 +1,65 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>nsIAccessible::description tests</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">
|
||||
function testDescr(aAccOrElmOrID, aDescr)
|
||||
{
|
||||
var acc = getAccessible(aAccOrElmOrID);
|
||||
if (!acc)
|
||||
return;
|
||||
|
||||
is(acc.description, aDescr,
|
||||
"Wrong description for " + prettyName(aAccOrElmOrID));
|
||||
}
|
||||
|
||||
function doTest()
|
||||
{
|
||||
// Description from aria-describedby attribute
|
||||
testDescr("img1", "aria description");
|
||||
|
||||
// No description from @title attribute because it is used to generate
|
||||
// name.
|
||||
testDescr("img2", "");
|
||||
|
||||
// Description from @title attribute, name is generated from @alt
|
||||
// attribute.
|
||||
testDescr("img3", "description");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(doTest);
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=489944"
|
||||
title="@title attribute no longer exposed on accDescription">
|
||||
Mozilla Bug 489944
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<p id="description">aria description</p>
|
||||
<img id="img1" aria-describedby="description" />
|
||||
<img id="img2" title="title" />
|
||||
<img id="img3" alt="name" title="description" />
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user