Skip to content

Commit

Permalink
service worker: skipWaiting() should resolve after activation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfalken committed Jun 19, 2018
1 parent 0007ac4 commit 2aeeed0
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
var saw_activate_event = false

self.addEventListener('activate', function() {
saw_activate_event = true;
});

self.addEventListener('message', function(event) {
var port = event.data.port;
event.waitUntil(self.skipWaiting()
Expand All @@ -13,15 +7,9 @@ self.addEventListener('message', function(event) {
return;
}

if (!saw_activate_event) {
port.postMessage(
'FAIL: Promise should be resolved after activate event is dispatched');
return;
}

if (self.registration.active.state !== 'activating') {
if (self.registration.active.state !== 'activated') {
port.postMessage(
'FAITL: Promise should be resolved before ServiceWorker#state is set to activated');
'FAIL: Promise should be resolved after ServiceWorker#state is set to activated');
return;
}

Expand Down

0 comments on commit 2aeeed0

Please sign in to comment.