[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / fast / events / message-port-context-destroyed.html
1 <script>
2 if (window.layoutTestController) {
3     layoutTestController.dumpAsText();
4     layoutTestController.waitUntilDone();
5 }
6
7 var port;
8 var gc_stuff = new Array();
9
10 gc_and_crash = function() {
11     if (this.GCController)
12         GCController.collect();
13     else {
14         // V8 needs that many objects to run GC.
15         for(i = 0; i < 100000; i++) {
16             p = new Object();
17             gc_stuff.push(p);
18             gc_stuff.push(p + p);
19         }
20     }
21
22     // If the bug 43140 is regressed, this will crash, at least in v8-based ports.
23     port.start();
24
25     document.getElementById("log").innerText = "PASS";
26     if (window.layoutTestController)
27         layoutTestController.notifyDone();
28 }
29
30 function test() {
31     var iframe = document.getElementById("iframe");
32     var channel = new iframe.contentWindow.MessageChannel();
33     port = channel.port1;
34
35     iframe.onload = function() { gc_and_crash(); }
36     iframe.src = "data:text/html,<body>Hello!" ;
37 }
38 </script>
39 <body onload="test()">
40 <p>Test that MessagePort is properly closed when its owning context goes away. The test succeeds if it doesn't crash and prints "PASS" below. See https://bugs.webkit.org/show_bug.cgi?id=43140 for more details.</p>
41 <pre id=log></pre>
42 <iframe style="display:none" id=iframe></iframe>