[slightlyoff/ServiceWorker] be more explicit that jobs always run asynchronously (#861)

Previously @mattto stated that Chrome always run jobs asynchronously.  The spec is a bit fuzzy on this saying things like:

> If job’s job type is register, invoke Register with job and continue running these steps in parallel. 

This suggests that perhaps Register gets to keep running sync and then the current steps are completed potentially in parallel.

I think it would be better for Run Job to explicitly queue a task to invoke the algorithm for the job.

This matters for things like:

```
registration.unregister().then(function() {
  var p =navigator.serviceWorker.register(urlThat404s, scope: registration.scope)

  // Removing last controlled client would allow registration with uninstalling flag to
  // be purged.
  controlledFrame.remove();

  return p;
}).then(function() {
  // if register can run its initial steps sync, then it can clear the uninstalling
  // flag before the controlled client is removed.  This results in the original
  //  service worker script remaining active.

  // If register always runs async, then the controlled client is always removed
  // before the uninstalling flag could be cleared.  This results in no registration
  // being present since the new script 404s.
});
```

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

Received on Tuesday, 29 March 2016 18:41:24 UTC