test_listbox.html (2516B)
1 <html> 2 3 <head> 4 <title>Listbox group attribute tests</title> 5 <meta charset="utf-8" /> 6 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 7 8 <script 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="../attributes.js"></script> 14 <script type="application/javascript" 15 src="../promisified-events.js"></script> 16 17 <script type="application/javascript"> 18 async function doTest() { 19 // First test the whole lot. 20 testGroupAttrs("a", 1, 6); 21 testGroupAttrs("b", 2, 6); 22 testGroupAttrs("c", 3, 6); 23 testGroupAttrs("d", 4, 6); 24 testGroupAttrs("e", 5, 6); 25 testGroupAttrs("f", 6, 6); 26 // Remove c, reducing the set to 5. 27 let listbox = getAccessible("listbox"); 28 let updated = waitForEvent(EVENT_REORDER, listbox); 29 c.remove(); 30 await updated; 31 testGroupAttrs("a", 1, 5); 32 testGroupAttrs("b", 2, 5); 33 testGroupAttrs("d", 3, 5); 34 testGroupAttrs("e", 4, 5); 35 testGroupAttrs("f", 5, 5); 36 // Now, remove the first element. 37 updated = waitForEvent(EVENT_REORDER, listbox); 38 a.remove(); 39 await updated; 40 testGroupAttrs("b", 1, 4); 41 testGroupAttrs("d", 2, 4); 42 testGroupAttrs("e", 3, 4); 43 testGroupAttrs("f", 4, 4); 44 // Remove the last item. 45 updated = waitForEvent(EVENT_REORDER, listbox); 46 f.remove(); 47 await updated; 48 testGroupAttrs("b", 1, 3); 49 testGroupAttrs("d", 2, 3); 50 testGroupAttrs("e", 3, 3); 51 // Finally, remove the middle item. 52 updated = waitForEvent(EVENT_REORDER, listbox); 53 d.remove(); 54 await updated; 55 testGroupAttrs("b", 1, 2); 56 testGroupAttrs("e", 2, 2); 57 58 SimpleTest.finish(); 59 } 60 61 SimpleTest.waitForExplicitFinish(); 62 addA11yLoadEvent(doTest); 63 </script> 64 </head> 65 <body> 66 <p id="display"></p> 67 <div id="content" style="display: none"></div> 68 <pre id="test"> 69 </pre> 70 71 <!-- Group information updated after removal of list items, bug 1515186 --> 72 <div id="listbox" role="listbox"> 73 <div id="a" role="option">Option a</div> 74 <div id="b" role="option">Option b</div> 75 <div id="c" role="option">Option c</div> 76 <div id="d" role="option">Option d</div> 77 <div id="e" role="option">Option e</div> 78 <div id="f" role="option">Option f</div> 79 </div> 80 81 </body> 82 </html>