Skip to content

Commit e91ddff

Browse files
Redesign Service-Worker-Allowed header extraction (#1830)
This change updates the Service-Worker-Allowed header handling to use modern Fetch primitives. Specifically: 1. Replaced 'extracting header list values' with 'header list/get'. 2. Added an explicit 'isomorphic decode' step for the header value. 3. Moved the failure check to follow the URL parsing step. Fixes #1360
1 parent 2fd367a commit e91ddff

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

index.bs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,13 +2815,12 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
28152815
1. [=Extract a MIME type=] from the |response|'s [=response/header list=]. If this MIME type (ignoring parameters) is not a [=JavaScript MIME type=], then:
28162816
1. Invoke [=Reject Job Promise=] with |job| and "{{SecurityError}}" {{DOMException}}.
28172817
1. Asynchronously complete these steps with a [=network error=].
2818-
1. Let |serviceWorkerAllowed| be the result of [=extracting header list values=] given \`<code>Service-Worker-Allowed</code>\` and |response|'s [=response/header list=].
2818+
1. Let |serviceWorkerAllowed| be the result of [=header list/get=] \`<code>Service-Worker-Allowed</code>\` from |response|'s [=response/header list=].
28192819

28202820
Note: See the definition of the [=Service-Worker-Allowed=] header in Appendix B: Extended HTTP headers.
28212821

2822+
1. If |serviceWorkerAllowed| is not null, then set |serviceWorkerAllowed| to the result of [=isomorphic decode=] |serviceWorkerAllowed|.
28222823
1. Set |policyContainer| to the result of <a>creating a policy container from a fetch response</a> given |response|.
2823-
1. If |serviceWorkerAllowed| is failure, then:
2824-
1. Asynchronously complete these steps with a <a>network error</a>.
28252824
1. Let |scopeURL| be |registration|'s [=service worker registration/scope url=].
28262825
1. Let |maxScopeString| be null.
28272826
1. If |serviceWorkerAllowed| is null, then:
@@ -2832,6 +2831,8 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
28322831

28332832
1. Else:
28342833
1. Let |maxScope| be the result of [=URL parser|parsing=] |serviceWorkerAllowed| using |job|'s [=job/script url=] as the [=base URL=].
2834+
1. If |maxScope| is failure, then:
2835+
1. Asynchronously complete these steps with a <a>network error</a>.
28352836
1. If |maxScope|'s [=url/origin=] is |job|'s [=job/script url=]'s [=url/origin=], then:
28362837
1. Set |maxScopeString| to "`/`", followed by the strings in |maxScope|'s [=url/path=] (including empty strings), separated from each other by "`/`".
28372838
1. Let |scopeString| be "`/`", followed by the strings in |scopeURL|'s [=url/path=] (including empty strings), separated from each other by "`/`".

0 commit comments

Comments
 (0)