Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<html>
<head>
<title>ARIA alert event testing</title>
<link rel="stylesheet" type="text/css"
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../states.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
// //////////////////////////////////////////////////////////////////////////
// Do tests
// enableLogging("tree,events,verbose");
async function doTests() {
let alerted = waitForEvent(EVENT_ALERT, "alert");
let div = document.createElement("div");
div.setAttribute("role", "alert");
div.setAttribute("id", "alert");
div.appendChild(document.createTextNode("alert"));
document.body.appendChild(div);
await alerted;
alerted = waitForEvent(EVENT_ALERT, "alert");
getNode("alert").textContent = "new alert";
await alerted;
// Regression test for Coverity CID 1473402: the "inside alert" context
// flag must propagate to descendants, so inserting content into a nested
// (non-alert) descendant of an existing alert must still fire EVENT_ALERT
// on the alert ancestor.
let nestedAlert = document.createElement("div");
nestedAlert.setAttribute("role", "alert");
nestedAlert.setAttribute("id", "nestedAlert");
let inner = document.createElement("div");
inner.setAttribute("role", "group");
inner.setAttribute("id", "inner");
nestedAlert.appendChild(inner);
// Showing the alert subtree fires EVENT_ALERT via the show path.
alerted = waitForEvent(EVENT_ALERT, "nestedAlert");
document.body.appendChild(nestedAlert);
await alerted;
// Inserting into the nested descendant must fire EVENT_ALERT too; this
// relies on the inside-alert flag set when "inner" was bound to its
// parent. Before the fix the flag was never set, so no event fired here.
alerted = waitForEvent(EVENT_ALERT, "nestedAlert");
getNode("inner").appendChild(document.createTextNode("nested alert content"));
await alerted;
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
title="mochitest for bug 334386: fire alert event when ARIA alert is shown or new its children are inserted">
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
</html>