bug 472326 - html:input of type file no longer rendered to screen readers, effective December 30, 2008, r=aaronlev, r=surkov
authorMarco Zehe <marco.zehe@googlemail.com>
Thu, 15 Jan 2009 15:45:43 +0100
changeset 23749 a4ad1c1d61ddb1331de23016b14c75d5da67fa82
parent 23748 96da79f2122a865690784c7493fbfb5df378f75f
child 23750 6eb627215b618ad6faf2f738305ada9f3430c6f0
push id4700
push usermzehe@mozilla.com
push dateThu, 15 Jan 2009 14:47:22 +0000
treeherdermozilla-central@a4ad1c1d61dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaaronlev, surkov
bugs472326
milestone1.9.2a1pre
bug 472326 - html:input of type file no longer rendered to screen readers, effective December 30, 2008, r=aaronlev, r=surkov
accessible/src/html/nsHyperTextAccessible.cpp
accessible/tests/mochitest/Makefile.in
accessible/tests/mochitest/common.js
accessible/tests/mochitest/test_nsHyperTextAcc_roles.html
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -154,17 +154,20 @@ NS_IMETHODIMP nsHyperTextAccessible::Get
            tag == nsAccessibilityAtoms::h3 ||
            tag == nsAccessibilityAtoms::h4 ||
            tag == nsAccessibilityAtoms::h5 ||
            tag == nsAccessibilityAtoms::h6) {
     *aRole = nsIAccessibleRole::ROLE_HEADING;
   }
   else {
     nsIFrame *frame = GetFrame();
-    if (frame && frame->GetType() == nsAccessibilityAtoms::blockFrame) {
+    if (frame && frame->GetType() == nsAccessibilityAtoms::blockFrame &&
+        frame->GetContent()->Tag() != nsAccessibilityAtoms::input) {
+      // An html:input @type="file" is the only input that is exposed as a
+      // blockframe. It must be exposed as ROLE_TEXT_CONTAINER for JAWS.
       *aRole = nsIAccessibleRole::ROLE_PARAGRAPH;
     }
     else {
       *aRole = nsIAccessibleRole::ROLE_TEXT_CONTAINER; // In ATK this works
     }
   }
   return NS_OK;
 }
--- a/accessible/tests/mochitest/Makefile.in
+++ b/accessible/tests/mochitest/Makefile.in
@@ -64,16 +64,17 @@ include $(topsrcdir)/config/rules.mk
 		$(warning test_bug368835.xul temporarily disabled) \
 		test_bug420863.html \
 		test_cssattrs.html \
 		test_events_caretmove.html \
 		test_events_mutation.html \
 		test_groupattrs.xul \
 		test_groupattrs.html \
 	$(warning test_table_indexes.html temporarily disabled) \
+		test_nsHyperTextAcc_roles.html \
 		test_nsIAccessible_actions.html \
 		$(warning test_nsIAccessible_actions.xul temporarily disabled) \
 		test_nsIAccessible_applicationAccessible.html \
 		test_nsIAccessible_comboboxes.xul \
 		test_nsIAccessible_editablebody.html \
 		test_nsIAccessible_editabledoc.html \
 		test_nsIAccessible_name.html \
 		test_nsIAccessible_name_button.html \
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -44,17 +44,19 @@ const ROLE_COMBOBOX = nsIAccessibleRole.
 const ROLE_COMBOBOX_LIST = nsIAccessibleRole.ROLE_COMBOBOX_LIST;
 const ROLE_COMBOBOX_OPTION = nsIAccessibleRole.ROLE_COMBOBOX_OPTION;
 const ROLE_DOCUMENT = nsIAccessibleRole.ROLE_DOCUMENT;
 const ROLE_ENTRY = nsIAccessibleRole.ROLE_ENTRY;
 const ROLE_FLAT_EQUATION = nsIAccessibleRole.ROLE_FLAT_EQUATION;
 const ROLE_LABEL = nsIAccessibleRole.ROLE_LABEL;
 const ROLE_LIST = nsIAccessibleRole.ROLE_LIST;
 const ROLE_OPTION = nsIAccessibleRole.ROLE_OPTION;
+const ROLE_PARAGRAPH = nsIAccessibleRole.ROLE_PARAGRAPH;
 const ROLE_PASSWORD_TEXT = nsIAccessibleRole.ROLE_PASSWORD_TEXT;
+const ROLE_TEXT_CONTAINER = nsIAccessibleRole.ROLE_TEXT_CONTAINER;
 const ROLE_TEXT_LEAF = nsIAccessibleRole.ROLE_TEXT_LEAF;
 const ROLE_TOGGLE_BUTTON = nsIAccessibleRole.ROLE_TOGGLE_BUTTON;
 
 ////////////////////////////////////////////////////////////////////////////////
 // States
 
 const STATE_CHECKED = nsIAccessibleStates.STATE_CHECKED;
 const STATE_CHECKABLE = nsIAccessibleStates.STATE_CHECKABLE;
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/test_nsHyperTextAcc_roles.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=472326
+-->
+<head>
+  <title>test nsHyperTextAccessible roles</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 doTests()
+    {
+      // 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.
+      fileUploadAcc = getAccessible("data");
+      if (fileUploadAcc)
+        is(fileUploadAcc.role, ROLE_TEXT_CONTAINER,
+           "Wrong role for file upload textbox!");
+
+      // Test regular paragraph by comparison to make sure exposure does not
+      // get broken.
+      var paraAcc = getAccessible("p");
+      if (paraAcc)
+        is(paraAcc.role, ROLE_PARAGRAPH, "Wrong role for paragraph!");
+
+      SimpleTest.finish();
+    }
+
+    SimpleTest.waitForExplicitFinish();
+    addLoadEvent(doTests);
+  </script>
+</head>
+<body>
+
+  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472326"
+     title="html:input of type "file" no longer rendered to screen readers">
+     Mozilla Bug 472326
+  </a>
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+  <form action="submit.php" method="post">
+    <label for="data">File</label>:
+    <input type="file" id="data" name="data" size="50"/>
+  </form>
+  <p id="p">A paragraph for comparison.</p>
+</body>
+</html>