4 <title>Multi-Worker Test
</title>
6 <script src=
"worker_utils.js"></script>
10 var expected_total
= 0;
12 var completed_worker_count
= 0;
13 var total_workers
= 4;
15 function createWorker(base
) {
16 var worker
= getWorker("worker_common.js");
17 for (var i
= 0; i
< 100; i
++) {
18 worker
.postMessage("eval " + base
+ "+" + i
);
19 expected_total
+= base
+ i
;
21 worker
.postMessage("ping");
22 worker
.onmessage = function(evt
) {
23 if (evt
.data
== "pong") {
24 completed_worker_count
++;
25 if (completed_worker_count
== total_workers
) {
26 if (expected_total
== actual_total
)
33 actual_total
+= parseInt(evt
.data
);
42 for (var i
= 0; i
< total_workers
; ++i
) {
43 var worker
= createWorker(100 + i
);
50 <div id=statusPanel
></div>