summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/relations/test_general.html
blob: bcb1d282a53175282360f81a5b729e382ba1fa07 (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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<html>

<head>
  <title>nsIAccessible::getAccessibleRelated() tests</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="../relations.js"></script>
  <script type="application/javascript"
          src="../role.js"></script>

  <script type="application/javascript">
    function doTest()
    {
      // html:label@for
      testRelation("label1_1", RELATION_LABEL_FOR, "control1_1");
      testRelation("control1_1", RELATION_LABELLED_BY, "label1_1");

      // html:label@for, multiple
      testRelation("label1_2", RELATION_LABEL_FOR, "control1_2");
      testRelation("label1_3", RELATION_LABEL_FOR, "control1_2");
      testRelation("control1_2", RELATION_LABELLED_BY,
                   [ "label1_2", "label1_3" ]);

      // ancestor html:label (implicit association)
      testRelation("label1_4", RELATION_LABEL_FOR, "control1_4");
      testRelation("control1_4", RELATION_LABELLED_BY, "label1_4");
      testRelation("control1_4_option1", RELATION_LABELLED_BY, null);
      testRelation("label1_5", RELATION_LABEL_FOR, "control1_5");
      testRelation("control1_5", RELATION_LABELLED_BY, "label1_5");
      testRelation("label1_6", RELATION_LABEL_FOR, "control1_6");
      testRelation("control1_6", RELATION_LABELLED_BY, "label1_6");
      testRelation("label1_7", RELATION_LABEL_FOR, "control1_7");
      testRelation("control1_7", RELATION_LABELLED_BY, "label1_7");
      testRelation("label1_8", RELATION_LABEL_FOR, "control1_8");
      testRelation("control1_8", RELATION_LABELLED_BY, "label1_8");
      testRelation("label1_9", RELATION_LABEL_FOR, "control1_9");
      testRelation("control1_9", RELATION_LABELLED_BY, "label1_9");
      testRelation("label1_10", RELATION_LABEL_FOR, "control1_10");
      testRelation("control1_10", RELATION_LABELLED_BY, "label1_10");
      testRelation("label1_11", RELATION_LABEL_FOR, "control1_11");
      testRelation("control1_11", RELATION_LABELLED_BY, "label1_11");
      testRelation("label1_12", RELATION_LABEL_FOR, "control1_12");
      testRelation("control1_12", RELATION_LABELLED_BY, "label1_12");

      testRelation("label1_13", RELATION_LABEL_FOR, null);
      testRelation("control1_13", RELATION_LABELLED_BY, null);
      testRelation("control1_14", RELATION_LABELLED_BY, "label1_14");

      // aria-labelledby
      testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
      testRelation("checkbox2", RELATION_LABELLED_BY, "label2");

      // aria-labelledby, multiple relations
      testRelation("label3", RELATION_LABEL_FOR, "checkbox3");
      testRelation("label4", RELATION_LABEL_FOR, "checkbox3");
      testRelation("checkbox3", RELATION_LABELLED_BY, ["label3", "label4"]);

      // aria-describedby
      testRelation("descr1", RELATION_DESCRIPTION_FOR, "checkbox4");
      testRelation("checkbox4", RELATION_DESCRIBED_BY, "descr1");

      // aria-describedby, multiple relations
      testRelation("descr2", RELATION_DESCRIPTION_FOR, "checkbox5");
      testRelation("descr3", RELATION_DESCRIPTION_FOR, "checkbox5");
      testRelation("checkbox5", RELATION_DESCRIBED_BY, ["descr2", "descr3"]);

      // aria_owns, multiple relations
      testRelation("treeitem1", RELATION_NODE_CHILD_OF, "tree");
      testRelation("treeitem2", RELATION_NODE_CHILD_OF, "tree");

      // 'node child of' relation for outlineitem role
      testRelation("treeitem3", RELATION_NODE_CHILD_OF, "tree");
      testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree");
      testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4");
      testRelation("treeitem6", RELATION_NODE_CHILD_OF, "tree");
      testRelation("treeitem7", RELATION_NODE_CHILD_OF, "treeitem6");
      testRelation("tree2_ti1", RELATION_NODE_CHILD_OF, "tree2");
      testRelation("tree2_ti1a", RELATION_NODE_CHILD_OF, "tree2_ti1");
      testRelation("tree2_ti1b", RELATION_NODE_CHILD_OF, "tree2_ti1");

      // 'node child of' relation for row role in grid.
      // Relation for row associated using aria-level should exist.
      testRelation("simplegrid-row3", RELATION_NODE_CHILD_OF,
                   "simplegrid-row2");
      // Relations for hierarchical children elements shouldn't exist.
      testAbsentRelation("simplegrid-row1", RELATION_NODE_CHILD_OF,
                         "simplegrid");
      testAbsentRelation("simplegrid-row2", RELATION_NODE_CHILD_OF,
                         "simplegrid");

      // 'node child of' relation for row role of treegrid
      testRelation("treegridrow1", RELATION_NODE_CHILD_OF, "treegrid");
      testRelation("treegridrow2", RELATION_NODE_CHILD_OF, "treegrid");
      testRelation("treegridrow3", RELATION_NODE_CHILD_OF, "treegridrow2");

      // 'node child of' relation for lists organized by groups
      testRelation("listitem1", RELATION_NODE_CHILD_OF, "list");
      testRelation("listitem1.1", RELATION_NODE_CHILD_OF, "listitem1");
      testRelation("listitem1.2", RELATION_NODE_CHILD_OF, "listitem1");

      // 'node child of' relation for the document having window, returns
      // direct accessible parent (fixed in bug 419770).
      var iframeElmObj = {};
      var iframeAcc = getAccessible("iframe", null, iframeElmObj);
      var iframeDoc = iframeElmObj.value.contentDocument;
      var iframeDocAcc = getAccessible(iframeDoc);
      testRelation(iframeDocAcc, RELATION_NODE_CHILD_OF, iframeAcc);

      // 'node parent of' relation on ARIA tree and treegrid.
      testRelation("tree", RELATION_NODE_PARENT_OF,
                    ["treeitem1", "treeitem2", // aria-owns
                     "treeitem3", "treeitem4", "treeitem6"]); // children
      testRelation("treeitem4", RELATION_NODE_PARENT_OF,
                   "treeitem5"); // aria-level
      testRelation("treeitem6", RELATION_NODE_PARENT_OF,
                   "treeitem7"); // // group role
      testRelation("tree2", RELATION_NODE_PARENT_OF, "tree2_ti1"); // group role
      testRelation("tree2_ti1", RELATION_NODE_PARENT_OF,
                   ["tree2_ti1a", "tree2_ti1b"]); // group role

      testRelation("treegridrow2", RELATION_NODE_PARENT_OF, "treegridrow3");
      testRelation("treegrid", RELATION_NODE_PARENT_OF,
                   ["treegridrow1", "treegridrow2"]);

      // 'node parent of' relation on ARIA grid.
      // 'node parent of' relation on ARIA grid's row.
      // Should only have relation to child through aria-level.
      testRelation("simplegrid-row2", RELATION_NODE_PARENT_OF,
                   "simplegrid-row3");

      // 'node parent of' relation on ARIA list structured by groups
      testRelation("list", RELATION_NODE_PARENT_OF,
                   "listitem1");
      testRelation("listitem1", RELATION_NODE_PARENT_OF,
                   [ "listitem1.1", "listitem1.2" ]);

      // aria-atomic
      testRelation(getNode("atomic").firstChild, RELATION_MEMBER_OF, "atomic");

      // aria-controls
      getAccessible("tab");
      todo(false,
           "Getting an accessible tab, otherwise relations for tabpanel aren't cached. Bug 606924 will fix that.");
      testRelation("tabpanel", RELATION_CONTROLLED_BY, "tab");
      testRelation("tab", RELATION_CONTROLLER_FOR, "tabpanel");

      // aria-controls, multiple relations
      testRelation("lr1", RELATION_CONTROLLED_BY, "button");
      testRelation("lr2", RELATION_CONTROLLED_BY, "button");
      testRelation("button", RELATION_CONTROLLER_FOR, ["lr1", "lr2"]);

      // aria-flowto
      testRelation("flowto", RELATION_FLOWS_TO, "flowfrom");
      testRelation("flowfrom", RELATION_FLOWS_FROM, "flowto");

      // aria-flowto, multiple relations
      testRelation("flowto1", RELATION_FLOWS_TO, ["flowfrom1", "flowfrom2"]);
      testRelation("flowfrom1", RELATION_FLOWS_FROM, "flowto1");
      testRelation("flowfrom2", RELATION_FLOWS_FROM, "flowto1");

      // 'default button' relation
      testRelation("input", RELATION_DEFAULT_BUTTON, "submit");

      // output 'for' relations
      testRelation("output", RELATION_CONTROLLED_BY, ["input", "input2"]);
      testRelation("output2", RELATION_CONTROLLED_BY, ["input", "input2"]);
      testRelation("input", RELATION_CONTROLLER_FOR, ["output", "output2"]);
      testRelation("input2", RELATION_CONTROLLER_FOR, ["output", "output2"]);

      // 'described by'/'description for' relation for html:table and
      // html:caption
      testRelation("caption", RELATION_LABEL_FOR, "table");
      testRelation("table", RELATION_LABELLED_BY, "caption");

      // 'labelled by'/'label for' relation for html:fieldset and
      // html:legend
      testRelation("legend", RELATION_LABEL_FOR, "fieldset");
      testRelation("fieldset", RELATION_LABELLED_BY, "legend");

      // containing relations
      testRelation("control1_1", RELATION_CONTAINING_DOCUMENT, document);
      testRelation("control1_1", RELATION_CONTAINING_TAB_PANE, getTabDocAccessible("control1_1"));
      testRelation("control1_1", RELATION_CONTAINING_APPLICATION, getApplicationAccessible());

      // details
      testRelation("has_details", RELATION_DETAILS, "details");
      testRelation("details", RELATION_DETAILS_FOR, "has_details");

      // error
      testRelation("has_error", RELATION_ERRORMSG, "error");
      testRelation("error", RELATION_ERRORMSG_FOR, "has_error");

      // finish test
      SimpleTest.finish();
    }

    disableLogging(); // from test_embeds.xul
    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doTest);
  </script>

</head>

<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=475298"
     title="mochitests for accessible relations">
    Bug 475298
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=527461"
     title="Implement RELATION_NODE_PARENT_OF">
    Bug 527461
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036"
     title="make HTML <output> accessible">
    Bug 558036
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=682790"
     title="Ignore implicit label association when it's associated explicitly">
    Bug 682790
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=687393"
     title="HTML select options gets relation from containing label">
    Bug 687393
  </a>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=864224"
     title="Support nested ARIA listitems structured by role='group'">
    Bug 864224
  </a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <label id="label1_1" for="control1_1">label</label>
  <input id="control1_1">

  <label id="label1_2" for="control1_2">label</label>
  <label id="label1_3" for="control1_2">label</label>
  <input id="control1_2">

  <label id="label1_4">Label
    <select id="control1_4">
      <option id="control1_4_option1">option</option>
    </select>
  </label>
  <label id="label1_5">Label
    <button id="control1_5">button</button>
  </label>
  <label id="label1_6">Label
    <input id="control1_6">
  </label>
  <label id="label1_7">Label
    <input id="control1_7" type="checkbox">
  </label>
  <label id="label1_8">Label
    <input id="control1_8" type="radio">
  </label>
  <label id="label1_9">Label
    <input id="control1_9" type="button" value="button">
  </label>
  <label id="label1_10">Label
    <input id="control1_10" type="submit">
  </label>
  <label id="label1_11">Label
    <input id="control1_11" type="image">
  </label>
  <label id="label1_12">Label
    <progress id="control1_12"></progress>
  </label>

  <label id="label1_13" for="">Label
    <input id="control1_13">
  </label>
  <label id="label1_14" for="control1_14">Label
    <input id="control1_14">
  </label>

  <span id="label2">label</span>
  <span role="checkbox" id="checkbox2" aria-labelledby="label2"></span>

  <span id="label3">label1</span>
  <span id="label4">label2</span>
  <span role="checkbox" id="checkbox3" aria-labelledby="label3 label4"></span>

  <span id="descr1">description</span>
  <span role="checkbox" id="checkbox4" aria-describedby="descr1"></span>

  <span id="descr2">description1</span>
  <span id="descr3">description2</span>
  <span role="checkbox" id="checkbox5" aria-describedby="descr2 descr3"></span>

  <div role="treeitem" id="treeitem1">Yellow</div>
  <div role="treeitem" id="treeitem2">Orange</div>
  <div id="tree" role="tree" aria-owns="treeitem1 treeitem2">
    <div role="treeitem" id="treeitem3">Blue</div>
    <div role="treeitem" id="treeitem4" aria-level="1">Green</div>
    <div role="treeitem" id="treeitem5" aria-level="2">Light green</div>
    <div role="treeitem" id="treeitem6" aria-level="1">Green2</div>
    <div role="group">
      <div role="treeitem" id="treeitem7">Super light green</div>
    </div>
  </div>

  <div role="grid" id="simplegrid">
    <div role="row" id="simplegrid-row1" aria-level="1">
      <div role="gridcell">cell 1,1</div>
      <div role="gridcell">cell 1,2</div>
    </div>
    <div role="row" id="simplegrid-row2" aria-level="1">
      <div role="gridcell">cell 2,1</div>
      <div role="gridcell">cell 2,2</div>
    </div>
    <div role="row" id="simplegrid-row3" aria-level="2">
      <div role="gridcell">cell 3,1</div>
      <div role="gridcell">cell 3,2</div>
    </div>
  </div>

  <ul role="tree" id="tree2">
    <li role="treeitem" id="tree2_ti1">Item 1
      <ul role="group">
        <li role="treeitem" id="tree2_ti1a">Item 1A</li>
        <li role="treeitem" id="tree2_ti1b">Item 1B</li>
      </ul>
    </li>
  </ul>

  <div role="treegrid" id="treegrid">
    <div role="row" id="treegridrow1">
      <span role="gridcell">cell1</span><span role="gridcell">cell2</span>
    </div>
    <div role="row" id="treegridrow2" aria-level="1">
      <span role="gridcell">cell3</span><span role="gridcell">cell4</span>
    </div>
    <div role="row" id="treegridrow3" aria-level="2">
      <span role="gridcell">cell5</span><span role="gridcell">cell6</span>
    </div>
  </div>

  <div role="list" id="list">
    <div role="listitem" id="listitem1">Item 1
      <div role="group">
        <div role="listitem" id="listitem1.1">Item 1A</div>
        <div role="listitem" id="listitem1.2">Item 1B</div>
      </div>
    </div>
  </div>

  <iframe id="iframe"></iframe>

  <div id="tablist" role="tablist">
    <div id="tab" role="tab" aria-controls="tabpanel">tab</div>
  </div>
  <div id="tabpanel" role="tabpanel">tabpanel</div>

  <div id="lr1" aria-live="assertive">1</div>
  <div id="lr2" aria-live="assertive">a</div>
  <input type="button" id="button" aria-controls="lr1 lr2"
         onclick="getNode('lr1').textContent += '1'; getNode('lr2').textContent += 'a';"/>

  <div id="atomic" aria-atomic="true">live region</div>

  <span id="flowto" aria-flowto="flowfrom">flow to</span>
  <span id="flowfrom">flow from</span>

  <span id="flowto1" aria-flowto="flowfrom1 flowfrom2">flow to</span>
  <span id="flowfrom1">flow from</span>
  <span id="flowfrom2">flow from</span>

  <form id="form">
    <input id="input" />
    <input id="input2" />
    <input type="submit" id="submit" />
    <output id="output" style="display:block" for="input input2"></output>
    <output id="output2" for="input input2"></output>
  </form>

  <table id="table">
    <caption id="caption">tabple caption</caption>
    <tr>
      <td>cell1</td><td>cell2</td>
    </tr>
  </table>

  <fieldset id="fieldset">
    <legend id="legend">legend</legend>
    <input />
  </fieldset>

  <input id="has_details" aria-details="details"><section id="details"></section>
  <input id="has_error" aria-errormessage="error"><section id="error"></section>
</body>
</html>