blob: 416193b3886f9aa59b82e9310755c1cf9900010b [file] [log] [blame]
<script>
function test()
{
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var counter = 0;
var worker = new Worker("resources/wrapper-map-gc.js");
// Post the message from worker back to the worker.
// This will fire another onmessage event in the Worker and allocate more data.
worker.onmessage = function(evt)
{
worker.postMessage(evt.data);
// This appears to be enough to reliably trigger GC in a Worker (about 20Mb strings allocated).
if (++counter > 20) {
document.getElementById("result").innerText = "PASS";
worker.terminate();
if (window.testRunner) {
testRunner.notifyDone();
}
}
}
}
</script>
<body onload=test()>
<p>This test tries to cause GC in Worker context. It also fires events in the Worker, which allocates JS DOM Wrappers for Event object. As a result of GC, the maps that map wrappers to DOM Objects will be cleaned up. Test succeeds if it does not crash and prints 'PASS' at the end.</p>
<pre id="result"></pre>
</body>
</html>