[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / fast / events / message-channel-gc.html
1 <body>
2 <p>Test some cases of MessagePort garbage collection.</p>
3 <pre id=log></pre>
4 <script>
5 function gc()
6 {
7     if (window.GCController)
8         return GCController.collect();
9
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");
12     }
13 }
14
15 function log(message)
16 {
17     document.getElementById("log").innerHTML += message + "<br>";
18 }
19
20 function done()
21 {
22     channel.port1.close();
23     channel.port2.close();
24
25     gc();
26
27     log("DONE");
28     if (window.layoutTestController)
29         layoutTestController.notifyDone();
30 }
31
32 if (window.layoutTestController) {
33     layoutTestController.dumpAsText();
34     layoutTestController.waitUntilDone();
35 }
36
37 var channel = new MessageChannel;
38 channel.port1.foo = "bar";
39
40 gc();
41 log("Should be 'bar': " + channel.port1.foo);
42
43 channel.port1.onmessage = function() { log("onmessage"); }
44 channel.port1.addEventListener("message", function() { log("message listener"); done(); }, false);
45
46 gc();
47 channel.port1.start();
48 channel.port2.postMessage("msg");
49
50 gc();
51
52 </script>
53 </body>