Bug 924896 - [AccessFu] Exposing the type attribute for entries such as search, url, tel, etc. r=eeejay
authorYura Zenevich <yura.zenevich@gmail.com>
Thu, 24 Oct 2013 23:21:29 -0400
changeset 165870 53746157d20f6fbd9d88edc77e858b9294d5feac
parent 165869 87a32e0b05ba73fe8a9826e420a03887108ac53d
child 165871 253b0a696a1d843e736ad6cd19bfe8d7f54ba027
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs924896
milestone27.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 924896 - [AccessFu] Exposing the type attribute for entries such as search, url, tel, etc. r=eeejay --- accessible/src/jsat/OutputGenerator.jsm | 22 +++++++++++++++++- .../tests/mochitest/jsat/test_utterance_order.html | 27 ++++++++++++++++++++++ .../en-US/chrome/accessibility/AccessFu.properties | 6 +++++ 3 files changed, 54 insertions(+), 1 deletion(-)
accessible/src/jsat/OutputGenerator.jsm
accessible/tests/mochitest/jsat/test_utterance_order.html
dom/locales/en-US/chrome/accessibility/AccessFu.properties
--- a/accessible/src/jsat/OutputGenerator.jsm
+++ b/accessible/src/jsat/OutputGenerator.jsm
@@ -199,16 +199,34 @@ this.OutputGenerator = {
     if (!landmark) {
       return;
     }
 
     aOutput[this.outputOrder === OUTPUT_DESC_FIRST ? 'unshift' : 'push'](
       landmark);
   },
 
+  /**
+   * Adds an entry type attribute to the description if available.
+   * @param {Array} aDesc Description array.
+   * @param {nsIAccessible} aAccessible current accessible object.
+   * @param {String} aRoleStr aAccessible's role string.
+   */
+  _addType: function _addType(aDesc, aAccessible, aRoleStr) {
+    if (aRoleStr !== 'entry') {
+      return;
+    }
+
+    let typeName = Utils.getAttributes(aAccessible)['text-input-type'];
+    if (!typeName) {
+      return;
+    }
+    aDesc.push(gStringBundle.GetStringFromName('textInputType_' + typeName));
+  },
+
   get outputOrder() {
     if (!this._utteranceOrder) {
       this._utteranceOrder = new PrefCache('accessibility.accessfu.utterance');
     }
     return typeof this._utteranceOrder.value === 'number' ?
       this._utteranceOrder.value : this.defaultOutputOrder;
   },
 
@@ -301,18 +319,20 @@ this.OutputGenerator = {
 
   objectOutputFunctions: {
     _generateBaseOutput: function _generateBaseOutput(aAccessible, aRoleStr, aStates, aFlags) {
       let output = [];
 
       if (aFlags & INCLUDE_DESC) {
         let desc = this._getLocalizedStates(aStates);
         let roleStr = this._getLocalizedRole(aRoleStr);
-        if (roleStr)
+        if (roleStr) {
+          this._addType(desc, aAccessible, aRoleStr);
           desc.push(roleStr);
+        }
         output.push(desc.join(' '));
       }
 
       if (aFlags & INCLUDE_VALUE) {
         let value = aAccessible.value;
         if (value) {
           output[this.outputOrder === OUTPUT_DESC_FIRST ?
                  'push' : 'unshift'](value);
--- a/accessible/tests/mochitest/jsat/test_utterance_order.html
+++ b/accessible/tests/mochitest/jsat/test_utterance_order.html
@@ -79,16 +79,39 @@ https://bugzilla.mozilla.org/show_bug.cg
             "link", "Bananas", "link", "Peaches", "Last item", "link", "Plums"
           ], [
             "Apples", "link", "First item", "Bananas", "link", "Peaches",
             "link", "Plums", "link", "Last item", "list 4 items",
             "Column 1 Row 1", "Fruits and vegetables",
             "table with 1 column and 1 row"
           ]]
         }, {
+          accOrElmOrID: "email",
+          expected: [
+            ["e-mail entry", "test@example.com"],
+            ["test@example.com", "e-mail entry"]
+          ]
+        }, {
+          accOrElmOrID: "search",
+          expected: [
+            ["search entry", "This is a search"],
+            ["This is a search", "search entry"]
+          ]
+        }, {
+          accOrElmOrID: "tel",
+          expected: [
+            ["telephone entry", "555-5555"], ["555-5555", "telephone entry"]
+          ]
+        }, {
+          accOrElmOrID: "url",
+          expected: [
+            ["URL entry", "http://example.com"],
+            ["http://example.com", "URL entry"]
+          ]
+        }, {
           // Test pivot to list from li_one.
           accOrElmOrID: "list",
           oldAccOrElmOrID: "li_one",
           expected: [
             ["list 1 item", "First item", "1.", "list one"],
             ["1.", "list one", "First item", "list 1 item"]
           ]
         }, {
@@ -271,11 +294,15 @@ https://bugzilla.mozilla.org/show_bug.cg
       <form id="form1">
         <label id="label1"><input id="input1" type="checkbox">Orange</label>
         <input id="input2" type="checkbox"><label id="label2" for="input2">Blue</label>
       </form>
       <label id="label3">First name: <input id="input3" value="Joe"></label>
       <label id="label4">Points:
         <input id="input4" type="range" name="points" min="1" max="10" value="3">
       </label>
+      <input id="email" type="email" value="test@example.com" />
+      <input id="search" type="search" value="This is a search" />
+      <input id="tel" type="tel" value="555-5555" />
+      <input id="url" type="url" value="http://example.com" />
     </div>
   </body>
 </html>
--- a/dom/locales/en-US/chrome/accessibility/AccessFu.properties
+++ b/dom/locales/en-US/chrome/accessibility/AccessFu.properties
@@ -67,16 +67,22 @@ note           =       note
 figure         =       figure
 definitionlist =       definition list
 term           =       term
 definition     =       definition
 
 # More sophisticated roles which are not actual numeric roles
 textarea       =       text area
 
+# Text input types
+textInputType_email  =       e-mail
+textInputType_search =       search
+textInputType_tel    =       telephone
+textInputType_url    =       URL
+
 # More sophisticated object descriptions
 headingLevel   =       heading level %S
 
 # more sophisticated list announcement
 listStart      =       First item
 listEnd        =       Last item
 # LOCALIZATION NOTE (listItemsCount): Semi-colon list of plural forms.
 # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals