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 [=this=]'s [=relevant 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 [=this=]'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 [=this=]'s <a>relevant settings object</a>.
609
611
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
The <dfn method for="ServiceWorkerRegistration"><code>unregister()</code></dfn> method steps are:
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 [=this=]'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 [=this=]'s <a>relevant settings object</a>.
1. Let |client| be [=this=]'s [=ServiceWorkerContainer/service worker client=].
742
746
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> |scriptURL| with [=this=]'s <a>relevant settings object</a>'s <a>API base URL</a>.
743
747
1. Let |scopeURL| be null.
744
-
1. If |options|["{{RegistrationOptions/scope}}"][=map/exists=], set |scopeURL| to the result of <a lt="URL parser">parsing</a> |options|["{{RegistrationOptions/scope}}"] with [=this=]'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}}"].
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 [=this=]'s <a>relevant settings object</a>'s <a>API base URL</a>.
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=].
2347
2353
2348
-
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=].
2349
-
2350
2354
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.
2541
2548
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.
2542
-
1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|.
2549
+
1. If |id| is null, set |id| to |scopeURL|.
2550
+
1. Let |job| be the result of running [=Create Job=] with *register*, |id|, |scopeURL|, |scriptURL|, |promise|, and |client|.
2543
2551
1. Set |job|'s [=job/worker type=] to |workerType|.
2544
2552
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.
2728
2739
1. If |newestWorker| is null, abort these steps.
2729
-
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.
2740
+
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.
2730
2741
1. Set |job|'s <a>worker type</a> to |newestWorker|'s [=service worker/type=].
2731
2742
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.
2750
2761
1. Assert: |job|'s [=job/job promise=] is not null.
2751
2762
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2752
-
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |registration|'s [=service worker registration/scope url=]'s [=url/origin=].
2763
+
1. Let |settingsObjects| be all [=environment settings objects=] whose [=environment settings object/origin=] is |job|'s [=job/scope url=]'s [=url/origin=].
2753
2764
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:
2754
2765
1. Let |registrationObjects| be every {{ServiceWorkerRegistration}} object in |settingsObject|'s [=environment settings object/realm=], whose [=ServiceWorkerRegistration/service worker registration=] is |registration|.
2755
2766
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.
2817
2828
2829
+
<!-- remove this service worker registration/scope url reference -->
2818
2830
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=].
2819
2831
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:
2820
2832
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.
3223
+
<!-- get rid of this service worker registration/scope url reference -->
3211
3224
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|.
3212
3225
1. [=map/Set=]<a>id to registration map</a>[|id|] to |registration|.
0 commit comments