blob: d7c81a7584412ef4a8a174383be66d1425d9bd3c [file] [log] [blame]
<body>
<p>Test that messaging an inactive frameless document works as expected.</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 otherDocument;
var mainPort;
function test()
{
otherDocument = 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.src = "resources/window-opened.html";
frameElement.onload = test3;
gc();
}
function test3()
{
gc();
mainPort.postMessage("alert FAIL: the document is inactive.");
mainPort.postMessage("freeze");
mainPort.postMessage("ping");
mainPort.onmessage = function(evt) {
log("Unexpected response: FAIL");
};
setTimeout(test4, 10);
}
function test4()
{
mainPort.close();
log("Didn't crash, freeze or respond: SUCCESS");
if (window.testRunner)
testRunner.notifyDone();
}
</script>
<iframe src="resources/message-port-iframe.html" onload="test()" width=0 height=0 frameborder=0></iframe>
</body>