accessible/tests/mochitest/jsat/test_live_regions.html
author Yura Zenevich <yzenevich@mozilla.com>
Wed, 06 Aug 2014 09:38:50 -0400
changeset 198190 d6059e806022b7b93748c32ba8fbb1e4911b6bfa
parent 171821 445ad0b80d92cde08f54a24ed290a815e913bb29
child 202207 d20f8a8d74992021f36d041ce5b00aff6f7e8586
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 tests for live regions support</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="./jsatcommon.js"></script>
  <script type="application/javascript">

    function startAccessFu() {
      SpecialPowers.setIntPref("accessibility.accessfu.activate", 1);
      AccessFuTest.once_log("EventManager.start", AccessFuTest.nextTest);
    }

    function stopAccessFu() {
      SpecialPowers.setIntPref("accessibility.accessfu.activate", 0);
      AccessFuTest.once_log("EventManager.stop", AccessFuTest.finish);
    }

    function hide(id) {
      var element = document.getElementById(id);
      element.style.display = "none";
    }

    function show(id) {
      var element = document.getElementById(id);
      element.style.display = "block";
    }

    function udpate(id, text, property) {
      var element = document.getElementById(id);
      element[property] = text;
    }

    function updateText(id, text) {
      udpate(id, text, "textContent");
    }

    function updateHTML(id, text) {
      udpate(id, text, "innerHTML");
    }

    var tests = [{
      expected: {
        "eventType": "liveregion-change",
        "data": [{"string": "hidden"}, "I will be hidden"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        [hide(id) for (id of ["to_hide1", "to_hide2", "to_hide3", "to_hide4"])];
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": [{"string": "hidden"},"I will be hidden"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        [hide(id) for (id of ["to_hide_descendant1", "to_hide_descendant2",
          "to_hide_descendant3", "to_hide_descendant4"])];
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["I will be shown"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        [show(id) for (id of ["to_show1", "to_show2", "to_show3", "to_show4"])];
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["I will be shown"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        [show(id) for (id of ["to_show_descendant1", "to_show_descendant2",
          "to_show_descendant3", "to_show_descendant4"])];
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": [{"string": "hidden"}, "I will be hidden"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        hide("to_hide_live_assertive");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["I will be shown"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        [show(id) for (id of ["to_show_live_off", "to_show_live_assertive"])];
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["Text Added"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateText("text_add", "Text Added");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["Text Added"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateHTML("text_add", "Text Added");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": [{"string": "hidden"}, "Text Removed"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        updateText("text_remove", "");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["Descendant Text Added"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateText("text_add_descendant", "Descendant Text Added");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["Descendant Text Added"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateHTML("text_add_descendant", "Descendant Text Added");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": [{"string": "hidden"}, "Descendant Text Removed"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        updateText("text_remove_descendant", "");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["Descendant Text Added"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateText("text_add_descendant2", "Descendant Text Added");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["Descendant Text Added"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateHTML("text_add_descendant2", "Descendant Text Added");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": [{"string": "hidden"}, "Descendant Text Removed"],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        updateText("text_remove_descendant2", "");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["I am replaced", {"string": "main"}],
        "options": {
          "enqueue": true
        }
      },
      action: function action() {
        var region = document.getElementById("to_replace_region");
        var child = document.getElementById("to_replace");
        child.setAttribute("role", "main");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["I am a replaced text"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateText("to_replace_text", "I am a replaced text");
      }
    }, {
      expected: {
        "eventType": "liveregion-change",
        "data": ["I am a replaced text"],
        "options": {
          "enqueue": false
        }
      },
      action: function action() {
        updateHTML("to_replace_text", "I am a replaced text");
      }
    }];

    function doTest() {
      AccessFuTest.addFunc(startAccessFu);
      tests.forEach(function addTest(test) {
        AccessFuTest.addFunc(function () {
          AccessFuTest.once(test.expected, AccessFuTest.nextTest);
          test.action();
        });
      });
      AccessFuTest.addFunc(stopAccessFu);
      AccessFuTest.waitForExplicitFinish();
      AccessFuTest.runTests();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>

</head>
<body>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=795957"
     title="[AccessFu] Support live regions">
    Mozilla Bug 795957
  </a>
  <div id="root">
    <p id="display"></p>
    <div id="content" style="display: none"></div>
    <pre id="test"></pre>

    <p id="to_hide1">I should not be announced 1</p>
    <p id="to_hide2" aria-live="polite">I should not be announced 2</p>
    <p id="to_hide3" aria-live="assertive" aria-relevant="text">I should not be announced 3</p>
    <p id="to_hide4" aria-live="polite" aria-relevant="all">I will be hidden</p>

    <div>
      <p id="to_hide_descendant1">I should not be announced 1</p>
    </div>
    <div aria-live="polite">
      <p id="to_hide_descendant2">I should not be announced 2</p>
    </div>
    <div aria-live="assertive" aria-relevant="text">
      <p id="to_hide_descendant3">I should not be announced 3</p>
    </div>
    <div aria-live="polite" aria-relevant="all">
      <p id="to_hide_descendant4">I will be hidden</p>
    </div>

    <p id="to_show1" style="display: none">I should not be announced 1</p>
    <p id="to_show2" aria-live="assertive" aria-relevant="text" style="display: none">I should not be announced 2</p>
    <p id="to_show3" aria-live="polite" aria-relevant="removals" style="display: none">I should not be announced 3</p>
    <p id="to_show4" aria-live="polite" aria-relevant="all" style="display: none">I will be shown</p>

    <div>
      <p id="to_show_descendant1" style="display: none">I should not be announced 1</p>
    </div>
    <div aria-live="polite" aria-relevant="removals">
      <p id="to_show_descendant2" style="display: none">I should not be announced 2</p>
    </div>
    <div aria-live="assertive" aria-relevant="text">
      <p id="to_show_descendant3" style="display: none">I should not be announced 3</p>
    </div>
    <div aria-live="polite" aria-relevant="all">
      <p id="to_show_descendant4" style="display: none">I will be shown</p>
    </div>

    <div aria-live="assertive" aria-relevant="all">
      <p id="to_hide_live_assertive">I will be hidden</p>
    </div>
    <p id="to_show_live_assertive" aria-live="assertive" style="display: none">I will be shown</p>

    <p id="to_show_live_off" aria-live="off" style="display: none">I will not be shown</p>

    <div id="to_replace_region" aria-live="polite" aria-relevant="all">
      <p id="to_replace">I am replaced</p>
    </div>

    <p id="to_replace_text" aria-live="assertive" aria-relevant="text">I am going to be replaced</p>

    <p id="text_add" aria-live="assertive" aria-relevant="text"></p>
    <p id="text_remove" aria-live="polite" aria-relevant="all">Text Removed</p>

    <div aria-live="assertive" aria-relevant="all">
      <p id="text_add_descendant"></p>
    </div>
    <div aria-live="polite" aria-relevant="text">
      <p id="text_remove_descendant">Descendant Text Removed</p>
    </div>
    <div aria-live="assertive" aria-relevant="text">
      <p id="text_add_descendant2"></p>
    </div>
    <div aria-live="polite" aria-relevant="all">
      <p id="text_remove_descendant2">Descendant Text Removed</p>
    </div>
  </div>
</body>
</html>