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
A [=/service worker registration=] has an associated <dfn export>navigation preload header value</dfn>, which is a [=byte sequence=]. It is initially set to \`<code>true</code>\`.
238
238
239
-
A [=/service worker registration=] is said to be <dfn export id="dfn-service-worker-registration-unregistered">unregistered</dfn> if [=scope to registration map=][this [=/service worker registration=]'s [=service worker registration/scope url=]] is not this [=/service worker registration=].
239
+
A [=/service worker registration=] is said to be <dfn export id="dfn-service-worker-registration-unregistered">unregistered</dfn> if [=id to registration map=][this [=/service worker registration=]'s [=service worker registration/id=]] is not this [=/service worker registration=].
A user agent *must* persistently keep a list of <a>registered</a>[=/service worker registrations=] unless otherwise they are explicitly <a>unregistered</a>. A user agent has a<a>scope to registration map</a> that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=], [=URL serializer|serialized=], and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=].
244
+
A user agent *must* persistently keep a list of <a>registered</a>[=/service worker registrations=] unless otherwise they are explicitly <a>unregistered</a>. A user agent has an<a>id to registration map</a> that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/id=] and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=].
1. [=map/For each=] |scope| → |registration| of [=scope to registration map=]:
776
+
1. [=map/For each=] |id| → |registration| of [=id to registration map=]:
777
+
1. Let |scope| be |registration|'s [=service worker registration/scope url=], [=URL serializer|serialized=].
777
778
1. If the [=url/origin=] of the result of [=URL parser|parsing=] |scope| is the [=same origin|same=] as |client|'s [=environment settings object/origin=], then [=append=] |registration| to |registrations|.
778
779
1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps:
[=/Service workers=] introduce new persistent storage features including <a>scope to registration map</a> (for [=/service worker registrations=] and their [=/service workers=]), [=request response list=] and <a>name to cache map</a> (for caches), and [=script resource map=] (for script resources). In order to protect users from any potential <a biblio data-biblio-type="informative" lt="unsanctioned-tracking">unsanctioned tracking</a> threat, these persistent storages *should* be cleared when users intend to clear them and *should* maintain and interoperate with existing user controls e.g. purging all existing persistent storages.
2276
+
[=/Service workers=] introduce new persistent storage features including <a>id to registration map</a> (for [=/service worker registrations=] and their [=/service workers=]), [=request response list=] and <a>name to cache map</a> (for caches), and [=script resource map=] (for script resources). In order to protect users from any potential <a biblio data-biblio-type="informative" lt="unsanctioned-tracking">unsanctioned tracking</a> threat, these persistent storages *should* be cleared when users intend to clear them and *should* maintain and interoperate with existing user controls e.g. purging all existing persistent storages.
1. If the [=environment settings object/origin=] of |job|'s [=job/scope url=] is not |job|'s [=job/referrer=]'s [=environment settings object/origin=], then:
2552
2555
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
2553
2556
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2554
-
1. Let |registration| be the result of running the <a>Get Registration</a> algorithm passing |job|'s [=job/scope url=] as the argument.
2557
+
1. Let |registration| be the result of running the <a>Get Registration</a> algorithm passing |job|'s [=job/id=] as the argument.
2555
2558
1. If |registration| is not null, then:
2556
2559
1. Let |newestWorker| be the result of running the <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2557
2560
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=], |job|'s [=job/worker type=] equals |newestWorker|'s [=service worker/type=], and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then:
1. Let |runResult| be the result of running the [=Run Service Worker=] algorithm with |worker| and |forceBypassCache|.
2696
2700
1. If |runResult| is *failure* or an [=abrupt completion=], then:
2697
2701
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
2698
-
1. If |newestWorker| is null, then [=map/remove=][=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]].
2702
+
1. If |newestWorker| is null, then [=map/remove=][=id to registration map=][|registration|'s [=service worker registration/id=]].
2699
2703
1. Invoke [=Finish Job=] with |job|.
2700
2704
1. Else, invoke [=Install=] algorithm with |job|, |worker|, and |registration| as its arguments.
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s [=installing worker=] and "`redundant`" as the arguments.
2768
2772
1. Run the <a>Update Registration State</a> algorithm passing |registration|, "<code>installing</code>" and null as the arguments.
2769
-
1. If |newestWorker| is null, then [=map/remove=][=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]].
2773
+
1. If |newestWorker| is null, then [=map/remove=][=id to registration map=][|registration|'s [=service worker registration/id=]].
2770
2774
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2771
2775
1. Let |map| be |registration|'s [=installing worker=]'s [=script resource map=].
2772
2776
1. Let |usedSet| be |registration|'s [=installing worker=]'s [=set of used scripts=].
1. [=map/For each=]<var ignore>scope</var> → |registration| of <a>scope to registration map</a>:
3149
+
1. [=map/For each=]<var ignore>id</var> → |registration| of <a>id to registration map</a>:
3146
3150
1. If |registration|'s <a>installing worker</a> |installingWorker| is not null, then:
3147
3151
1. If |registration|'s [=waiting worker=] is null and |registration|'s [=active worker=] is null, invoke <a>Clear Registration</a> with |registration| and continue to the next iteration of the loop.
1. If the [=environment settings object/origin=] of |job|'s [=job/scope url=] is not |job|'s [=job/client=]'s [=environment settings object/origin=], then:
3177
3181
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
3178
3182
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
3179
-
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |job|'s [=job/scope url=] as the argument.
3183
+
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |job|'s [=job/id=] as the argument.
3180
3184
1. If |registration| is null, then:
3181
3185
1. Invoke <a>Resolve Job Promise</a> with |job| and false.
3182
3186
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
3183
-
1. [=map/Remove=][=scope to registration map=][|job|'s [=job/scope url=]].
3187
+
1. [=map/Remove=][=id to registration map=][|job|'s [=job/id=]].
3184
3188
1. Invoke <a>Resolve Job Promise</a> with |job| and true.
3185
3189
1. Invoke [=Try Clear Registration=] with |registration|.
:: |updateViaCache|, an [=service worker registration/update via cache mode=]
3198
3203
: Output
3199
3204
:: |registration|, a [=/service worker registration=]
3200
3205
3201
3206
1. Run the following steps atomically.
3202
3207
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
3203
-
1. Let |registration| be a new [=/service worker registration=] whose [=service worker registration/scope url=] is set to |scope| and [=service worker registration/update via cache mode=] is set to |updateViaCache|.
3204
-
1. [=map/Set=]<a>scope to registration map</a>[|scopeString|] to |registration|.
3208
+
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
+
1. [=map/Set=]<a>id to registration map</a>[|id|] to |registration|.
1. Let |clientURLString| be <a lt="URL serializer">serialized</a> |clientURL|.
3319
3324
1. Let |matchingScopeString| be the empty string.
3320
-
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from <a>scope to registration map</a>.
3325
+
1. Let |scopeMap| be the empty map.
3326
+
1. [=map/For each=] |key| → |value| of <a>id to registration map</a>:
3327
+
1. If |value|'s [=service worker registration/active worker=/ is null, then [=continue=].
3328
+
1. [=map/Set=] |scopeMap|[|value|'s [=service worker registration/scope url] to |value|.
3329
+
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from |scopeMap|.
3321
3330
1. Set |matchingScopeString| to the longest value in |scopeStringSet| which the value of |clientURLString| starts with, if it exists.
3322
3331
3323
3332
Note: The URL string matching in this step is prefix-based rather than path-structural. E.g. a client URL string with "https://example.com/prefix-of/resource.html" will match a registration for a scope with "https://example.com/prefix". The URL string comparison is safe for the same-origin security as HTTP(S) URLs are always [=URL serializer|serialized=] with a trailing slash at the end of the origin part of the URLs.
0 commit comments