Bug 758675 - Speak accessible description if available, r=eeejay, f=yzen
authorMarco Zehe <mzehe@mozilla.com>
Tue, 23 Jul 2013 10:40:49 +0200
changeset 151838 bf53001aa2c795cd6bf525f2bbbb6eb82df6af36
parent 151837 9fc53053c489f95d18aac1e418844bafbce8a9a6
child 151839 1ede6adb61d65f8210dbefb0e6247b702c9e70a9
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseeejay
bugs758675
milestone25.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 758675 - Speak accessible description if available, r=eeejay, f=yzen
accessible/src/jsat/OutputGenerator.jsm
accessible/tests/mochitest/jsat/test_utterance_order.html
--- a/accessible/src/jsat/OutputGenerator.jsm
+++ b/accessible/src/jsat/OutputGenerator.jsm
@@ -159,16 +159,29 @@ this.OutputGenerator = {
 
   _addName: function _addName(aOutput, aAccessible, aFlags) {
     let name;
     if (Utils.getAttributes(aAccessible)['explicit-name'] === 'true' ||
       (aFlags & INCLUDE_NAME)) {
       name = aAccessible.name;
     }
 
+    let description = aAccessible.description;
+    if (description) {
+      // Compare against the calculated name unconditionally, regardless of name rule,
+      // so we can make sure we don't speak duplicated descriptions
+      let tmpName = name || aAccessible.name;
+      if (tmpName && (description !== tmpName)) {
+        name = name || '';
+        name = this.outputOrder === OUTPUT_DESC_FIRST ?
+          description + ' - ' + name :
+          name + ' - ' + description;
+      }
+    }
+
     if (name) {
       aOutput[this.outputOrder === OUTPUT_DESC_FIRST ?
         'push' : 'unshift'](name);
     }
   },
 
   /**
    * Adds a landmark role to the output if available.
--- a/accessible/tests/mochitest/jsat/test_utterance_order.html
+++ b/accessible/tests/mochitest/jsat/test_utterance_order.html
@@ -19,16 +19,33 @@ https://bugzilla.mozilla.org/show_bug.cg
       function doTest() {
         // Test the following accOrElmOrID (with optional old accOrElmOrID).
         // Note: each accOrElmOrID entry maps to a unique object utterance
         // generator function within the UtteranceGenerator.
         var tests = [{
           accOrElmOrID: "anchor",
           expected: [["link", "title"], ["title", "link"]]
         }, {
+          accOrElmOrID: "anchor_titleandtext",
+          expected: [[
+            "link", "goes to the tests -", "Tests"
+          ], [
+            "Tests", "- goes to the tests", "link"
+          ]]
+        }, {
+          accOrElmOrID: "anchor_duplicatedtitleandtext",
+          expected: [["link", "Tests"], ["Tests", "link"]]
+        }, {
+          accOrElmOrID: "anchor_arialabelandtext",
+          expected: [[
+            "link", "goes to the tests - Tests"
+          ], [
+            "Tests - goes to the tests", "link"
+          ]]
+        }, {
           accOrElmOrID: "textarea",
           expected: [[
             "text area", "This is the text area text."
           ], [
             "This is the text area text.", "text area"
           ]]
         }, {
           accOrElmOrID: "heading",
@@ -137,20 +154,27 @@ https://bugzilla.mozilla.org/show_bug.cg
     </script>
   </head>
   <body>
     <div id="root">
       <a target="_blank"
          href="https://bugzilla.mozilla.org/show_bug.cgi?id=753984"
          title="[AccessFu] utterance order test">
          Mozilla Bug 753984</a>
+      <a target="_blank"
+         href="https://bugzilla.mozilla.org/show_bug.cgi?id=758675"
+         title="[AccessFu] Add support for accDescription">
+         Mozilla Bug 758675</a>
       <p id="display"></p>
       <div id="content" style="display: none"></div>
       <pre id="test"></pre>
       <a id="anchor" href="#test" title="title"></a>
+      <a id="anchor_titleandtext" href="#test" title="goes to the tests">Tests</a>
+      <a id="anchor_duplicatedtitleandtext" href="#test" title="Tests">Tests</a>
+      <a id="anchor_arialabelandtext" href="#test" aria-label="Tests" title="goes to the tests">Tests</a>
       <textarea id="textarea" cols="80" rows="5">
         This is the text area text.
       </textarea>
       <h1 id="heading" title="Test heading"></h1>
       <ol id="list">
         <li id="li_one">list one</li>
       </ol>
       <dl id="dlist">