diff options
Diffstat (limited to 'accessible/tests/mochitest/events/test_attrchange.html')
-rw-r--r-- | accessible/tests/mochitest/events/test_attrchange.html | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/accessible/tests/mochitest/events/test_attrchange.html b/accessible/tests/mochitest/events/test_attrchange.html new file mode 100644 index 0000000000..bd2c68bac3 --- /dev/null +++ b/accessible/tests/mochitest/events/test_attrchange.html @@ -0,0 +1,107 @@ +<html> + +<head> + <title>Accessible attr change event testing</title> + + <link rel="stylesheet" type="text/css" + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> + + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + + <script type="application/javascript" + src="../common.js"></script> + <script type="application/javascript" + src="../promisified-events.js"></script> + <script type="application/javascript" + src="../role.js"></script> + <script type="application/javascript" + src="../states.js"></script> + + <script type="application/javascript"> + async function testGotAttrChange(elem, name, value) { + const waitFor = waitForEvent(EVENT_OBJECT_ATTRIBUTE_CHANGED, elem); + if (value) { + document.getElementById(elem).setAttribute(name, value); + } else { + document.getElementById(elem).removeAttribute(name); + } + await waitFor; + } + + async function doTests() { + info("Removing summary attr"); + // after summary is removed, we should have a layout table + await testGotAttrChange( + "sampleTable", + "summary", + null + ); + + info("Setting abbr attr"); + // after abbr is set we should have a data table again + await testGotAttrChange( + "cellOne", + "abbr", + "hello world" + ); + + info("Removing abbr attr"); + // after abbr is removed we should have a layout table again + await testGotAttrChange( + "cellOne", + "abbr", + null + ); + + info("Setting scope attr"); + // after scope is set we should have a data table again + await testGotAttrChange( + "cellOne", + "scope", + "col" + ); + + info("Removing scope attr"); + // remove scope should give layout + await testGotAttrChange( + "cellOne", + "scope", + null + ); + + info("Setting headers attr"); + // add headers attr should give data + await testGotAttrChange( + "cellThree", + "headers", + "cellOne" + ); + + info("Removing headers attr"); + // remove headers attr should give layout + await testGotAttrChange( + "cellThree", + "headers", + null + ); + + SimpleTest.finish(); + } + + SimpleTest.waitForExplicitFinish(); + addA11yLoadEvent(doTests); + </script> +</head> +<body> + <table id="sampleTable" summary="example summary"> + <tr role="presentation"> + <td id="cellOne">cell1</td> + <td>cell2</td> + </tr> + <tr> + <td id="cellThree">cell3</td> + <td>cell4</td> + </tr> + </table> +</body> +</html> |