[w3c/ServiceWorker] Handle UA shutdown algorithm always invokes clear reg if we have installing worker (#1063)

Considering the following behavior as per [2.6 User Agent Shutdown](https://w3c.github.io/ServiceWorker/#user-agent-shutdown):
- An installing worker does not persist but discarded. If the installing worker was the only service worker for the service worker registration, the service worker registration is discarded.

However, the [User Agent Shutdown Algorithm](https://w3c.github.io/ServiceWorker/#on-user-agent-shutdown-algorithm) states:
1. If _registration_'s installing worker _installingWorker_ is not null, then:
   1. If the result of running Get Newest Worker with _registration_ is _installingWorker_, invoke Clear Registration with _registration_ and continue to the next iteration of the loop.

According to the algorithm, when we call [Get Newest Worker](https://w3c.github.io/ServiceWorker/#get-newest-worker), we're always going to get the installingWorker. Step 1 checks if the  _registration_'s installing worker _installingWorker_ is not null and the Get Newest Worker returns newestWorker which is going to be the registration's installing worker since the installing worker is not null.

This can be a problem since that means we are always invoking Clear Registration regardless.

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

Received on Tuesday, 24 January 2017 23:37:45 UTC