browser_groupPosition.js (2993B)
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 /** 8 * Test exposure of group position information. 9 */ 10 addAccessibleTask( 11 ` 12 <ul> 13 <li id="li1">li1<ul> 14 <li id="li1a">li1a</li> 15 </ul></li> 16 <li id="li2">li2</li> 17 </ul> 18 <h2 id="h2">h2</h2> 19 <button id="button">button</button> 20 `, 21 async function testGroupPosition() { 22 let pos = await runPython(` 23 global doc, li1 24 doc = getDocIa2() 25 li1 = findIa2ByDomId(doc, "li1") 26 return li1.groupPosition 27 `); 28 SimpleTest.isDeeply(pos, [1, 2, 1], "li1 groupPosition correct"); 29 let attrs = await runPython(`li1.attributes`); 30 ok(!attrs.includes("posinset:"), "li1 doesn't have posinset attribute"); 31 ok(!attrs.includes("setsize:"), "li1 doesn't have setsize attribute"); 32 ok(!attrs.includes("level:"), "li1 doesn't have level attribute"); 33 34 pos = await runPython(` 35 global li1a 36 li1a = findIa2ByDomId(doc, "li1a") 37 return li1a.groupPosition 38 `); 39 SimpleTest.isDeeply(pos, [2, 1, 1], "li1a groupPosition correct"); 40 attrs = await runPython(`li1a.attributes`); 41 ok(!attrs.includes("posinset:"), "li1a doesn't have posinset attribute"); 42 ok(!attrs.includes("setsize:"), "li1a doesn't have setsize attribute"); 43 ok(!attrs.includes("level:"), "li1a doesn't have level attribute"); 44 45 pos = await runPython(` 46 global li2 47 li2 = findIa2ByDomId(doc, "li2") 48 return li2.groupPosition 49 `); 50 SimpleTest.isDeeply(pos, [1, 2, 2], "li2 groupPosition correct"); 51 attrs = await runPython(`li2.attributes`); 52 ok(!attrs.includes("posinset:"), "li2 doesn't have posinset attribute"); 53 ok(!attrs.includes("setsize:"), "li2 doesn't have setsize attribute"); 54 ok(!attrs.includes("level:"), "li2 doesn't have level attribute"); 55 56 pos = await runPython(` 57 global h2 58 h2 = findIa2ByDomId(doc, "h2") 59 return h2.groupPosition 60 `); 61 // IAccessible2 expects heading level to be exposed as an object attribute, 62 // not via groupPosition. 63 SimpleTest.isDeeply(pos, [0, 0, 0], "h2 groupPosition correct"); 64 attrs = await runPython(`h2.attributes`); 65 ok(!attrs.includes("posinset:"), "h2 doesn't have posinset attribute"); 66 ok(!attrs.includes("setsize:"), "h2 doesn't have setsize attribute"); 67 ok(attrs.includes("level:2;"), "h2 has level attribute 2"); 68 69 pos = await runPython(` 70 global button 71 button = findIa2ByDomId(doc, "button") 72 return button.groupPosition 73 `); 74 SimpleTest.isDeeply(pos, [0, 0, 0], "button groupPosition correct"); 75 attrs = await runPython(`button.attributes`); 76 ok(!attrs.includes("posinset:"), "button doesn't have posinset attribute"); 77 ok(!attrs.includes("setsize:"), "button doesn't have setsize attribute"); 78 ok(!attrs.includes("level:"), "button doesn't have level attribute"); 79 } 80 );