browser_obj_group_002.js (12387B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /* import-globals-from ../../mochitest/attributes.js */ 8 loadScripts({ name: "attributes.js", dir: MOCHITESTS_DIR }); 9 10 addAccessibleTask( 11 `<table role="grid" id="grid"> 12 <tr role="row" id="grid_row1"> 13 <td role="gridcell" id="grid_cell1">cell1</td> 14 <td role="gridcell" id="grid_cell2">cell2</td> 15 </tr> 16 <tr role="row" id="grid_row2"> 17 <td role="gridcell" id="grid_cell3">cell3</td> 18 <td role="gridcell" id="grid_cell4">cell4</td> 19 </tr> 20 </table>`, 21 async function (browser, accDoc) { 22 let getAcc = id => findAccessibleChildByID(accDoc, id); 23 24 // //////////////////////////////////////////////////////////////////////// 25 // ARIA grid 26 testGroupAttrs(getAcc("grid_row1"), 1, 2); 27 testAbsentAttrs(getAcc("grid_cell1"), { posinset: "", setsize: "" }); 28 testAbsentAttrs(getAcc("grid_cell2"), { posinset: "", setsize: "" }); 29 30 testGroupAttrs(getAcc("grid_row2"), 2, 2); 31 testAbsentAttrs(getAcc("grid_cell3"), { posinset: "", setsize: "" }); 32 testAbsentAttrs(getAcc("grid_cell4"), { posinset: "", setsize: "" }); 33 testGroupParentAttrs(getAcc("grid"), 2, false, false); 34 }, 35 { 36 topLevel: true, 37 iframe: true, 38 remoteIframe: true, 39 chrome: true, 40 } 41 ); 42 43 addAccessibleTask( 44 `<div role="treegrid" id="treegrid" aria-colcount="4"> 45 <div role="row" aria-level="1" id="treegrid_row1"> 46 <div role="gridcell" id="treegrid_cell1">cell1</div> 47 <div role="gridcell" id="treegrid_cell2">cell2</div> 48 </div> 49 <div role="row" aria-level="2" id="treegrid_row2"> 50 <div role="gridcell" id="treegrid_cell3">cell1</div> 51 <div role="gridcell" id="treegrid_cell4">cell2</div> 52 </div> 53 <div role="row" id="treegrid_row3"> 54 <div role="gridcell" id="treegrid_cell5">cell1</div> 55 <div role="gridcell" id="treegrid_cell6">cell2</div> 56 </div> 57 </div>`, 58 async function (browser, accDoc) { 59 let getAcc = id => findAccessibleChildByID(accDoc, id); 60 61 // //////////////////////////////////////////////////////////////////////// 62 // ARIA treegrid 63 testGroupAttrs(getAcc("treegrid_row1"), 1, 2, 1); 64 testAbsentAttrs(getAcc("treegrid_cell1"), { posinset: "", setsize: "" }); 65 testAbsentAttrs(getAcc("treegrid_cell2"), { posinset: "", setsize: "" }); 66 67 testGroupAttrs(getAcc("treegrid_row2"), 1, 1, 2); 68 testAbsentAttrs(getAcc("treegrid_cell3"), { posinset: "", setsize: "" }); 69 testAbsentAttrs(getAcc("treegrid_cell4"), { posinset: "", setsize: "" }); 70 71 testGroupAttrs(getAcc("treegrid_row3"), 2, 2, 1); 72 testAbsentAttrs(getAcc("treegrid_cell5"), { posinset: "", setsize: "" }); 73 testAbsentAttrs(getAcc("treegrid_cell6"), { posinset: "", setsize: "" }); 74 75 testGroupParentAttrs(getAcc("treegrid"), 2, true); 76 // row child item count provided by parent grid's aria-colcount 77 testGroupParentAttrs(getAcc("treegrid_row1"), 4, false); 78 }, 79 { 80 topLevel: true, 81 iframe: true, 82 remoteIframe: true, 83 chrome: true, 84 } 85 ); 86 87 addAccessibleTask( 88 `<div id="headings"> 89 <h1 id="h1">heading1</h1> 90 <h2 id="h2">heading2</h2> 91 <h3 id="h3">heading3</h3> 92 <h4 id="h4">heading4</h4> 93 <h5 id="h5">heading5</h5> 94 <h6 id="h6">heading6</h6> 95 <div id="ariaHeadingNoLevel" role="heading">ariaHeadingNoLevel</div> 96 </div>`, 97 async function (browser, accDoc) { 98 let getAcc = id => findAccessibleChildByID(accDoc, id); 99 100 // //////////////////////////////////////////////////////////////////////// 101 // HTML headings 102 testGroupAttrs(getAcc("h1"), 0, 0, 1); 103 testGroupAttrs(getAcc("h2"), 0, 0, 2); 104 testGroupAttrs(getAcc("h3"), 0, 0, 3); 105 testGroupAttrs(getAcc("h4"), 0, 0, 4); 106 testGroupAttrs(getAcc("h5"), 0, 0, 5); 107 testGroupAttrs(getAcc("h6"), 0, 0, 6); 108 testGroupAttrs(getAcc("ariaHeadingNoLevel"), 0, 0, 2); 109 // No child item counts or "tree" flag for parent of headings 110 testAbsentAttrs(getAcc("headings"), { "child-item-count": "", tree: "" }); 111 }, 112 { 113 topLevel: true, 114 iframe: true, 115 remoteIframe: true, 116 chrome: true, 117 } 118 ); 119 120 addAccessibleTask( 121 `<ul id="combo1" role="combobox">Password 122 <li id="combo1_opt1" role="option">Xyzzy</li> 123 <li id="combo1_opt2" role="option">Plughs</li> 124 <li id="combo1_opt3" role="option">Shazaam</li> 125 <li id="combo1_opt4" role="option">JoeSentMe</li> 126 </ul>`, 127 async function (browser, accDoc) { 128 let getAcc = id => findAccessibleChildByID(accDoc, id); 129 130 // //////////////////////////////////////////////////////////////////////// 131 // ARIA combobox 132 testGroupAttrs(getAcc("combo1_opt1"), 1, 4); 133 testGroupAttrs(getAcc("combo1_opt2"), 2, 4); 134 testGroupAttrs(getAcc("combo1_opt3"), 3, 4); 135 testGroupAttrs(getAcc("combo1_opt4"), 4, 4); 136 testGroupParentAttrs(getAcc("combo1"), 4, false); 137 }, 138 { 139 topLevel: true, 140 iframe: true, 141 remoteIframe: true, 142 chrome: true, 143 } 144 ); 145 146 addAccessibleTask( 147 `<div role="table" aria-colcount="4" aria-rowcount="2" id="table"> 148 <div role="row" id="table_row" aria-rowindex="2"> 149 <div role="cell" id="table_cell" aria-colindex="3">cell</div> 150 </div> 151 </div>`, 152 async function (browser, accDoc) { 153 let getAcc = id => findAccessibleChildByID(accDoc, id); 154 155 // //////////////////////////////////////////////////////////////////////// 156 // ARIA table 157 testGroupAttrs(getAcc("table_cell"), 3, 4); 158 testGroupAttrs(getAcc("table_row"), 2, 2); 159 160 // grid child item count provided by aria-rowcount 161 testGroupParentAttrs(getAcc("table"), 2, false); 162 // row child item count provided by parent grid's aria-colcount 163 testGroupParentAttrs(getAcc("table_row"), 4, false); 164 }, 165 { 166 topLevel: true, 167 iframe: true, 168 remoteIframe: true, 169 chrome: true, 170 } 171 ); 172 173 addAccessibleTask( 174 `<div role="grid" aria-readonly="true"> 175 <div tabindex="-1"> 176 <div role="row" id="wrapped_row_1"> 177 <div role="gridcell">cell content</div> 178 </div> 179 </div> 180 <div tabindex="-1"> 181 <div role="row" id="wrapped_row_2"> 182 <div role="gridcell">cell content</div> 183 </div> 184 </div> 185 </div>`, 186 async function (browser, accDoc) { 187 let getAcc = id => findAccessibleChildByID(accDoc, id); 188 189 // Attributes calculated even when row is wrapped in a div. 190 testGroupAttrs(getAcc("wrapped_row_1"), 1, 2, null); 191 testGroupAttrs(getAcc("wrapped_row_2"), 2, 2, null); 192 }, 193 { 194 topLevel: true, 195 iframe: true, 196 remoteIframe: true, 197 chrome: true, 198 } 199 ); 200 201 addAccessibleTask( 202 `<div role="list" aria-owns="t1_li1 t1_li2 t1_li3" id="aria-list_4"> 203 <div role="listitem" id="t1_li2">Apples</div> 204 <div role="listitem" id="t1_li1">Oranges</div> 205 </div> 206 <div role="listitem" id="t1_li3">Bananas</div>`, 207 async function (browser, accDoc) { 208 let getAcc = id => findAccessibleChildByID(accDoc, id); 209 210 // //////////////////////////////////////////////////////////////////////// 211 // ARIA list constructed by ARIA owns 212 testGroupAttrs(getAcc("t1_li1"), 1, 3); 213 testGroupAttrs(getAcc("t1_li2"), 2, 3); 214 testGroupAttrs(getAcc("t1_li3"), 3, 3); 215 testGroupParentAttrs(getAcc("aria-list_4"), 3, false); 216 }, 217 { 218 topLevel: true, 219 iframe: true, 220 remoteIframe: true, 221 chrome: true, 222 } 223 ); 224 225 addAccessibleTask( 226 `<!-- ARIA comments, 1 level, group pos and size calculation --> 227 <article> 228 <p id="comm_single_1" role="comment">Comment 1</p> 229 <p id="comm_single_2" role="comment">Comment 2</p> 230 </article> 231 232 <!-- Nested comments --> 233 <article> 234 <div id="comm_nested_1" role="comment"><p>Comment 1 level 1</p> 235 <div id="comm_nested_1_1" role="comment"><p>Comment 1 level 2</p></div> 236 <div id="comm_nested_1_2" role="comment"><p>Comment 2 level 2</p></div> 237 </div> 238 <div id="comm_nested_2" role="comment"><p>Comment 2 level 1</p> 239 <div id="comm_nested_2_1" role="comment"><p>Comment 3 level 2</p> 240 <div id="comm_nested_2_1_1" role="comment"><p>Comment 1 level 3</p></div> 241 </div> 242 </div> 243 <div id="comm_nested_3" role="comment"><p>Comment 3 level 1</p></div> 244 </article>`, 245 async function (browser, accDoc) { 246 let getAcc = id => findAccessibleChildByID(accDoc, id); 247 248 // Test group attributes of ARIA comments 249 testGroupAttrs(getAcc("comm_single_1"), 1, 2, 1); 250 testGroupAttrs(getAcc("comm_single_2"), 2, 2, 1); 251 testGroupAttrs(getAcc("comm_nested_1"), 1, 3, 1); 252 testGroupAttrs(getAcc("comm_nested_1_1"), 1, 2, 2); 253 testGroupAttrs(getAcc("comm_nested_1_2"), 2, 2, 2); 254 testGroupAttrs(getAcc("comm_nested_2"), 2, 3, 1); 255 testGroupAttrs(getAcc("comm_nested_2_1"), 1, 1, 2); 256 testGroupAttrs(getAcc("comm_nested_2_1_1"), 1, 1, 3); 257 testGroupAttrs(getAcc("comm_nested_3"), 3, 3, 1); 258 }, 259 { 260 topLevel: true, 261 iframe: true, 262 remoteIframe: true, 263 chrome: true, 264 } 265 ); 266 267 addAccessibleTask( 268 `<div role="tree" id="tree4"><div role="treeitem" 269 id="tree4_ti1">Item 1</div><div role="treeitem" 270 id="tree4_ti2">Item 2</div></div>`, 271 async function (browser, accDoc) { 272 let getAcc = id => findAccessibleChildByID(accDoc, id); 273 274 // Test that group position information updates after deleting node. 275 testGroupAttrs(getAcc("tree4_ti1"), 1, 2, 1); 276 testGroupAttrs(getAcc("tree4_ti2"), 2, 2, 1); 277 testGroupParentAttrs(getAcc("tree4"), 2, true); 278 279 let p = waitForEvent(EVENT_REORDER, "tree4"); 280 invokeContentTask(browser, [], () => { 281 content.document.getElementById("tree4_ti1").remove(); 282 }); 283 284 await p; 285 testGroupAttrs(getAcc("tree4_ti2"), 1, 1, 1); 286 testGroupParentAttrs(getAcc("tree4"), 1, true); 287 }, 288 { 289 topLevel: true, 290 iframe: true, 291 remoteIframe: true, 292 chrome: true, 293 } 294 ); 295 296 // Verify that intervening SECTION accs in ARIA compound widgets do not split 297 // up the group info for descendant owned elements. Test various types of 298 // widgets that should all be treated the same. 299 addAccessibleTask( 300 `<div role="tree" id="tree"> 301 <div tabindex="0"> 302 <div role="treeitem" id="ti1">treeitem 1</div> 303 </div> 304 <div tabindex="0"> 305 <div role="treeitem" id="ti2">treeitem 2</div> 306 </div> 307 </div> 308 <div role="listbox" id="listbox"> 309 <div tabindex="0"> 310 <div role="option" id="opt1">option 1</div> 311 </div> 312 <div tabindex="0"> 313 <div role="option" id="opt2">option 2</div> 314 </div> 315 </div> 316 <div role="list" id="list"> 317 <div tabindex="0"> 318 <div role="listitem" id="li1">listitem 1</div> 319 </div> 320 <div tabindex="0"> 321 <div role="listitem" id="li2">listitem 2</div> 322 </div> 323 </div> 324 <div role="menu" id="menu"> 325 <div tabindex="0"> 326 <div role="menuitem" id="mi1">menuitem 1</div> 327 </div> 328 <div tabindex="0"> 329 <div role="menuitem" id="mi2">menuitem 2</div> 330 </div> 331 </div> 332 <div role="radiogroup" id="radiogroup"> 333 <div tabindex="0"> 334 <div role="radio" id="r1">radio 1</div> 335 </div> 336 <div tabindex="0"> 337 <div role="radio" id="r2">radio 2</div> 338 </div> 339 </div> 340 `, 341 async function (browser, accDoc) { 342 let getAcc = id => findAccessibleChildByID(accDoc, id); 343 344 testGroupAttrs(getAcc("ti1"), 1, 2, 1); 345 testGroupAttrs(getAcc("ti2"), 2, 2, 1); 346 347 testGroupAttrs(getAcc("opt1"), 1, 2, 0); 348 testGroupAttrs(getAcc("opt2"), 2, 2, 0); 349 350 testGroupAttrs(getAcc("li1"), 1, 2, 0); 351 testGroupAttrs(getAcc("li2"), 2, 2, 0); 352 353 testGroupAttrs(getAcc("mi1"), 1, 2, 0); 354 testGroupAttrs(getAcc("mi2"), 2, 2, 0); 355 356 testGroupAttrs(getAcc("r1"), 1, 2, 0); 357 testGroupAttrs(getAcc("r2"), 2, 2, 0); 358 }, 359 { 360 topLevel: true, 361 iframe: true, 362 remoteIframe: true, 363 chrome: true, 364 } 365 ); 366 367 // Verify that non-generic accessibles (like buttons) correctly split the group 368 // info of descendant owned elements. 369 addAccessibleTask( 370 `<div role="tree" id="tree"> 371 <div role="button"> 372 <div role="treeitem" id="ti1">first</div> 373 </div> 374 <div tabindex="0"> 375 <div role="treeitem" id="ti2">second</div> 376 </div> 377 </div>`, 378 async function (browser, accDoc) { 379 let getAcc = id => findAccessibleChildByID(accDoc, id); 380 381 testGroupAttrs(getAcc("ti1"), 1, 1, 1); 382 testGroupAttrs(getAcc("ti2"), 1, 1, 1); 383 }, 384 { 385 topLevel: true, 386 iframe: true, 387 remoteIframe: true, 388 chrome: true, 389 } 390 );