blob: 22accfcc04bdfcd4d3df06a60685416c5f15f40e [file] [log] [blame]
<body>
<p>Test that destroying a frame doesn't cause a crash when posting a message to a MessagePort it owned.</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();
}
var mainPort;
var frameDoc;
function test()
{
frameDoc = window.frames[0].document;
var channel = new MessageChannel;
window.frames[0].postMessage("msg", "*", [channel.port2]);
mainPort = channel.port1;
mainPort.start();
mainPort.postMessage("ping");
mainPort.onmessage = test2;
}
function test2()
{
var frameElement = document.getElementsByTagName("iframe")[0];
frameElement.parentNode.removeChild(frameElement);
frameElement = null;
gc();
setTimeout(test3, 10);
}
function test3()
{
gc();
mainPort.postMessage("ping");
mainPort.onmessage = function(evt) {
if (evt.data == "pong")
log("Unexpected response: FAIL");
};
setTimeout(test4, 10);
}
function test4()
{
log("Didn't crash: SUCCESS");
if (window.testRunner)
testRunner.notifyDone();
}
</script>
<iframe src="resources/message-port-iframe.html" onload="test()"></iframe>
</body>