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