mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
bug 666504 - Ignore role presentation on focusable elements r=davidb, marcoz
This commit is contained in:
parent
91c70daef1
commit
86a69af379
@ -1009,12 +1009,13 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
|
||||
}
|
||||
|
||||
nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(aNode);
|
||||
if (roleMapEntry && !nsCRT::strcmp(roleMapEntry->roleString, "presentation") &&
|
||||
!content->IsFocusable()) { // For presentation only
|
||||
// Only create accessible for role of "presentation" if it is focusable --
|
||||
// in that case we need an accessible in case it gets focused, we
|
||||
// don't want focus ever to be 'lost'
|
||||
return nsnull;
|
||||
if (roleMapEntry && !nsCRT::strcmp(roleMapEntry->roleString, "presentation")) {
|
||||
// Ignore presentation role if element is focusable (focus event shouldn't
|
||||
// be ever lost and should be sensible).
|
||||
if (content->IsFocusable())
|
||||
roleMapEntry = nsnull;
|
||||
else
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
if (weakFrame.IsAlive() && !newAcc && isHTML) { // HTML accessibles
|
||||
|
@ -103,7 +103,7 @@
|
||||
<button id="btn_namefromcontent" title="title">1</button>
|
||||
|
||||
<!-- button, no name from content, ARIA role overrides this rule -->
|
||||
<button id="btn_nonamefromcontent" role="presentation">1</button>
|
||||
<button id="btn_nonamefromcontent" role="img">1</button>
|
||||
|
||||
<!-- button, no content, name from @title -->
|
||||
<button id="btn_title" title="title"></button>
|
||||
|
@ -88,8 +88,7 @@
|
||||
title="title"><img alt="img title" /></a>
|
||||
|
||||
<!-- no name from content, ARIA role overrides this rule -->
|
||||
<a id="nonamefromcontent" href="mozilla.org"
|
||||
role="presentation">1</a>
|
||||
<a id="nonamefromcontent" href="mozilla.org" role="img">1</a>
|
||||
<br/>
|
||||
|
||||
<!-- no content, name from @title -->
|
||||
|
@ -57,6 +57,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=529289
|
||||
is(accessibleTable.getCellAt(0,0).firstChild.name, "hi", "no cell");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// test gEmptyRoleMap
|
||||
testRole("cell", ROLE_NOTHING);
|
||||
|
||||
@ -67,10 +68,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=529289
|
||||
for (a in abstract_roles)
|
||||
testRole(abstract_roles[a], ROLE_SECTION);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// misc roles
|
||||
testRole("scrollbar", ROLE_SCROLLBAR);
|
||||
testRole("dir", ROLE_LIST);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// test document role map update
|
||||
var testDoc = getAccessible(document, [nsIAccessibleDocument]);
|
||||
testRole(testDoc, ROLE_DOCUMENT);
|
||||
|
@ -50,6 +50,7 @@ _TEST_FILES =\
|
||||
$(warning test_applicationacc.xul temporarily disabled, see bug 561508) \
|
||||
test_aria_globals.html \
|
||||
test_aria_imgmap.html \
|
||||
test_aria_presentation.html \
|
||||
test_button.xul \
|
||||
test_combobox.xul \
|
||||
test_cssoverflow.html \
|
||||
|
104
accessible/tests/mochitest/tree/test_aria_presentation.html
Normal file
104
accessible/tests/mochitest/tree/test_aria_presentation.html
Normal file
@ -0,0 +1,104 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test accessible tree when ARIA role presentation is used</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/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
||||
<script type="application/javascript"
|
||||
src="../common.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="../role.js"></script>
|
||||
|
||||
<script type="application/javascript">
|
||||
function doTest()
|
||||
{
|
||||
// Presentation role don't allow accessible.
|
||||
var tree =
|
||||
{ SECTION: [ // container
|
||||
{ TEXT_LEAF: [ ] } // child text of presentation node
|
||||
] };
|
||||
testAccessibleTree("div_cnt", tree);
|
||||
|
||||
// Focusable element, presentation role is ignored.
|
||||
tree =
|
||||
{ SECTION: [ // container
|
||||
{ PUSHBUTTON: [ // button
|
||||
{ TEXT_LEAF: [ ] }
|
||||
] }
|
||||
] };
|
||||
testAccessibleTree("btn_cnt", tree);
|
||||
|
||||
// Presentation table, no table structure is exposed.
|
||||
tree =
|
||||
{ SECTION: [ // container
|
||||
{ TEXT_LEAF: [ ] } // cell text
|
||||
] };
|
||||
testAccessibleTree("tbl_cnt", tree);
|
||||
|
||||
// Focusable table, presentation role is ignored.
|
||||
tree =
|
||||
{ SECTION: [ // container
|
||||
{ TABLE: [ // table
|
||||
{ ROW: [ // tr
|
||||
{ CELL: [ //td
|
||||
{ TEXT_LEAF: [ ] }
|
||||
] }
|
||||
] }
|
||||
] }
|
||||
] };
|
||||
testAccessibleTree("tblfocusable_cnt", tree);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addA11yLoadEvent(doTest);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=548291"
|
||||
title="Accessible tree of ARIA image maps">
|
||||
Mozilla Bug 548291
|
||||
</a>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=666504"
|
||||
title="Ignore role presentation on focusable elements">
|
||||
Mozilla Bug 666504
|
||||
</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
||||
<div id="div_cnt"><div role="presentation">text</div></div>
|
||||
|
||||
<div id="btn_cnt"><button role="presentation">btn</button></div>
|
||||
|
||||
<div id="tbl_cnt">
|
||||
<table role="presentation">
|
||||
<tr>
|
||||
<td>cell</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="tblfocusable_cnt">
|
||||
<table role="presentation" tabindex="0">
|
||||
<tr>
|
||||
<td>cell</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user