Bug 1316965: Give file inputs an a11y role of GROUPING so screen readers report their label when focus enters them. r=MarcoZ a=lizzard
authorJames Teh <jteh@mozilla.com>
Thu, 19 Sep 2019 04:39:21 +0000
changeset 552132 256e2d1a8ed57f4c08ce5b2d6a8942171d3fdd96
parent 552131 60460b7ebca0579b204b466256e347db4a73618d
child 552133 97f7c310e2473491261387e9cf16503ecab98bcf
push id12065
push userdvarga@mozilla.com
push dateSat, 28 Sep 2019 00:01:11 +0000
treeherdermozilla-beta@6601e4d9a980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMarcoZ, lizzard
bugs1316965
milestone70.0
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
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
@@ -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: [
               {