OLD | NEW |
(Empty) | |
| 1 self.state = 'starting'; |
| 2 |
| 3 self.addEventListener('install', function() { |
| 4 self.state = 'installing'; |
| 5 }); |
| 6 |
| 7 self.addEventListener('activate', function() { |
| 8 self.state = 'activating'; |
| 9 }); |
| 10 |
| 11 self.addEventListener('message', function(event) { |
| 12 var port = event.data.port; |
| 13 if (self.state !== 'installing') { |
| 14 port.postMessage('FAIL: Worker should be waiting in installed state'); |
| 15 return; |
| 16 } |
| 17 self.skipWaiting() |
| 18 .then(function(result) { |
| 19 if (result !== undefined) { |
| 20 port.postMessage('FAIL: Promise should be resolved with undefined'); |
| 21 return; |
| 22 } |
| 23 if (self.state !== 'activating') { |
| 24 port.postMessage( |
| 25 'FAIL: Promise should be resolved after worker activated'); |
| 26 return; |
| 27 } |
| 28 port.postMessage('PASS'); |
| 29 }) |
| 30 .catch(function(e) { |
| 31 port.postMessage('FAIL: unexpected exception: ' + e); |
| 32 }); |
| 33 }); |
OLD | NEW |