Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / test / data / workers / multi_worker.html
blob46cc3c674b9c52366fa8b739cea4baa8a7c80a2f
1 <html>
3 <head>
4 <title>Multi-Worker Test</title>
6 <script src="worker_utils.js"></script>
8 <script>
10 var expected_total = 0;
11 var actual_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)
27 onSuccess();
28 else
29 onFailure();
31 } else {
32 try {
33 actual_total += parseInt(evt.data);
34 } catch (ex) {
35 onFailure();
39 return worker;
42 for (var i = 0; i < total_workers; ++i) {
43 var worker = createWorker(100 + i);
46 </script>
47 </head>
49 <body>
50 <div id=statusPanel></div>
51 </body>
52 </html>