Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / message-port-inactive-document.html
blob23f7fb6301b0c82abb5a952c7dc3beda2d996f3b
1 <body>
2 <p>Test that messaging an inactive frameless document works as expected.</p>
3 <pre id=log></pre>
4 <script>
5 function gc()
7 if (window.GCController)
8 return GCController.collect();
10 for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
11 var s = new String("abc");
15 function log(message)
17 document.getElementById("log").innerHTML += message + "<br>";
20 if (window.testRunner) {
21 testRunner.dumpAsText();
22 testRunner.waitUntilDone();
25 var otherDocument;
26 var mainPort;
28 function test()
30 otherDocument = window.frames[0].document;
31 var channel = new MessageChannel;
32 window.frames[0].postMessage("msg", [channel.port2], "*");
33 mainPort = channel.port1;
34 mainPort.start();
36 mainPort.postMessage("ping");
37 mainPort.onmessage = test2;
40 function test2()
42 var frameElement = document.getElementsByTagName("iframe")[0];
43 frameElement.src = "resources/window-opened.html";
44 frameElement.onload = test3;
45 gc();
48 function test3()
50 gc();
51 mainPort.postMessage("alert FAIL: the document is inactive.");
52 mainPort.postMessage("freeze");
53 mainPort.postMessage("ping");
54 mainPort.onmessage = function(evt) {
55 log("Unexpected response: FAIL");
57 setTimeout(test4, 10);
60 function test4()
62 mainPort.close();
64 log("Didn't crash, freeze or respond: SUCCESS");
66 if (window.testRunner)
67 testRunner.notifyDone();
70 </script>
71 <iframe src="resources/message-port-iframe.html" onload="test()" width=0 height=0 frameborder=0></iframe>
72 </body>