[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / fast / events / message-channel-gc-3.html
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()
7 {
8     if (window.GCController)
9         return GCController.collect();
10
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");
13     }
14 }
15
16 function log(message)
17 {
18     document.getElementById("log").innerHTML += message + "<br>";
19 }
20
21 if (window.layoutTestController) {
22     layoutTestController.dumpAsText();
23     layoutTestController.waitUntilDone();
24 }
25
26 function test1()
27 {
28     var channel = new MessageChannel;
29
30     channel.port1.onmessage = function(evt) { log("PASS: message delivered. Port: " + evt.target); test2(); }
31     channel.port2.postMessage("msg");
32
33     channel = 0;
34     gc();
35 }
36
37 function test2()
38 {
39     var channel = new MessageChannel;
40
41     channel.port2.close();
42
43     channel = 0;
44     gc();
45     log("PASS: port closed.");
46     if (window.layoutTestController)
47         layoutTestController.notifyDone();
48 }
49
50 test1();
51
52 </script>
53 </body>