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
Remove fragment identifiers from script url and scope url (#1251)
The spec and the implementations did not agree on the behavior: the spec
didn't remove fragment identifiers and had ServiceWorker.scriptURL and
ServiceWorkerRegistration.scope return urls without stripping them.
Chrome, Firefox, and Edge don't return fragments.
This changes the spec to remove the fragment indentifiers from the
script url and scope url given to register() and getRegistration()
before storing them, in order to match the implementations.
Fixes#1249.
1. Let |client| be the <a>context object</a>'s [=ServiceWorkerContainer/service worker client=].
638
638
1. Let |clientURL| be the result of <a lt="URL parser">parsing</a> |clientURL| with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
639
639
1. If |clientURL| is failure, return a <a>promise</a> rejected with a <code>TypeError</code>.
640
+
1. Set |clientURL|'s [=url/fragment=] to null.
640
641
1. If the [=environment settings object/origin=] of |clientURL| is not |client|'s [=environment settings object/origin=], return a |promise| rejected with a "{{SecurityError}}" {{DOMException}}.
1. If |scriptURL| is failure, reject |promise| with a <code>TypeError</code> and abort these steps.
2307
+
1. Set |scriptURL|'s [=url/fragment=] to null.
2308
+
2309
+
Note: The user agent does not store the [=url/fragment=] of the script's url. This means that the [=url/fragment=] does not have an effect on identifying [=/service workers=].
2310
+
2306
2311
1. If |scriptURL|'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.
2307
2312
1. If any of the strings in |scriptURL|'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.
2308
2313
1. If |scopeURL| is null, set |scopeURL| to the result of <a lt="URL parser">parsing</a> the string "<code>./</code>" with |scriptURL|.
2309
2314
2310
2315
Note: The scope url for the registration is set to the location of the service worker script by default.
2311
2316
2312
2317
1. If |scopeURL| is failure, reject |promise| with a <code>TypeError</code> and abort these steps.
2318
+
1. Set |scopeURL|'s [=url/fragment=] to null.
2319
+
2320
+
Note: The user agent does not store the [=url/fragment=] of the scope url. This means that the [=url/fragment=] does not have an effect on identifying [=/service worker registrations=].
2321
+
2313
2322
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.
2314
2323
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.
2315
2324
1. Let |job| be the result of running [=Create Job=] with *register*, |scopeURL|, |scriptURL|, |promise|, and |client|.
1. If |registration|'s <a>uninstalling flag</a> is set, unset it.
2342
2351
1. Let |newestWorker| be the result of running the <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2343
-
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=] with the *exclude fragments flag* set, and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then:
2352
+
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=], and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=], then:
2344
2353
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2345
2354
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
2362
2371
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2363
2372
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2364
-
1. If |job|'s <a>job type</a> is *update*, and |newestWorker|'s [=service worker/script url=] does not [=url/equal=] |job|'s [=job/script url=] with the *exclude fragments flag* set, then:
2373
+
1. If |job|'s <a>job type</a> is *update*, and |newestWorker|'s [=service worker/script url=] does not [=url/equal=] |job|'s [=job/script url=], then:
2365
2374
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
2366
2375
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
Else, continue the rest of these steps after the algorithm's asynchronous completion, with |script| being the asynchronous completion value.
2432
2441
2433
-
1. If |newestWorker| is not null, |newestWorker|'s [=service worker/script url=] [=url/equals=] |job|'s [=job/script url=] with the *exclude fragments flag* set, and |script|'s [=source text=] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=source text=], if |script| is a [=classic script=], and |script|'s [=module script/module record=]'s \[[ECMAScriptCode]] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=module script/module record=]'s \[[ECMAScriptCode]] otherwise, then:
2442
+
1. If |newestWorker| is not null, |newestWorker|'s [=service worker/script url=] [=url/equals=] |job|'s [=job/script url=], and |script|'s [=source text=] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=source text=], if |script| is a [=classic script=], and |script|'s [=module script/module record=]'s \[[ECMAScriptCode]] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=module script/module record=]'s \[[ECMAScriptCode]] otherwise, then:
2434
2443
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2435
2444
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
:: |registration|, a [=/service worker registration=]
2878
2887
2879
2888
1. Run the following steps atomically.
2880
-
1. Let |scopeString| be <a lt="URL serializer">serialized</a> |scope| with the *exclude fragment flag* set.
2889
+
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
2881
2890
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|.
2882
2891
1. [=map/Set=]<a>scope to registration map</a>[|scopeString|] to |registration|.
1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
2905
2914
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s [=active worker=] and *redundant* as the arguments.
2906
2915
1. Run the <a>Update Registration State</a> algorithm passing |registration|, "<code>active</code>" and null as the arguments.
2907
-
1. Let |scopeString| be <a lt="URL serializer">serialized</a> |registration|'s [=service worker registration/scope url=] with the *exclude fragment flag* set.
2916
+
1. Let |scopeString| be |registration|'s [=URL serializer|serialized=][=service worker registration/scope url=].
2908
2917
1. [=map/Remove=]<a>scope to registration map</a>[|scopeString|].
1. Let |client| be the <a>context object</a>'s [=ServiceWorkerContainer/service worker client=].
607
607
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>.
608
608
1. If |scriptURL| is failure, reject |p| with a <code>TypeError</code> and abort these steps.
609
+
1. Set |scriptURL|'s [=url/fragment=] to null.
610
+
611
+
Note: The user agent does not store the [=url/fragment=] of the script's url. This means that the [=url/fragment=] does not have an effect on identifying [=/service workers=].
612
+
609
613
1. If |scriptURL|'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", reject |p| with a <code>TypeError</code> and abort these steps.
610
614
1. If any of the strings in |scriptURL|'s [=url/path=] contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject |p| with a <code>TypeError</code> and abort these steps.
1. Else, 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>.
617
621
1. If |scopeURL| is failure, reject |p| with a <code>TypeError</code> and abort these steps.
622
+
1. Set |scopeURL|'s [=url/fragment=] to null.
623
+
624
+
Note: The user agent does not store the [=url/fragment=] of the scope url. This means that the [=url/fragment=] does not have an effect on identifying [=/service worker registrations=].
625
+
618
626
1. If |scopeURL|'s [=url/scheme=] is not one of "<code>http</code>" and "<code>https</code>", reject |p| with a <code>TypeError</code> and abort these steps.
619
627
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 |p| with a <code>TypeError</code> and abort these steps.
620
628
1. Let |job| be the result of running <a>Create Job</a> with *register*, |scopeURL|, |scriptURL|, |p|, and |client|.
1. Let |client| be the <a>context object</a>'s [=ServiceWorkerContainer/service worker client=].
633
641
1. Let |clientURL| be the result of <a lt="URL parser">parsing</a> |clientURL| with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
634
642
1. If |clientURL| is failure, return a <a>promise</a> rejected with a <code>TypeError</code>.
643
+
1. Set |clientURL|'s [=url/fragment=] to null.
635
644
1. If the [=environment settings object/origin=] of |clientURL| is not |client|'s [=environment settings object/origin=], return a |promise| rejected with a "{{SecurityError}}" {{DOMException}}.
1. If |registration|'s <a>uninstalling flag</a> is set, unset it.
2231
2240
1. Let |newestWorker| be the result of running the <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2232
-
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=] with the *exclude fragments flag* set, and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=]'s value, then:
2241
+
1. If |newestWorker| is not null, |job|'s [=job/script url=] [=url/equals=] |newestWorker|'s [=service worker/script url=], and |job|'s [=job/update via cache mode=]'s value equals |registration|'s [=service worker registration/update via cache mode=]'s value, then:
2233
2242
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2234
2243
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
2251
2260
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
2252
2261
1. Let |newestWorker| be the result of running <a>Get Newest Worker</a> algorithm passing |registration| as the argument.
2253
-
1. If |job|'s <a>job type</a> is *update*, and |newestWorker|'s [=service worker/script url=] does not [=url/equal=] |job|'s [=job/script url=] with the *exclude fragments flag* set, then:
2262
+
1. If |job|'s <a>job type</a> is *update*, and |newestWorker|'s [=service worker/script url=] does not [=url/equal=] |job|'s [=job/script url=], then:
2254
2263
1. Invoke [=Reject Job Promise=] with |job| and `TypeError`.
2255
2264
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
Else, continue the rest of these steps after the algorithm's asynchronous completion, with |script| being the asynchronous completion value.
2321
2330
2322
-
1. If |newestWorker| is not null, |newestWorker|'s [=service worker/script url=] [=url/equals=] |job|'s [=job/script url=] with the *exclude fragments flag* set, and |script|'s [=source text=] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=source text=], if |script| is a [=classic script=], and |script|'s [=module script/module record=]'s \[[ECMAScriptCode]] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=module script/module record=]'s \[[ECMAScriptCode]] otherwise, then:
2331
+
1. If |newestWorker| is not null, |newestWorker|'s [=service worker/script url=] [=url/equals=] |job|'s [=job/script url=], and |script|'s [=source text=] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=source text=], if |script| is a [=classic script=], and |script|'s [=module script/module record=]'s \[[ECMAScriptCode]] is a byte-for-byte match with |newestWorker|'s [=script resource=]'s [=module script/module record=]'s \[[ECMAScriptCode]] otherwise, then:
2323
2332
1. Invoke [=Resolve Job Promise=] with |job| and |registration|.
2324
2333
1. Invoke <a>Finish Job</a> with |job| and abort these steps.
:: |registration|, a [=/service worker registration=]
2743
2752
2744
2753
1. Run the following steps atomically.
2745
-
1. Let |scopeString| be <a lt="URL serializer">serialized</a> |scope| with the *exclude fragment flag* set.
2754
+
1. Let |scopeString| be [=URL serializer|serialized=] |scope| with the *exclude fragment flag* set.
2746
2755
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|.
2747
2756
1. [=map/Set=]<a>scope to registration map</a>[|scopeString|] to |registration|.
1. [=Terminate Service Worker|Terminate=] |registration|'s [=active worker=].
2770
2779
1. Run the <a>Update Worker State</a> algorithm passing |registration|'s [=active worker=] and *redundant* as the arguments.
2771
2780
1. Run the <a>Update Registration State</a> algorithm passing |registration|, "<code>active</code>" and null as the arguments.
2772
-
1. Let |scopeString| be <a lt="URL serializer">serialized</a> |registration|'s [=service worker registration/scope url=] with the *exclude fragment flag* set.
2781
+
1. Let |scopeString| be |registration|'s [=URL serializer|serialized=][=service worker registration/scope url=].
2773
2782
1. [=map/Remove=]<a>scope to registration map</a>[|scopeString|].
0 commit comments