<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var port;
var gc_stuff = new Array();
gc_and_crash = function() {
if (this.GCController)
GCController.collect();
else {
// V8 needs that many objects to run GC.
for(i = 0; i < 100000; i++) {
p = new Object();
gc_stuff.push(p);
gc_stuff.push(p + p);
}
}
// If the bug 43140 is regressed, this will crash, at least in v8-based ports.
port.start();
document.getElementById("log").innerText = "PASS";
if (window.testRunner)
testRunner.notifyDone();
}
function test() {
var iframe = document.getElementById("iframe");
var channel = new iframe.contentWindow.MessageChannel();
port = channel.port1;
iframe.onload = function() { gc_and_crash(); }
iframe.src = "data:text/html,<body>Hello!" ;
}
</script>
<body onload="test()">
<p>Test that MessagePort is properly closed when its owning context goes away. The test succeeds if it doesn't crash and prints "PASS" below. See https://bugs.webkit.org/show_bug.cgi?id=43140 for more details.</p>
<pre id=log></pre>
<iframe style="display:none" id=iframe></iframe>