blob: 29dff485e7fa45aacc3130ef3fd3a4e6736e7806 [file] [log] [blame]
<p>This page verifies that queued event listeners keep firing even after a node has been removed from the document.</p>
<p>If the test passes, you'll see a PASS message below.</p>
<pre id="console"></pre>
<div id="div"></div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
function log(s)
{
document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
}
var result = [ ];
function reportResult(expected)
{
var passed = true;
var end = result.length > expected.length ? result.length : expected.length;
for (var i = 0; i < end; ++i) {
if (result[i] != expected[i]) {
log("FAIL: " + name + " result[" + i + "] should be " + expected[i] + " but instead is " + result[i] + ".");
passed = false;
}
}
if (passed)
log("PASS: result should be " + expected + " and is.");
}
var div = document.getElementById("div");
div.addEventListener("click", function f1() {
result.push(arguments.callee.name);
div.parentNode.removeChild(div);
}, false);
div.addEventListener("click", function f2() {
result.push(arguments.callee.name);
}, false);
var event = document.createEvent("MouseEvent");
event.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, document);
div.dispatchEvent(event);
reportResult([ "f1", "f2" ]);
</script>