OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 if ('onmessage' in self) { // dedicated worker |
| 3 onmessage = function(e) { |
| 4 postMessage(e.data); |
| 5 } |
| 6 } else { // shared worker |
| 7 onconnect = function(e) { |
| 8 e.ports[0].onmessage = function(e) { |
| 9 this.postMessage(e.data); |
| 10 } |
| 11 } |
| 12 } |
| 13 /* |
| 14 --> |
| 15 <!doctype html> |
| 16 <title>dedicated and shared worker in same page</title> |
| 17 <script src="/resources/testharness.js"></script> |
| 18 <script src="/resources/testharnessreport.js"></script> |
| 19 <div id=log></div> |
| 20 <script> |
| 21 async_test(function() { |
| 22 var worker = new Worker('#'); |
| 23 worker.onmessage = this.step_func(function(e) { |
| 24 assert_equals(e.data, 'dedicated'); |
| 25 this.done(); |
| 26 }); |
| 27 worker.postMessage('dedicated'); |
| 28 }, 'dedicated'); |
| 29 async_test(function() { |
| 30 var shared = new SharedWorker('#', ''); |
| 31 shared.port.onmessage = this.step_func(function(e) { |
| 32 assert_equals(e.data, 'shared'); |
| 33 this.done(); |
| 34 }); |
| 35 shared.port.postMessage('shared'); |
| 36 }, 'shared'); |
| 37 </script> |
| 38 <!-- |
| 39 */ |
| 40 //--> |
| 41 |
OLD | NEW |