[ServiceWorker] Add an API to take over uncontrolled pages (or pages controlled by another service worker) (#586)

This used to be part of `installEvent.replace()`, but we've separated out the skip-waiting part into `self.skipWaiting`, but we still need the other part.

Loosely, this would:

1. If this worker isn't active, either wait or reject (TODO: not sure what's best yet)
1. For each client
  1. Let registration be the result of "Match Service Worker Registration" for that client
  1. If registration is not the registration already in use by the client:
    1. If registration is this serviceworker's registration:
      1. Make the client use registration, fire `controllerchange` event
1. Resolve promise with undefined

Need to have a think about step 1. Also, maybe it should resolve true/false depending on if anything actually changed.

@slightlyoff suggested `clients.claim()` as a API name/location, which works for me.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/586

Received on Wednesday, 10 December 2014 18:52:06 UTC