accessible/tests/mochitest/jsat/test_explicit_names.html
author Yura Zenevich <yzenevich@mozilla.com>
Wed, 06 Aug 2014 09:38:50 -0400
changeset 198190 d6059e806022b7b93748c32ba8fbb1e4911b6bfa
parent 170262 ff04d02b5c49cf9dbad60382017a59a29ccb24ae
child 291527 a6ec31248db660951879aa94b5721e09ba954c5f
permissions -rw-r--r--
Bug 1030470 - (part 1) moved the non-android localization part out of AccessFu to be handled in Gaia. r=eeejay --- accessible/jsat/AccessFu.jsm | 176 ++----- accessible/jsat/OutputGenerator.jsm | 337 +++++-------- accessible/jsat/Presentation.jsm | 193 ++++---- accessible/jsat/Utils.jsm | 43 +- accessible/tests/mochitest/jsat/jsatcommon.js | 19 +- accessible/tests/mochitest/jsat/output.js | 12 +- accessible/tests/mochitest/jsat/test_alive.html | 22 +- .../mochitest/jsat/test_content_integration.html | 95 ++-- .../tests/mochitest/jsat/test_content_text.html | 8 +- .../tests/mochitest/jsat/test_explicit_names.html | 73 +-- .../tests/mochitest/jsat/test_landmarks.html | 125 +++-- .../tests/mochitest/jsat/test_live_regions.html | 144 +++--- accessible/tests/mochitest/jsat/test_output.html | 526 +++++++++++---------- accessible/tests/mochitest/jsat/test_tables.html | 492 ++++++++++++++----- .../en-US/chrome/accessibility/AccessFu.properties | 103 +++- 15 files changed, 1306 insertions(+), 1062 deletions(-)

<html>
<head>
  <title>[AccessFu] Trust explicitly associated names when speaking certain elements</title>

  <link rel="stylesheet" type="text/css"
        href="chrome://mochikit/content/tests/SimpleTest/test.css" />
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="output.js"></script>
  <script type="application/javascript">

    function doTest() {
      // Test the following accOrElmOrID.
      var tests = [{
        accOrElmOrID: "anchor1",
        expected: [{"string": "link"}, "title"]
      }, {
        accOrElmOrID: "anchor2",
        expected: [{"string": "link"}, "This is a link"]
      }, {
        accOrElmOrID: "button1",
        expected: [{"string": "pushbutton"}, "Press me"]
      }, {
        accOrElmOrID: "button2",
        expected: [{"string": "pushbutton"}, "Press me"]
      }, {
        accOrElmOrID: "textarea1",
        expected: [{"string": "textarea"}, "This is the text area text.",
          "Test Text Area"]
      }, {
        accOrElmOrID: "textarea2",
        expected: [{"string": "textarea"}, "This is the text area text."]
      }, {
        accOrElmOrID: "heading1",
        expected: [{"string": "headingLevel", "args": [1]}, "Test heading",
          "This is the heading."]
      }, {
        accOrElmOrID: "heading1",
        oldAccOrElmOrID: null,
        expected: [null /* parent doc title */, document.title,
          {"string": "headingLevel", "args": [1]}, "Test heading",
          "This is the heading."]
      }, {
        accOrElmOrID: "heading2",
        expected: [{"string": "headingLevel", "args": [1]},
          "This is the heading."]
      }, {
        accOrElmOrID: "list",
        expected: [{"string": "list"}, {"string": "listItemsCount", "count": 2},
          "Test List", {"string": "listStart"}, "Top of the list",
          {"string": "listEnd"}, "2.", "list two"]
      }, {
        accOrElmOrID: "dlist",
        expected: [{"string": "definitionlist"},
          {"string": "listItemsCount", "count": 0.5}, "Test Definition List",
          "dd one"]
      }, {
        accOrElmOrID: "li_one",
        expected: [{"string": "list"}, {"string": "listItemsCount", "count": 2},
          "Test List", {"string": "listStart"}, "Top of the list"]
      }, {
        accOrElmOrID: "li_two",
        expected: [{"string": "list"}, {"string": "listItemsCount", "count": 2},
          "Test List", {"string": "listEnd"}, "2.", "list two"]
      }, {
        accOrElmOrID: "cell",
        expected: [{"string": "table"},
          {"string": "tblColumnInfo", "count": 1},
          {"string": "tblRowInfo", "count": 1}, "Fruits and vegetables",
          {"string": "columnInfo", "args": [1]},
          {"string": "rowInfo", "args": [1]}, "List of Fruits",
          {"string": "list"}, {"string": "listItemsCount", "count": 4},
          {"string": "listStart"}, {"string": "link"}, "Apples",
          {"string": "link"}, "Bananas",
          {"string": "link"}, "Peaches", {"string": "listEnd"},
          {"string": "link"}, "Plums"]
      }, {
        accOrElmOrID: "app.net",
        expected: [{"string": "list"}, {"string": "listItemsCount", "count": 2},
          {"string": "listStart"}, {"string": "link"}, "star",
          {"string": "listEnd"}, {"string": "link"}, "repost"]
      }, {
        // Test pivot to list from li_one.
        accOrElmOrID: "list",
        oldAccOrElmOrID: "li_one",
        expected: [{"string": "list"}, {"string": "listItemsCount", "count": 2},
          "Test List", {"string": "listStart"}, "Top of the list",
          {"string": "listEnd"}, "2.", "list two"]
      }, {
        // Test pivot to li_one from list.
        accOrElmOrID: "li_one",
        oldAccOrElmOrID: "list",
        expected: [{"string": "listStart"}, "Top of the list"]
      }, {
        // Test pivot to "apples" link from the table cell.
        accOrElmOrID: "apples",
        oldAccOrElmOrID: "cell",
        expected: [{"string": "list"}, {"string": "listItemsCount", "count": 4},
          {"string": "listStart"}, {"string": "link"}, "Apples"]
      }, {
        // Test pivot to the table cell from the "apples" link.
        accOrElmOrID: "cell",
        oldAccOrElmOrID: "apples",
        expected: ["List of Fruits", {"string": "list"},
          {"string": "listItemsCount", "count": 4}, {"string": "listStart"},
          {"string": "link"}, "Apples", {"string": "link"}, "Bananas",
          {"string": "link"}, "Peaches", {"string": "listEnd"},
          {"string": "link"}, "Plums"]
      }];

      SpecialPowers.setIntPref(PREF_UTTERANCE_ORDER, 0);

      // Test various explicit names vs the utterance generated from subtrees.
      tests.forEach(function run(test) {
        testOutput(test.expected, test.accOrElmOrID, test.oldAccOrElmOrID, 1);
      });

      SpecialPowers.clearUserPref(PREF_UTTERANCE_ORDER);
      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>
<body>
  <div id="root">
    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=845870"
       title="[AccessFu] Trust explicitly associated names when speaking certain elements">
       Mozilla Bug 845870
       </a>
    <p id="display"></p>
    <div id="content" style="display: none"></div>
    <pre id="test"></pre>
    <button id="button1" aria-label="Press me">This is not a name</button>
    <button id="button2">
      Press me
    </button>
    <a id="anchor1" href="#test" title="title"></a>
    <a id="anchor2" href="#test">This is a link</a>
    <textarea id="textarea1" title="Test Text Area" cols="80" rows="5">This is the text area text.</textarea>
    <textarea id="textarea2" cols="80" rows="5">
      This is the text area text.
    </textarea>
    <h1 id="heading1" title="Test heading">This is the heading.</h1>
    <h1 id="heading2">
      This is the heading.
    </h1>
    <ol id="list" title="Test List">
      <li id="li_one" aria-label="Top of the list">list one</li>
      <li id="li_two">list two</li>
    </ol>
    <dl id="dlist" title="Test Definition List">
      <dd id="dd_one">dd one</dd>
    </dl>
    <table>
      <caption>Fruits and vegetables</caption>
      <tr>
        <td id="cell" aria-label="List of Fruits">
          <ul style="list-style-type: none;">
            <li><a id="apples" href="#">Apples</a></li>
            <li><a id="bananas" href="#">Bananas</a></li>
            <li><a href="#">Peaches</a></li>
            <li>
              <a href="#">

                Plums
              </a>
            </li>
          </ul>
        </td>
      </tr>
    </table>
    <!-- app.net -->
    <ul id="app.net" class="unstyled ul-horizontal yui3-u fixed-right ta-right" style="list-style-type: none;">
      <li class="yui3-u">
        <a href="#star" data-starred="0" data-star-button="1" data-post-id="5098826" aria-label="star">
          Garbage
        </a>
      </li>
      <li class="yui3-u repost">
        <a href="#repost" title="repost" data-repost-button="1" data-reposted="0" data-post-id="5098826">
          <i aria-label="repost" class="icon-repost"></i>
        </a>
      </li>
    </ul>
  </div>
</body>
</html>