Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / message-channel-gc-3.html
blob29577c44a8e8b2aac7309399cf8c2d9a637cd067
1 <body>
2 <p>Test that MessagePort messages are delivered even if both ports are inaccessible from JS any more.</p>
3 <p>Should say PASS twice.</p>
4 <pre id=log></pre>
5 <script>
6 function gc()
8 if (window.GCController)
9 return GCController.collect();
11 for (var i = 0; i < 10000; i++) { // > force garbage collection (FF requires about 9K allocations before a collect)
12 var s = new String("abc");
16 function log(message)
18 document.getElementById("log").innerHTML += message + "<br>";
21 if (window.testRunner) {
22 testRunner.dumpAsText();
23 testRunner.waitUntilDone();
26 function test1()
28 var channel = new MessageChannel;
30 channel.port1.onmessage = function(evt) { log("PASS: message delivered. Port: " + evt.target); test2(); }
31 channel.port2.postMessage("msg");
33 channel = 0;
34 gc();
37 function test2()
39 var channel = new MessageChannel;
41 channel.port2.close();
43 channel = 0;
44 gc();
45 log("PASS: port closed.");
46 if (window.testRunner)
47 testRunner.notifyDone();
50 test1();
52 </script>
53 </body>