1 self
.state
= 'starting';
3 self
.addEventListener('install', function() {
4 self
.state
= 'installing';
7 self
.addEventListener('activate', function() {
8 self
.state
= 'activating';
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');
18 .then(function(result
) {
19 if (result
!== undefined) {
20 port
.postMessage('FAIL: Promise should be resolved with undefined');
23 if (self
.state
!== 'activating') {
25 'FAIL: Promise should be resolved after worker activated');
28 port
.postMessage('PASS');
31 port
.postMessage('FAIL: unexpected exception: ' + e
);