66 lines
1.4 KiB
HTML
66 lines
1.4 KiB
HTML
<p>This page tests for a bogus invalidation of a node's event listeners. If the
|
|
test passes, you'll see a PASS message below.</p>
|
|
<pre id="console"></pre>
|
|
|
|
<div id="div"></div>
|
|
|
|
<script>
|
|
function $(id)
|
|
{
|
|
return document.getElementById(id);
|
|
}
|
|
|
|
function log(s)
|
|
{
|
|
$('console').appendChild(document.createTextNode(s + '\n'));
|
|
}
|
|
|
|
function shouldBe(aDescription, a, b)
|
|
{
|
|
if (a === b) {
|
|
log("PASS: " + aDescription + " should be " + b + " and is.");
|
|
return;
|
|
}
|
|
log("FAIL: " + aDescription + " should be " + b + " but instead is " + a);
|
|
}
|
|
|
|
function allocate() {
|
|
for (var i = 0; i < 5000; ++i)
|
|
new Object;
|
|
}
|
|
|
|
(function () {
|
|
if (window.testRunner) {
|
|
testRunner.dumpAsText();
|
|
testRunner.waitUntilDone();
|
|
}
|
|
|
|
var listener = function () { return "click"; };
|
|
|
|
// Fill the heap with garbage...
|
|
var a = []
|
|
for (var i = 0; i < 5000; ++i)
|
|
a[a.length] = new Object;
|
|
|
|
// ...followed by a DOM node wrapper.
|
|
$("div");
|
|
a = null;
|
|
|
|
// Move the allocation pointer up to the DOM node wrapper.
|
|
allocate();
|
|
|
|
// Make a new DOM node wrapper, and add an event listener.
|
|
$("div").onclick = listener;
|
|
|
|
// Collect the original DOM node wrapper.
|
|
for (var i = 0; i < 3; ++i)
|
|
allocate();
|
|
|
|
// See if the listener is still registered.
|
|
shouldBe("div.onclick", div.onclick, listener);
|
|
|
|
if (window.testRunner)
|
|
testRunner.notifyDone();
|
|
})();
|
|
</script>
|