Re: [ServiceWorker] Accessing service worker state from worker (#674)

The [_service worker_](http://localhost/spec/service_worker/#dfn-service-worker-global-scope-service-worker) referenced in the step 1 of `clients.claim` is associated with the `ServiceWorkerGlobalScope` object in which the method is running. Although the state of the _service worker_ is being accessed/changed by other steps in the main thread and algorithm threads, the _service worker_'s state the method is checking is that of the one associated with the global object.

So, in your example, the `self.claim`'s success/failure depends on the current state of the _service worker_. For instance, if it was a fresh Register attempt, it'll fail as the state of the worker must be `installing`. On the other hand, it'll succeed if it was an Update attempt on an active worker.

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

Received on Tuesday, 7 April 2015 01:35:26 UTC