blob: 1b3909edaddf007799c6ba394929c2aefb124401 [file] [log] [blame]
<div id="div"></div>
<p> Test for bug <a href="">34231</a>: Nodes in XPath result snapshots should keep JS wrappers alive.</p>
<p>This page tests for proper invalidation of a node's event listeners. If the test passes, you'll see a PASS message below.</p>
<pre id="console">FAILED: Test did not run.</pre>
function $(id)
return document.getElementById(id);
function log(s)
$('console').innerHTML = s + '\n';
function allocate() {
for (var i = 0; i < 3000; ++i)
(function () {
if (window.testRunner)
// Fill the heap with event listeners...
var a = []
for (var i = 0; i < 5000; ++i)
a[a.length] = function() { };
// ...followed by a DOM node wrapper
var div = $("div");
// Add the listeners to the DOM node.
for (var i = 0; i < a.length; ++i)
div.addEventListener("click", a[i], false);
// Eliminate JS references to the div and its listeners, but keep a reference to the div in an XPath query.
var query = document.evaluate("//div", document.documentElement, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
div = null
a = null;
// Potentially overwrite listeners with strings, but don't overwrite div.
// Fire listeners and see if we crash.
var event = document.createEvent('MouseEvent');
event.initEvent('click', true, true);
log("PASS: You didn't crash.");