3 <script src=
"worker_utils.js"></script>
10 document
.getElementById("result").innerHTML
+= message
+ "<br>";
13 var url
= document
.location
.toString();
14 var num_workers
= parseInt(url
.substr(url
.search("count=") + 6));
17 log("No count= parameter provided - test aborted");
19 for (var i
= 0; i
< num_workers
; ++i
) {
23 // Create two extra workers - these should both be queued, and launched as a
24 // single instance when we shutdown a worker.
25 createWorker(num_workers
);
26 createWorker(num_workers
);
29 var workers_created
= 0;
30 function createWorker(i
) {
31 var worker
= new SharedWorker("worker_common.js?id=" + i
);
32 worker
.port
.postMessage("ping");
33 worker
.port
.onmessage = function() {
35 log("worker " + i
+ " started");
36 if (workers_created
== num_workers
) {
37 // We've created all of our workers. Let's shut down the most recent one
38 // and see if we startup the queued worker.
39 log("Shutting down worker " + i
);
40 worker
.port
.postMessage("close");
41 } else if (workers_created
== (num_workers
+2)) {
42 // created the last worker
43 log("SUCCESS: queued worker created");