Re: [w3c/ServiceWorker] Central algorithm for updating service worker state and registrations (#1416)

jakearchibald commented on this pull request.



> +
+                      Note: *installing* is the initial script-exposed state, so it doesn't count as a change.
+
+          1. [=list/For each=] |registrationObject| of |registrationObjects|:
+              1. Set |registrationObject|'s {{ServiceWorkerRegistration/installing}} to null if |installingWorker| is null, otherwise set it to the {{ServiceWorker}} that represents |installingWorker| within |settingsObject|'s [=environment settings object/realm execution context=].
+              1. Set |registrationObject|'s {{ServiceWorkerRegistration/waiting}} to null if |waitingWorker| is null, otherwise set it to the {{ServiceWorker}} that represents |waitingWorker| within |settingsObject|'s [=environment settings object/realm execution context=].
+              1. Set |registrationObject|'s {{ServiceWorkerRegistration/active}} to null if |activeWorker| is null, otherwise set it to the {{ServiceWorker}} that represents |activeWorker| within |settingsObject|'s [=environment settings object/realm execution context=].
+          1. [=list/For each=] |workerObject| of |changedWorkers|, [=fire an event=] on |workerObject| named `statechange`.
+          1. If `updateFound` is true, then [=list/for each=] |registrationObject| of |registrationObjects|, [=fire an event=] on |registrationObject| named `updatefound`.
+          1. If |newActiveWorker| is true:
+              1. Let |container| be the {{ServiceWorkerContainer}} object within |settingsObject|'s [=environment settings object/realm execution context=].
+              1. Let |readyPromise| be |container|'s [=ServiceWorkerContainer/ready promise=].
+              1. If |settingsObject| [=/uses=] |registration|, then:
+                  1. Set |settingsObject|'s [=environment/active service worker=] to |activeWorker|.
+                  1. [=fire an event=] named `controllerchange` on |container|.
+              1. <span id="update-state-resolve-ready-step">If the [=Match Service Worker Registration|matching=] [=/service worker registration=] for |settingsObject|'s [=environment/creation URL=] is |registration|, and |readyPromise| is pending, then [=/resolve=] |readyPromise| with a new {{ServiceWorkerRegistration}} object representing |registration| in |readyPromise|'s [=relevant Realm=].</span>

This shouldn't be a new {{ServiceWorkerRegistration}}. It should return the same object if one exists. This is kinda hand-wavey in the spec.

-- 
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/pull/1416#pullrequestreview-246475293

Received on Thursday, 6 June 2019 10:06:25 UTC