[WK2] selection does not disappear after coping the text
[framework/web/webkit-efl.git] / LayoutTests / fast / workers / worker-messageport-gc.html
1 <body>
2 <p>Test that workers stay reachable via message ports.
3 Should print "DONE" when done.</p>
4 <div id=result></div>
5 <script>
6 function log(message)
7 {
8     document.getElementById("result").innerHTML += message + "<br>";
9 }
10
11 if (window.layoutTestController) {
12     layoutTestController.dumpAsText();
13     layoutTestController.waitUntilDone();
14 }
15
16 // Test that workers stay alive even though they are only reachable via message ports.
17 var worker = new Worker("resources/worker-messageport.js");
18 var channel = new MessageChannel();
19 worker.postMessage("port", [channel.port1]);
20 worker = 0;
21
22 channel.port2.postMessage("ping");
23 channel.port2.onmessage = function(evt) {
24     // Other side is running, now force a GC, wait a bit, and send a new message to make sure it arrives.
25     gc();
26     setTimeout(testReachable, 100);
27 }
28
29 function testReachable()
30 {
31     channel.port2.onmessage = function(evt) {
32         log("PASS: Worker is reachable.");
33         done();
34     }
35     channel.port2.postMessage("ping");
36 }
37
38 function gc()
39 {
40     if (window.GCController)
41         return GCController.collect();
42
43     for (var i = 0; i < 10000; i++) { // force garbage collection (FF requires about 9K allocations before a collect)
44         var s = new String("abc");
45     }
46 }
47
48 function done()
49 {
50     log("DONE");
51     if (window.layoutTestController)
52         layoutTestController.notifyDone();
53 }
54
55 </script>
56 </body>
57 </html>
58