2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / events / message-channel-gc-2.html
blobe0b734727ac8d3043272854cc10941caf6cf91b7
1 <body>
2 <p>Test that MessagePort close event gets delivered (without crashing) even if the channel object is garbage collected.</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.layoutTestController) {
21 layoutTestController.dumpAsText();
22 layoutTestController.waitUntilDone();
25 var channel = new MessageChannel;
27 channel.port1.onclose = function() { log("onclose"); setTimeout(function() { if (window.layoutTestController) layoutTestController.notifyDone(); gc(); }, 0) }
28 channel.port1.addEventListener("close", function() { log("close listener"); gc(); }, false);
30 gc();
31 channel.port1.start();
32 channel.port2.postMessage("msg");
34 gc();
35 channel.port1.close();
36 channel.port2.close();
37 gc();
38 channel = new MessageChannel;
39 gc();
40 </script>
41 </body>