|
1 <html> |
|
2 |
|
3 <head> |
|
4 <title>nsIAccessible::getAccessibleRelated() tests</title> |
|
5 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
6 |
|
7 <script type="application/javascript" |
|
8 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
9 |
|
10 <script type="application/javascript" |
|
11 src="../common.js"></script> |
|
12 <script type="application/javascript" |
|
13 src="../relations.js"></script> |
|
14 <script type="application/javascript" |
|
15 src="../role.js"></script> |
|
16 |
|
17 <script type="application/javascript"> |
|
18 function doTest() |
|
19 { |
|
20 // html:label@for |
|
21 testRelation("label1_1", RELATION_LABEL_FOR, "control1_1"); |
|
22 testRelation("control1_1", RELATION_LABELLED_BY, "label1_1"); |
|
23 |
|
24 // html:label@for, multiple |
|
25 testRelation("label1_2", RELATION_LABEL_FOR, "control1_2"); |
|
26 testRelation("label1_3", RELATION_LABEL_FOR, "control1_2"); |
|
27 testRelation("control1_2", RELATION_LABELLED_BY, |
|
28 [ "label1_2", "label1_3" ]); |
|
29 |
|
30 // ancestor html:label (implicit association) |
|
31 testRelation("label1_4", RELATION_LABEL_FOR, "control1_4"); |
|
32 testRelation("control1_4", RELATION_LABELLED_BY, "label1_4"); |
|
33 testRelation("control1_4_option1", RELATION_LABELLED_BY, null); |
|
34 testRelation("label1_5", RELATION_LABEL_FOR, "control1_5"); |
|
35 testRelation("control1_5", RELATION_LABELLED_BY, "label1_5"); |
|
36 testRelation("label1_6", RELATION_LABEL_FOR, "control1_6"); |
|
37 testRelation("control1_6", RELATION_LABELLED_BY, "label1_6"); |
|
38 testRelation("label1_7", RELATION_LABEL_FOR, "control1_7"); |
|
39 testRelation("control1_7", RELATION_LABELLED_BY, "label1_7"); |
|
40 testRelation("label1_8", RELATION_LABEL_FOR, "control1_8"); |
|
41 testRelation("control1_8", RELATION_LABELLED_BY, "label1_8"); |
|
42 testRelation("label1_9", RELATION_LABEL_FOR, "control1_9"); |
|
43 testRelation("control1_9", RELATION_LABELLED_BY, "label1_9"); |
|
44 testRelation("label1_10", RELATION_LABEL_FOR, "control1_10"); |
|
45 testRelation("control1_10", RELATION_LABELLED_BY, "label1_10"); |
|
46 testRelation("label1_11", RELATION_LABEL_FOR, "control1_11"); |
|
47 testRelation("control1_11", RELATION_LABELLED_BY, "label1_11"); |
|
48 testRelation("label1_12", RELATION_LABEL_FOR, "control1_12"); |
|
49 testRelation("control1_12", RELATION_LABELLED_BY, "label1_12"); |
|
50 |
|
51 testRelation("label1_13", RELATION_LABEL_FOR, null); |
|
52 testRelation("control1_13", RELATION_LABELLED_BY, null); |
|
53 testRelation("control1_14", RELATION_LABELLED_BY, "label1_14"); |
|
54 |
|
55 // aria-labelledby |
|
56 testRelation("label2", RELATION_LABEL_FOR, "checkbox2"); |
|
57 testRelation("checkbox2", RELATION_LABELLED_BY, "label2"); |
|
58 |
|
59 // aria-labelledby, multiple relations |
|
60 testRelation("label3", RELATION_LABEL_FOR, "checkbox3"); |
|
61 testRelation("label4", RELATION_LABEL_FOR, "checkbox3"); |
|
62 testRelation("checkbox3", RELATION_LABELLED_BY, ["label3", "label4"]); |
|
63 |
|
64 // aria-describedby |
|
65 testRelation("descr1", RELATION_DESCRIPTION_FOR, "checkbox4"); |
|
66 testRelation("checkbox4", RELATION_DESCRIBED_BY, "descr1"); |
|
67 |
|
68 // aria-describedby, multiple relations |
|
69 testRelation("descr2", RELATION_DESCRIPTION_FOR, "checkbox5"); |
|
70 testRelation("descr3", RELATION_DESCRIPTION_FOR, "checkbox5"); |
|
71 testRelation("checkbox5", RELATION_DESCRIBED_BY, ["descr2", "descr3"]); |
|
72 |
|
73 // aria_owns, multiple relations |
|
74 testRelation("treeitem1", RELATION_NODE_CHILD_OF, "tree"); |
|
75 testRelation("treeitem2", RELATION_NODE_CHILD_OF, "tree"); |
|
76 |
|
77 // 'node child of' relation for outlineitem role |
|
78 testRelation("treeitem3", RELATION_NODE_CHILD_OF, "tree"); |
|
79 testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree"); |
|
80 testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4"); |
|
81 testRelation("treeitem6", RELATION_NODE_CHILD_OF, "tree"); |
|
82 testRelation("treeitem7", RELATION_NODE_CHILD_OF, "treeitem6"); |
|
83 testRelation("tree2_ti1", RELATION_NODE_CHILD_OF, "tree2"); |
|
84 testRelation("tree2_ti1a", RELATION_NODE_CHILD_OF, "tree2_ti1"); |
|
85 testRelation("tree2_ti1b", RELATION_NODE_CHILD_OF, "tree2_ti1"); |
|
86 |
|
87 // 'node child of' relation for row role in grid. |
|
88 // Relation for row associated using aria-owns should exist. |
|
89 testRelation("simplegrid-ownrow", RELATION_NODE_CHILD_OF, "simplegrid"); |
|
90 // Relation for row associated using aria-level should exist. |
|
91 testRelation("simplegrid-row3", RELATION_NODE_CHILD_OF, |
|
92 "simplegrid-row2"); |
|
93 // Relations for hierarchical children elements shouldn't exist. |
|
94 testAbsentRelation("simplegrid-row1", RELATION_NODE_CHILD_OF, |
|
95 "simplegrid"); |
|
96 testAbsentRelation("simplegrid-row2", RELATION_NODE_CHILD_OF, |
|
97 "simplegrid"); |
|
98 |
|
99 // 'node child of' relation for row role of treegrid |
|
100 testRelation("treegridrow1", RELATION_NODE_CHILD_OF, "treegrid"); |
|
101 testRelation("treegridrow2", RELATION_NODE_CHILD_OF, "treegrid"); |
|
102 testRelation("treegridrow3", RELATION_NODE_CHILD_OF, "treegridrow2"); |
|
103 |
|
104 // 'node child of' relation for lists organized by groups |
|
105 testRelation("listitem1", RELATION_NODE_CHILD_OF, "list"); |
|
106 testRelation("listitem1.1", RELATION_NODE_CHILD_OF, "listitem1"); |
|
107 testRelation("listitem1.2", RELATION_NODE_CHILD_OF, "listitem1"); |
|
108 |
|
109 // 'node child of' relation for the document having window, returns |
|
110 // direct accessible parent (fixed in bug 419770). |
|
111 var iframeElmObj = {}; |
|
112 var iframeAcc = getAccessible("iframe", null, iframeElmObj); |
|
113 var iframeDoc = iframeElmObj.value.contentDocument; |
|
114 var iframeDocAcc = getAccessible(iframeDoc); |
|
115 testRelation(iframeDocAcc, RELATION_NODE_CHILD_OF, iframeAcc); |
|
116 |
|
117 // 'node parent of' relation on ARIA tree and treegrid. |
|
118 testRelation("tree", RELATION_NODE_PARENT_OF, |
|
119 ["treeitem1", "treeitem2", // aria-owns |
|
120 "treeitem3", "treeitem4", "treeitem6"]); // children |
|
121 testRelation("treeitem4", RELATION_NODE_PARENT_OF, |
|
122 "treeitem5"); // aria-level |
|
123 testRelation("treeitem6", RELATION_NODE_PARENT_OF, |
|
124 "treeitem7"); // // group role |
|
125 testRelation("tree2", RELATION_NODE_PARENT_OF, "tree2_ti1"); // group role |
|
126 testRelation("tree2_ti1", RELATION_NODE_PARENT_OF, |
|
127 ["tree2_ti1a", "tree2_ti1b"]); // group role |
|
128 |
|
129 testRelation("treegridrow2", RELATION_NODE_PARENT_OF, "treegridrow3"); |
|
130 testRelation("treegrid", RELATION_NODE_PARENT_OF, |
|
131 ["treegridrow1", "treegridrow2"]); |
|
132 |
|
133 // 'node parent of' relation on ARIA grid. |
|
134 // Should only have relation to child added through aria-owns. |
|
135 testRelation("simplegrid", RELATION_NODE_PARENT_OF, "simplegrid-ownrow"); |
|
136 // 'node parent of' relation on ARIA grid's row. |
|
137 // Should only have relation to child through aria-level. |
|
138 testRelation("simplegrid-row2", RELATION_NODE_PARENT_OF, |
|
139 "simplegrid-row3"); |
|
140 |
|
141 // 'node parent of' relation on ARIA list structured by groups |
|
142 testRelation("list", RELATION_NODE_PARENT_OF, |
|
143 "listitem1"); |
|
144 testRelation("listitem1", RELATION_NODE_PARENT_OF, |
|
145 [ "listitem1.1", "listitem1.2" ]); |
|
146 |
|
147 // aria-atomic |
|
148 testRelation(getNode("atomic").firstChild, RELATION_MEMBER_OF, "atomic"); |
|
149 |
|
150 // aria-controls |
|
151 getAccessible("tab"); |
|
152 todo(false, |
|
153 "Getting an accessible tab, otherwise relations for tabpanel aren't cached. Bug 606924 will fix that."); |
|
154 testRelation("tabpanel", RELATION_CONTROLLED_BY, "tab"); |
|
155 testRelation("tab", RELATION_CONTROLLER_FOR, "tabpanel"); |
|
156 |
|
157 // aria-controls, multiple relations |
|
158 testRelation("lr1", RELATION_CONTROLLED_BY, "button"); |
|
159 testRelation("lr2", RELATION_CONTROLLED_BY, "button"); |
|
160 testRelation("button", RELATION_CONTROLLER_FOR, ["lr1", "lr2"]); |
|
161 |
|
162 // aria-flowto |
|
163 testRelation("flowto", RELATION_FLOWS_TO, "flowfrom"); |
|
164 testRelation("flowfrom", RELATION_FLOWS_FROM, "flowto"); |
|
165 |
|
166 // aria-flowto, multiple relations |
|
167 testRelation("flowto1", RELATION_FLOWS_TO, ["flowfrom1", "flowfrom2"]); |
|
168 testRelation("flowfrom1", RELATION_FLOWS_FROM, "flowto1"); |
|
169 testRelation("flowfrom2", RELATION_FLOWS_FROM, "flowto1"); |
|
170 |
|
171 // 'default button' relation |
|
172 testRelation("input", RELATION_DEFAULT_BUTTON, "submit"); |
|
173 |
|
174 // output 'for' relations |
|
175 testRelation("output", RELATION_CONTROLLED_BY, ["input", "input2"]); |
|
176 testRelation("output2", RELATION_CONTROLLED_BY, ["input", "input2"]); |
|
177 testRelation("input", RELATION_CONTROLLER_FOR, ["output", "output2"]); |
|
178 testRelation("input2", RELATION_CONTROLLER_FOR, ["output", "output2"]); |
|
179 |
|
180 // 'described by'/'description for' relation for html:table and |
|
181 // html:caption |
|
182 testRelation("caption", RELATION_LABEL_FOR, "table"); |
|
183 testRelation("table", RELATION_LABELLED_BY, "caption"); |
|
184 |
|
185 // 'labelled by'/'label for' relation for html:fieldset and |
|
186 // html:legend |
|
187 testRelation("legend", RELATION_LABEL_FOR, "fieldset"); |
|
188 testRelation("fieldset", RELATION_LABELLED_BY, "legend"); |
|
189 |
|
190 // containing relations |
|
191 testRelation("control1_1", RELATION_CONTAINING_DOCUMENT, document); |
|
192 testRelation("control1_1", RELATION_CONTAINING_TAB_PANE, getTabDocAccessible("control1_1")); |
|
193 testRelation("control1_1", RELATION_CONTAINING_APPLICATION, getApplicationAccessible()); |
|
194 |
|
195 // finish test |
|
196 SimpleTest.finish(); |
|
197 } |
|
198 |
|
199 disableLogging(); // from test_embeds.xul |
|
200 SimpleTest.waitForExplicitFinish(); |
|
201 addA11yLoadEvent(doTest); |
|
202 </script> |
|
203 |
|
204 </head> |
|
205 |
|
206 <body> |
|
207 |
|
208 <a target="_blank" |
|
209 href="https://bugzilla.mozilla.org/show_bug.cgi?id=475298" |
|
210 title="mochitests for accessible relations"> |
|
211 Bug 475298 |
|
212 </a> |
|
213 <a target="_blank" |
|
214 href="https://bugzilla.mozilla.org/show_bug.cgi?id=527461" |
|
215 title="Implement RELATION_NODE_PARENT_OF"> |
|
216 Bug 527461 |
|
217 </a> |
|
218 <a target="_blank" |
|
219 href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036" |
|
220 title="make HTML <output> accessible"> |
|
221 Bug 558036 |
|
222 </a> |
|
223 <a target="_blank" |
|
224 href="https://bugzilla.mozilla.org/show_bug.cgi?id=682790" |
|
225 title="Ignore implicit label association when it's associated explicitly"> |
|
226 Bug 682790 |
|
227 </a> |
|
228 <a target="_blank" |
|
229 href="https://bugzilla.mozilla.org/show_bug.cgi?id=687393" |
|
230 title="HTML select options gets relation from containing label"> |
|
231 Bug 687393 |
|
232 </a> |
|
233 <a target="_blank" |
|
234 href="https://bugzilla.mozilla.org/show_bug.cgi?id=864224" |
|
235 title="Support nested ARIA listitems structured by role='group'"> |
|
236 Bug 864224 |
|
237 </a> |
|
238 <p id="display"></p> |
|
239 <div id="content" style="display: none"></div> |
|
240 <pre id="test"> |
|
241 </pre> |
|
242 |
|
243 <label id="label1_1" for="control1_1">label</label> |
|
244 <input id="control1_1"> |
|
245 |
|
246 <label id="label1_2" for="control1_2">label</label> |
|
247 <label id="label1_3" for="control1_2">label</label> |
|
248 <input id="control1_2"> |
|
249 |
|
250 <label id="label1_4">Label |
|
251 <select id="control1_4"> |
|
252 <option id="control1_4_option1">option</option> |
|
253 </select> |
|
254 </label> |
|
255 <label id="label1_5">Label |
|
256 <button id="control1_5">button</button> |
|
257 </label> |
|
258 <label id="label1_6">Label |
|
259 <input id="control1_6"> |
|
260 </label> |
|
261 <label id="label1_7">Label |
|
262 <input id="control1_7" type="checkbox"> |
|
263 </label> |
|
264 <label id="label1_8">Label |
|
265 <input id="control1_8" type="radio"> |
|
266 </label> |
|
267 <label id="label1_9">Label |
|
268 <input id="control1_9" type="button" value="button"> |
|
269 </label> |
|
270 <label id="label1_10">Label |
|
271 <input id="control1_10" type="submit"> |
|
272 </label> |
|
273 <label id="label1_11">Label |
|
274 <input id="control1_11" type="image"> |
|
275 </label> |
|
276 <label id="label1_12">Label |
|
277 <progress id="control1_12"></progress> |
|
278 </label> |
|
279 |
|
280 <label id="label1_13" for="">Label |
|
281 <input id="control1_13"> |
|
282 </label> |
|
283 <label id="label1_14" for="control1_14">Label |
|
284 <input id="control1_14"> |
|
285 </label> |
|
286 |
|
287 <span id="label2">label</span> |
|
288 <span role="checkbox" id="checkbox2" aria-labelledby="label2"></span> |
|
289 |
|
290 <span id="label3">label1</span> |
|
291 <span id="label4">label2</span> |
|
292 <span role="checkbox" id="checkbox3" aria-labelledby="label3 label4"></span> |
|
293 |
|
294 <span id="descr1">description</span> |
|
295 <span role="checkbox" id="checkbox4" aria-describedby="descr1"></span> |
|
296 |
|
297 <span id="descr2">description1</span> |
|
298 <span id="descr3">description2</span> |
|
299 <span role="checkbox" id="checkbox5" aria-describedby="descr2 descr3"></span> |
|
300 |
|
301 <div role="treeitem" id="treeitem1">Yellow</div> |
|
302 <div role="treeitem" id="treeitem2">Orange</div> |
|
303 <div id="tree" role="tree" aria-owns="treeitem1 treeitem2"> |
|
304 <div role="treeitem" id="treeitem3">Blue</div> |
|
305 <div role="treeitem" id="treeitem4" aria-level="1">Green</div> |
|
306 <div role="treeitem" id="treeitem5" aria-level="2">Light green</div> |
|
307 <div role="treeitem" id="treeitem6" aria-level="1">Green2</div> |
|
308 <div role="group"> |
|
309 <div role="treeitem" id="treeitem7">Super light green</div> |
|
310 </div> |
|
311 </div> |
|
312 |
|
313 <div aria-owns="simplegrid-ownrow" role="grid" id="simplegrid"> |
|
314 <div role="row" id="simplegrid-row1" aria-level="1"> |
|
315 <div role="gridcell">cell 1,1</div> |
|
316 <div role="gridcell">cell 1,2</div> |
|
317 </div> |
|
318 <div role="row" id="simplegrid-row2" aria-level="1"> |
|
319 <div role="gridcell">cell 2,1</div> |
|
320 <div role="gridcell">cell 2,2</div> |
|
321 </div> |
|
322 <div role="row" id="simplegrid-row3" aria-level="2"> |
|
323 <div role="gridcell">cell 3,1</div> |
|
324 <div role="gridcell">cell 3,2</div> |
|
325 </div> |
|
326 </div> |
|
327 <div role="row" id="simplegrid-ownrow"></div> |
|
328 |
|
329 <ul role="tree" id="tree2"> |
|
330 <li role="treeitem" id="tree2_ti1">Item 1 |
|
331 <ul role="group"> |
|
332 <li role="treeitem" id="tree2_ti1a">Item 1A</li> |
|
333 <li role="treeitem" id="tree2_ti1b">Item 1B</li> |
|
334 </ul> |
|
335 </li> |
|
336 </ul> |
|
337 |
|
338 <div role="treegrid" id="treegrid"> |
|
339 <div role="row" id="treegridrow1"> |
|
340 <span role="gridcell">cell1</span><span role="gridcell">cell2</span> |
|
341 </div> |
|
342 <div role="row" id="treegridrow2" aria-level="1"> |
|
343 <span role="gridcell">cell3</span><span role="gridcell">cell4</span> |
|
344 </div> |
|
345 <div role="row" id="treegridrow3" aria-level="2"> |
|
346 <span role="gridcell">cell5</span><span role="gridcell">cell6</span> |
|
347 </div> |
|
348 </div> |
|
349 |
|
350 <div role="list" id="list"> |
|
351 <div role="listitem" id="listitem1">Item 1 |
|
352 <div role="group"> |
|
353 <div role="listitem" id="listitem1.1">Item 1A</div> |
|
354 <div role="listitem" id="listitem1.2">Item 1B</div> |
|
355 </div> |
|
356 </div> |
|
357 </div> |
|
358 |
|
359 <iframe id="iframe"></iframe> |
|
360 |
|
361 <div id="tablist" role="tablist"> |
|
362 <div id="tab" role="tab" aria-controls="tabpanel">tab</div> |
|
363 </div> |
|
364 <div id="tabpanel" role="tabpanel">tabpanel</div> |
|
365 |
|
366 <div id="lr1" aria-live="assertive">1</div> |
|
367 <div id="lr2" aria-live="assertive">a</div> |
|
368 <input type="button" id="button" aria-controls="lr1 lr2" |
|
369 onclick="getNode('lr1').textContent += '1'; getNode('lr2').textContent += 'a';"/> |
|
370 |
|
371 <div id="atomic" aria-atomic="true">live region</div> |
|
372 |
|
373 <span id="flowto" aria-flowto="flowfrom">flow to</span> |
|
374 <span id="flowfrom">flow from</span> |
|
375 |
|
376 <span id="flowto1" aria-flowto="flowfrom1 flowfrom2">flow to</span> |
|
377 <span id="flowfrom1">flow from</span> |
|
378 <span id="flowfrom2">flow from</span> |
|
379 |
|
380 <form id="form"> |
|
381 <input id="input" /> |
|
382 <input id="input2" /> |
|
383 <input type="submit" id="submit" /> |
|
384 <output id="output" style="display:block" for="input input2"></output> |
|
385 <output id="output2" for="input input2"></output> |
|
386 </form> |
|
387 |
|
388 <table id="table"> |
|
389 <caption id="caption">tabple caption</caption> |
|
390 <tr> |
|
391 <td>cell1</td><td>cell2</td> |
|
392 </tr> |
|
393 </table> |
|
394 |
|
395 <fieldset id="fieldset"> |
|
396 <legend id="legend">legend</legend> |
|
397 <input /> |
|
398 </fieldset> |
|
399 </body> |
|
400 </html> |