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.
2285
+
[=/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:
2561
2564
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
2562
2565
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2563
-
1. Let |registration| be the result of running the <a>Get Registration</a> algorithm passing |job|'s [=job/scope url=] as the argument.
2566
+
1. Let |registration| be the result of running the <a>Get Registration</a> algorithm passing |job|'s [=job/id=] as the argument.
2564
2567
1. If |registration| is not null, then:
2565
2568
1. Let |newestWorker| be the result of running the <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2566
2569
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|.
2702
2706
1. If |runResult| is *failure* or an [=abrupt completion=], then:
2703
2707
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
2704
-
1. If |newestWorker| is null, then [=map/remove=][=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]].
2708
+
1. If |newestWorker| is null, then [=map/remove=][=id to registration map=][|registration|'s [=service worker registration/id=]].
2705
2709
1. Invoke [=Finish Job=] with |job|.
2706
2710
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.
2774
2778
1. Run the <a>Update Registration State</a> algorithm passing |registration|, "<code>installing</code>" and null as the arguments.
2775
-
1. If |newestWorker| is null, then [=map/remove=][=scope to registration map=][|registration|'s [=service worker registration/scope url=], [[=URL serializer|serialized=]].
2779
+
1. If |newestWorker| is null, then [=map/remove=][=id to registration map=][|registration|'s [=service worker registration/id=]].
2776
2780
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2777
2781
1. Let |map| be |registration|'s [=installing worker=]'s [=script resource map=].
2778
2782
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>:
3152
+
1. [=map/For each=]<var ignore>id</var> → |registration| of <a>id to registration map</a>:
3149
3153
1. If |registration|'s <a>installing worker</a> |installingWorker| is not null, then:
3150
3154
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:
3180
3184
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
3181
3185
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
3182
-
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |job|'s [=job/scope url=] as the argument.
3186
+
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |job|'s [=job/id=] as the argument.
3183
3187
1. If |registration| is null, then:
3184
3188
1. Invoke <a>Resolve Job Promise</a> with |job| and false.
3185
3189
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
3186
-
1. [=map/Remove=][=scope to registration map=][|job|'s [=job/scope url=]].
3190
+
1. [=map/Remove=][=id to registration map=][|job|'s [=job/id=]].
3187
3191
1. Invoke <a>Resolve Job Promise</a> with |job| and true.
3188
3192
1. Invoke [=Try Clear Registration=] with |registration|.
:: |updateViaCache|, an [=service worker registration/update via cache mode=]
3201
3206
: Output
3202
3207
:: |registration|, a [=/service worker registration=]
3203
3208
3204
3209
1. Run the following steps atomically.
3205
3210
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
3206
-
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|.
3207
-
1. [=map/Set=]<a>scope to registration map</a>[|scopeString|] to |registration|.
3211
+
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
+
1. [=map/Set=]<a>id to registration map</a>[|id|] to |registration|.
1. Let |clientURLString| be <a lt="URL serializer">serialized</a> |clientURL|.
3322
3327
1. Let |matchingScopeString| be the empty string.
3323
-
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from <a>scope to registration map</a>.
3328
+
1. Let |scopeMap| be the empty map.
3329
+
1. [=map/For each=] |key| → |value| of <a>id to registration map</a>:
3330
+
1. If |value|'s [=service worker registration/active worker=/ is null, then [=continue=].
3331
+
1. [=map/Set=] |scopeMap|[|value|'s [=service worker registration/scope url] to |value|.
3332
+
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from |scopeMap|.
3324
3333
1. Set |matchingScopeString| to the longest value in |scopeStringSet| which the value of |clientURLString| starts with, if it exists.
3325
3334
3326
3335
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