Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<html>
<head>
<title>Accessible attr change event testing</title>
<link rel="stylesheet" type="text/css"
<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>
<td id="cellOne">cell1</td>
<td>cell2</td>
</tr>
<tr>
<td id="cellThree">cell3</td>
<td>cell4</td>
</tr>
</table>
</body>
</html>