summaryrefslogtreecommitdiff
path: root/accessible/tests/mochitest/jsat/test_explicit_names.html
blob: fb7ed2022ed4aea0f73d0641c4d18b6058381915 (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
184
185
186
187
188
189
190
191
<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.pushPrefEnv({"set": [[PREF_UTTERANCE_ORDER, 0]]}, function() {
        // Test various explicit names vs the utterance generated from subtrees.
        tests.forEach(function run(test) {
          testOutput(test.expected, test.accOrElmOrID, test.oldAccOrElmOrID, 1);
        });
        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>