2 <p>Test that workers stay reachable via message ports.
3 Should print
"DONE" when done.
</p>
8 document
.getElementById("result").innerHTML
+= message
+ "<br>";
11 if (window
.testRunner
) {
12 testRunner
.dumpAsText();
13 testRunner
.waitUntilDone();
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
]);
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.
26 setTimeout(testReachable
, 100);
29 function testReachable()
31 channel
.port2
.onmessage = function(evt
) {
32 log("PASS: Worker is reachable.");
35 channel
.port2
.postMessage("ping");
40 if (window
.GCController
)
41 return GCController
.collectAll();
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");
51 if (window
.testRunner
)
52 testRunner
.notifyDone();