Bug 1316965: Give file inputs an a11y role of GROUPING so screen readers report their label when focus enters them. r=MarcoZ
authorJames Teh <jteh@mozilla.com>
Thu, 19 Sep 2019 04:39:21 +0000
changeset 494051 606bb262818f1e14d24480ed48b13876d36e0680
parent 494050 768b6818e6662500aa3d77b32f4549c393abb691
child 494052 089574291109a1f580930e4a00ef8189eb998b78
push id36593
push useropoprus@mozilla.com
push dateThu, 19 Sep 2019 09:46:54 +0000
treeherdermozilla-central@6b93a83735ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMarcoZ
bugs1316965
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1316965: Give file inputs an a11y role of GROUPING so screen readers report their label when focus enters them. r=MarcoZ Differential Revision: https://phabricator.services.mozilla.com/D46375
accessible/html/HTMLFormControlAccessible.cpp
accessible/tests/mochitest/elm/test_HTMLSpec.html
accessible/tests/mochitest/role/test_general.html
accessible/tests/mochitest/tree/test_filectrl.html
--- 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
@@ -699,17 +699,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: [
               {