summaryrefslogtreecommitdiff
path: root/accessible/tests/mochitest/jsat/test_landmarks.html
blob: 8b1a16f83bda1abbe3611d9d47cd6672bf65d095 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<html>
<head>
  <title> [AccessFu] Speak landmarks</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"
          src="jsatcommon.js"></script>
  <script type="application/javascript">

    function doTest() {
      // Test the following accOrElmOrID.
      var tests = [{
        accOrElmOrID: "nav",
        expectedUtterance: [[{"string": "navigation"}, "a nav"],
                            ["a nav", {"string": "navigation"}]],
        expectedBraille: [[{"string": "navigation"}, "a nav"],
                          ["a nav", {"string": "navigation"}]]
      }, {
        accOrElmOrID: "main",
        expectedUtterance: [[{"string": "main"}, "a main area"],
                            ["a main area", {"string": "main"}]],
        expectedBraille: [[{"string": "main"}, "a main area"],
                          ["a main area", {"string": "main"}]]
      }, {
        accOrElmOrID: "header",
        expectedUtterance: [
          [{"string": "banner"}, {"string": "header"}, "a header"],
          ["a header", {"string": "header"}, {"string": "banner"}]],
        expectedBraille: [
          [{"string": "banner"}, {"string": "headerAbbr"}, "a header"],
          ["a header", {"string": "headerAbbr"}, {"string": "banner"}]]
      }, {
        accOrElmOrID: "footer",
        expectedUtterance: [
          [{"string": "contentinfo"}, {"string": "footer"}, "a footer"],
          ["a footer", {"string": "footer"}, {"string": "contentinfo"}]],
        expectedBraille: [
          [{"string": "contentinfo"}, {"string": "footerAbbr"}, "a footer"],
          ["a footer", {"string": "footerAbbr"}, {"string": "contentinfo"}]]
      }, {
        accOrElmOrID: "article_header",
        expectedUtterance: [
          [{"string": "header"}, "a header within an article"],
          ["a header within an article", {"string": "header"}]],
        expectedBraille: [
          [{"string": "headerAbbr"}, "a header within an article"],
          ["a header within an article", {"string": "headerAbbr"}]],
      }, {
        accOrElmOrID: "article_footer",
        expectedUtterance: [
          [{"string": "footer"}, "a footer within an article"],
          ["a footer within an article", {"string": "footer"}]],
        expectedBraille: [
          [{"string": "footerAbbr"}, "a footer within an article"],
          ["a footer within an article", {"string": "footerAbbr"}]]
      }, {
        accOrElmOrID: "section_header",
        expectedUtterance: [[{"string":"header"}, "a header within a section"],
                            ["a header within a section", {"string":"header"}]],
        expectedBraille: [
          [{"string":"headerAbbr"}, "a header within a section"],
          ["a header within a section", {"string":"headerAbbr"}]]
      }, {
        accOrElmOrID: "section_footer",
        expectedUtterance: [
          [{"string": "footer"}, "a footer within a section"],
          ["a footer within a section", {"string": "footer"}]],
        expectedBraille: [
          [{"string": "footerAbbr"}, "a footer within a section"],
          ["a footer within a section", {"string": "footerAbbr"}]]
      }, {
        accOrElmOrID: "aside",
        expectedUtterance: [
          [{"string": "complementary"}, "by the way I am an aside"],
          ["by the way I am an aside", {"string": "complementary"}]],
        expectedBraille: [
          [{"string": "complementary"}, "by the way I am an aside"],
          ["by the way I am an aside", {"string": "complementary"}]]
      }, {
        accOrElmOrID: "main_element",
        expectedUtterance: [[{"string": "main"}, "another main area"],
                            ["another main area", {"string": "main"}]],
        expectedBraille: [[{"string": "main"}, "another main area"],
                          ["another main area", {"string": "main"}]]
      }, {
        accOrElmOrID: "complementary",
        expectedUtterance: [[{"string": "list"},
          {"string": "listItemsCount", "count": 1}, {"string": "complementary"},
          {"string": "listStart"}, "A complementary"], ["A complementary",
          {"string": "listStart"}, {"string": "complementary"},
          {"string": "list"}, {"string": "listItemsCount", "count": 1}]],
        expectedBraille: [["*", {"string": "complementary"}, "A complementary"],
                          ["*", "A complementary", {"string": "complementary"}]]
      }, {
        accOrElmOrID: "parent_main",
        expectedUtterance: [[{"string": "main"}, "a parent main",
          {"string": "complementary"}, "a child complementary"],
          ["a parent main", "a child complementary",
          {"string": "complementary"}, {"string": "main"}]],
        expectedBraille: [[{"string": "main"}, "a parent main",
          {"string": "complementary"}, "a child complementary"],
          ["a parent main", "a child complementary",
          {"string": "complementary"}, {"string": "main"}]]
      }, {
        accOrElmOrID: "child_complementary",
        expectedUtterance: [[{"string": "main"}, {"string": "complementary"},
          "a child complementary"], ["a child complementary",
          {"string": "complementary"}, {"string": "main"}]],
        expectedBraille: [[{"string": "complementary"},
          "a child complementary"], ["a child complementary",
          {"string": "complementary"}]]
      }];

      // Test outputs (utterance and braille) for landmarks.
      function testOutputOrder(aOutputOrder) {
        return function() {
          SpecialPowers.pushPrefEnv({
            "set": [[PREF_UTTERANCE_ORDER, aOutputOrder]]
          }, function() {
            tests.forEach(function run(test) {
              testOutput(test.expectedUtterance[aOutputOrder], test.accOrElmOrID,
                test.oldAccOrElmOrID, 1);
              testOutput(test.expectedBraille[aOutputOrder], test.accOrElmOrID,
                test.oldAccOrElmOrID, 0);
            });
            AccessFuTest.nextTest();
          });
        };
      }

      AccessFuTest.addFunc(testOutputOrder(0));
      AccessFuTest.addFunc(testOutputOrder(1));
      AccessFuTest.waitForExplicitFinish();
      AccessFuTest.runTests();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>
</head>
<body>
  <div id="root">
    <a target="_blank"
       href="https://bugzilla.mozilla.org/show_bug.cgi?id=888256"
       title="[AccessFu] Speak landmarks">
       Mozilla Bug 888256
       </a>
    <p id="display"></p>
    <div id="content" style="display: none"></div>
    <pre id="test"></pre>
    <nav id="nav">a nav</nav>
    <header id="header">a header</header>
    <footer id="footer">a footer</footer>
    <article id="article_with_header_and_footer">
      <header id="article_header">a header within an article</header>
      <footer id="article_footer">a footer within an article</footer>
    </article>
    <section id="section_with_header_and_footer">
      <header id="section_header">a header within a section</header>
      <footer id="section_footer">a footer within a section</footer>
    </section>
    <aside id="aside">by the way I am an aside</aside>
    <article id="main" role="main">a main area</article>
    <main id="main_element">another main area</main>
    <ul style="list-style-type: none;">
      <li role="complementary" id="complementary">
        A complementary
      </li>
    </ul>
    <main id="parent_main">
      a parent main
      <p id="child_complementary" role="complementary">a child complementary</article>
    </main>
  </div>
</body>
</html>