blob: 77e4717ab20a7280cc0969ad97980379b3da6942 [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.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.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.layoutTestController)
layoutTestController.notifyDone();
}
test1();
</script>
</body>