Bug 1316965: Give file inputs an a11y role of GROUPING so screen readers report their label when focus enters them. r=MarcoZ a=lizzard
Differential Revision:
https://phabricator.services.mozilla.com/D46375
--- a/accessible/html/HTMLFormControlAccessible.cpp
+++ b/accessible/html/HTMLFormControlAccessible.cpp
@@ -405,19 +405,19 @@ Accessible* HTMLTextFieldAccessible::Con
HTMLFileInputAccessible::HTMLFileInputAccessible(nsIContent* aContent,
DocAccessible* aDoc)
: HyperTextAccessibleWrap(aContent, aDoc) {
mType = eHTMLFileInputType;
}
role HTMLFileInputAccessible::NativeRole() const {
- // JAWS wants a text container, others don't mind. No specific role in
- // AT APIs.
- return roles::TEXT_CONTAINER;
+ // No specific role in AT APIs. We use GROUPING so that the label will be
+ // reported by screen readers when focus enters this control .
+ return roles::GROUPING;
}
nsresult HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent) {
nsresult rv = HyperTextAccessibleWrap::HandleAccEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
// Redirect state change events for inherited states to child controls. Note,
// unavailable state is not redirected. That's a standard for unavailable
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -696,17 +696,17 @@
actions: "uncheck",
};
testElm("input_checkbox_true", obj);
// ////////////////////////////////////////////////////////////////////////
// HTML:input@type="file"
obj = {
- TEXT_CONTAINER: [
+ GROUPING: [
{ role: ROLE_PUSHBUTTON },
{ role: ROLE_LABEL },
],
};
testElm("input_file", obj);
// ////////////////////////////////////////////////////////////////////////
// HTML:input@type="image"
--- a/accessible/tests/mochitest/role/test_general.html
+++ b/accessible/tests/mochitest/role/test_general.html
@@ -45,20 +45,18 @@
// Test html:h, all levels
testRole("head1", ROLE_HEADING);
testRole("head2", ROLE_HEADING);
testRole("head3", ROLE_HEADING);
testRole("head4", ROLE_HEADING);
testRole("head5", ROLE_HEADING);
testRole("head6", ROLE_HEADING);
- // Test that an html:input @type="file" is exposed as ROLE_TEXT_CONTAINER.
- // After fix for bug 471356, it was temporarily exposed as a paragraph,
- // breaking JAWS compatibility.
- testRole("data", ROLE_TEXT_CONTAINER);
+ // Test that an html:input @type="file" is exposed as ROLE_GROUPING.
+ testRole("data", ROLE_GROUPING);
// Test that input type="checkbox" and type="radio" are
// exposed as such regardless of appearance style.
testRole("checkbox_regular", ROLE_CHECKBUTTON);
testRole("checkbox_appearance_none", ROLE_CHECKBUTTON);
testRole("radio_regular", ROLE_RADIOBUTTON);
testRole("radio_appearance_none", ROLE_RADIOBUTTON);
--- a/accessible/tests/mochitest/tree/test_filectrl.html
+++ b/accessible/tests/mochitest/tree/test_filectrl.html
@@ -12,17 +12,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript">
function doTest() {
var accTree = {
- role: ROLE_TEXT_CONTAINER,
+ role: ROLE_GROUPING,
children: [
{
role: ROLE_PUSHBUTTON,
},
{
role: ROLE_LABEL,
children: [
{