[w3c/ServiceWorker] resurrected service workers don't fire an activate event which may break expectations (#1204)

Consider a service worker that looks like this:

```
self.addEventListener('activate', evt => evt.waitUntil(clients.claim()));
```

And then a main page that waits for a window to be controlled:

```
navigator.serviceWorker.register('sw.js');
await waitForControlled(existingWindow);
```

This works fine if the SW is installed fresh.  If the registration resurrects a service worker that was previously unregistered, then this code will break.  The activate event will not fire and the claim() will not occur.

Should we consider firing another `activate` event or some other new event when the service worker is resurrected like this?  It seems that the intent of restoring the SW to the active slot is that it should be equivalent to registering the new worker.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1204

Received on Friday, 6 October 2017 20:38:00 UTC