[w3c/ServiceWorker] `Clear Registration` should call `Update Registration State` before `Update Worker State` (#1270)

We have two different algorithms for updating DOM objects on their various javascript threads:

* `Update Worker State` sets the DOM object's `.state` value and fires a `statechange` event.
* `Update Registration State` sets the DOM object's `.installing`, `.waiting`, and `.active` properties.  It does not fire an event.

Both of these algorithms independently queue tasks to do the DOM object modifications.

In nearly all cases in the spec `Update Registration State` occurs before `Update Worker State`.  This is good because it means the registration DOM objects will be in a consistent state the `statechange` event fires.

The `Clear Registration` algorithm, though, does things in the reverse order.  It calls `Update Worker State` for moving each worker to the redundant state.  It then calls `Update Registration State` afterwards to clear its reference on the registration DOM object.

I think this is wrong because it means the `statechange` event to redundant will fire while the worker is still visible on the registration.

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

Received on Thursday, 1 February 2018 18:30:35 UTC