blob: 29577c44a8e8b2aac7309399cf8c2d9a637cd067 [file] [log] [blame]
<body>
<p>Test that MessagePort messages are delivered even if both ports are inaccessible from JS any more.</p>
<p>Should say PASS twice.</p>
<pre id=log></pre>
<script>
function gc()
{
if (window.GCController)
return GCController.collect();
for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
var s = new String("abc");
}
}
function log(message)
{
document.getElementById("log").innerHTML += message + "<br>";
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function test1()
{
var channel = new MessageChannel;
channel.port1.onmessage = function(evt) { log("PASS: message delivered. Port: " + evt.target); test2(); }
channel.port2.postMessage("msg");
channel = 0;
gc();
}
function test2()
{
var channel = new MessageChannel;
channel.port2.close();
channel = 0;
gc();
log("PASS: port closed.");
if (window.testRunner)
testRunner.notifyDone();
}
test1();
</script>
</body>