test_attrchange.html (2677B)
1 <html> 2 3 <head> 4 <title>Accessible attr change event testing</title> 5 6 <link rel="stylesheet" type="text/css" 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 11 <script type="application/javascript" 12 src="../common.js"></script> 13 <script type="application/javascript" 14 src="../promisified-events.js"></script> 15 <script type="application/javascript" 16 src="../role.js"></script> 17 <script type="application/javascript" 18 src="../states.js"></script> 19 20 <script type="application/javascript"> 21 async function testGotAttrChange(elem, name, value) { 22 const waitFor = waitForEvent(EVENT_OBJECT_ATTRIBUTE_CHANGED, elem); 23 if (value) { 24 document.getElementById(elem).setAttribute(name, value); 25 } else { 26 document.getElementById(elem).removeAttribute(name); 27 } 28 await waitFor; 29 } 30 31 async function doTests() { 32 info("Removing summary attr"); 33 // after summary is removed, we should have a layout table 34 await testGotAttrChange( 35 "sampleTable", 36 "summary", 37 null 38 ); 39 40 info("Setting abbr attr"); 41 // after abbr is set we should have a data table again 42 await testGotAttrChange( 43 "cellOne", 44 "abbr", 45 "hello world" 46 ); 47 48 info("Removing abbr attr"); 49 // after abbr is removed we should have a layout table again 50 await testGotAttrChange( 51 "cellOne", 52 "abbr", 53 null 54 ); 55 56 info("Setting scope attr"); 57 // after scope is set we should have a data table again 58 await testGotAttrChange( 59 "cellOne", 60 "scope", 61 "col" 62 ); 63 64 info("Removing scope attr"); 65 // remove scope should give layout 66 await testGotAttrChange( 67 "cellOne", 68 "scope", 69 null 70 ); 71 72 info("Setting headers attr"); 73 // add headers attr should give data 74 await testGotAttrChange( 75 "cellThree", 76 "headers", 77 "cellOne" 78 ); 79 80 info("Removing headers attr"); 81 // remove headers attr should give layout 82 await testGotAttrChange( 83 "cellThree", 84 "headers", 85 null 86 ); 87 88 SimpleTest.finish(); 89 } 90 91 SimpleTest.waitForExplicitFinish(); 92 addA11yLoadEvent(doTests); 93 </script> 94 </head> 95 <body> 96 <table id="sampleTable" summary="example summary"> 97 <tr> 98 <td id="cellOne">cell1</td> 99 <td>cell2</td> 100 </tr> 101 <tr> 102 <td id="cellThree">cell3</td> 103 <td>cell4</td> 104 </tr> 105 </table> 106 </body> 107 </html>