[w3c/ServiceWorker] It's possible to interact with an installing service worker before its 'install' event is dispatched (#1347)

Consider the following code, which results in the installation of a new a new service worker:
```javascript
navigator.serviceWorker.register(script, scope)
  .then(registration => {
    registration.installing.postMessage('foo', []);
  };
```
In step 6 of Install, a promise resolution task is queued to the DOM manipulation queue; in step 10 a task that dispatches the 'install' event to the worker is queued. If the same queue is used, the `then` callback would run before the event is dispatch. (If it's a different queue, the user can't tell in which order these events would happen.)
This is pretty confusing, since a user might expect that an installing worker will have already been notified about it.

-- 
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/1347

Received on Tuesday, 21 August 2018 10:28:05 UTC