You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. If |newestWorker| is null, return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
606
608
1. If the <a>context object</a>'s <a>relevant settings object</a>'s [=environment settings object/global object=] |globalObject| is a {{ServiceWorkerGlobalScope}} object, and |globalObject|'s associated [=ServiceWorkerGlobalScope/service worker=]'s <a>state</a> is "`installing`", return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
607
609
1. Let |promise| be a <a>promise</a>.
608
-
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/scope url=], |newestWorker|'s [=service worker/script url=], |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
610
+
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/id=], |newestWorkers|'s [=service worker/scope url=], |newestWorker|'s [=service worker/script url=], |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
609
611
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
<dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method *must* run these steps:
620
622
621
623
1. Let |promise| be [=a new promise=].
622
-
1. Let |job| be the result of running [=Create Job=] with *unregister*, the [=service worker registration/scope url=] of the [=ServiceWorkerRegistration/service worker registration=], null, |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
624
+
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
625
+
1. If |newestWorker| is null, return [=a promise rejected with=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps.
626
+
1. Let |job| be the result of running [=Create Job=] with *unregister*, the [=service worker registration/id=] of the [=ServiceWorkerRegistration/service worker registration=], |newest worker|'s [=service worker/scope url=], null, |promise|, and the <a>context object</a>'s <a>relevant settings object</a>.
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> |scriptURL| with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
743
747
1. Let |scopeURL| be null.
744
748
1. If |options|.{{RegistrationOptions/scope}} is <a>present</a>, set |scopeURL| to the result of <a lt="URL parser">parsing</a> |options|.{{RegistrationOptions/scope}} with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
745
-
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |p|, |client|, |client|'s <a>creation URL</a>, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/updateViaCache}}.
749
+
1. Let |id| be null.
750
+
1. If |options|.{{RegistrationOptions/id} is <a>present</a>, set |id| to |options|.{{RegistrationOptions/id}}.
751
+
1. Invoke [=Start Register=] with |id|, |scopeURL|, |scriptURL|, |p|, |client|, |client|'s <a>creation URL</a>, |options|.{{RegistrationOptions/type}}, and |options|.{{RegistrationOptions/updateViaCache}}.
An <dfn id="dfn-id-to-registration-map">id to registration map</dfn> is an <a>ordered map</a> where the keys are [=service worker registration/ids=] and the values are [=/service worker registrations=].
2338
2344
2339
-
A <dfn id="dfn-scope-to-service-worker-map">scope to service worker map</dfn> is an <a>ordered map</a> where the keys are [=service worker/scope urls=], [=URL serializer|serialized=], and the values are [=/service workers=].
2340
-
2341
2345
A <dfn id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a [=/service worker registration=].
1. If |scopeURL|'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", reject |promise| with a <code>TypeError</code> and abort these steps.
2532
2539
1. If any of the strings in |scopeURL|'s [=url/path=] contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject |promise| with a <code>TypeError</code> and abort these steps.
2533
-
1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|.
2540
+
1. If |id| is null, set |id| to |scopeURL|.
2541
+
1. Let |job| be the result of running [=Create Job=] with *register*, |id|, |scopeURL|, |scriptURL|, |promise|, and |client|.
2534
2542
1. Set |job|'s [=job/worker type=] to |workerType|.
2535
2543
1. Set |job|'s [=job/update via cache mode=] to |updateViaCache|.
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as its argument.
2722
2733
1. If |newestWorker| is null, abort these steps.
2723
-
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/scope url=], |newestWorker|'s [=service worker/script url=], null, and null.
2734
+
1. Let |job| be the result of running <a>Create Job</a> with *update*, |registration|'s [=service worker registration/id=], |newestWorker|'s [=service worker/scope url=], |newestWorker|'s [=service worker/script url=], null, and null.
2724
2735
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
2725
2736
1. Set |job|'s [=force bypass cache flag=] if |forceBypassCache| is true.
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s <a>installing worker</a> and "`installing`" as the arguments.
2744
2755
1. Assert: |job|'s [=job/job promise=] is not null.
2745
2756
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2746
-
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |registration|'s [=service worker registration/scope url=]'s [=url/origin=].
2757
+
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |job|'s [=job/scope url=]'s [=url/origin=].
2747
2758
1. For each |settingsObject| of |settingsObjects|, [=queue a task=] on |settingsObject|'s [=responsible event loop=] in the [=DOM manipulation task source=] to run the following steps:
2748
2759
1. Let |registrationObjects| be every {{ServiceWorkerRegistration}} object in |settingsObject|'s [=environment settings object/realm=], whose [=ServiceWorkerRegistration/service worker registration=] is |registration|.
2749
2760
1. For each |registrationObject| of |registrationObjects|, [=fire an event=] on |registrationObject| named `updatefound`.
Note: Make sure to design activation handlers to do non-essential work (like cleanup). This is because activation handlers may not all run to completion, especially in the case of browser termination during activation. A Service Worker should be designed to function properly, even if the activation handlers do not all complete successfully.
2811
2822
2823
+
<!-- remove this service worker registration/scope url reference -->
2812
2824
1. Let |matchedClients| be a [=list=] of [=/service worker clients=] whose <a>creation URL</a><a lt="Match Service Worker Registration">matches</a> |registration|'s [=service worker registration/scope url=].
2813
2825
1. [=list/For each=] |client| of |matchedClients|, [=queue a task=] on |client|'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following substeps:
2814
2826
1. Let |readyPromise| be |client|'s [=environment settings object/global object=]'s {{ServiceWorkerContainer}} object's [=ServiceWorkerContainer/ready promise=].
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
3220
+
<!-- get rid of this service worker registration/scope url reference -->
3208
3221
1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/id=] is set to |id|, [=service worker registration/scope url=] is set to |scope|, and [=service worker registration/update via cache mode=] is set to |updateViaCache|.
3209
3222
1. [=map/Set=]<a>id to registration map</a>[|id|] to |registration|.
0 commit comments