Fix build break
[chromium-blink-merge.git] / content / test / data / workers / queued_shared_worker_shutdown.html
blob03daff1d04205190f27dd6e0a6c0a96b44b1a68b
1 <html>
2 <head>
3 <script src="worker_utils.js"></script>
4 </head>
5 <body>
6 <div id=result></div>
7 <script>
8 function log(message)
10 document.getElementById("result").innerHTML += message + "<br>";
13 var url = document.location.toString();
14 var num_workers = parseInt(url.substr(url.search("count=") + 6));
16 if (!num_workers) {
17 log("No count= parameter provided - test aborted");
18 } else {
19 for (var i = 0; i < num_workers ; ++i) {
20 createWorker(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() {
34 workers_created++;
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");
44 onSuccess();
48 </script>
50 </body>
51 </html>