Skip to content

Commit 5474d11

Browse files
Handing fetch termination (#1178)
* Handing fetch termination * Catering for navigation preloads * Missing dot
1 parent 4b59263 commit 5474d11

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/index.bs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29362936
1. Let |client| be |request|'s [=request/client=].
29372937
1. Let |reservedClient| be |request|'s [=request/reserved client=].
29382938
1. Let |preloadResponse| be a new [=promise=].
2939+
1. Let |fetchInstance| be the instance of the [=/fetch=] algorithm representing the ongoing fetch.
29392940
1. Assert: |request|'s [=request/destination=] is not "<code>serviceworker</code>".
29402941
1. If |request| is a <a>potential-navigation-or-subresource request</a>, then:
29412942
1. Return null.
@@ -2961,13 +2962,14 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29612962
1. [=header list/Append=] to |preloadRequestHeaders| a new [=header=] whose [=header/name=] is \`<code>Service-Worker-Navigation-Preload</code>\` and [=header/value=] is |registration|'s [=navigation preload header value=].
29622963
1. Set |preloadRequest|'s [=service-workers mode=] to "`none`".
29632964
1. Run the following substeps [=in parallel=]:
2964-
1. [=Fetch=] |preloadRequest|.
2965+
1. [=Fetch=] |preloadRequest| and let |preloadFetchInstance| be the instance of the [=/fetch=] algorithm.
29652966

29662967
To [=process response=] for |navigationPreloadResponse|, run these substeps:
29672968

29682969
1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps.
29692970
1. Associate |preloadResponseObject| with |navigationPreloadResponse|.
29702971
1. Resolve |preloadResponse| with |navigationPreloadResponse|.
2972+
1. If |fetchInstance| is [=fetch/terminated=], then [=fetch/terminate=] |preloadFetchInstance| with the aborted flag set.
29712973
1. Else, resolve |preloadResponse| with undefined.
29722974

29732975
Note: From this point, the [=/service worker client=] starts to <a>use</a> its <a>active service worker</a>'s <a>containing service worker registration</a>.
@@ -2987,9 +2989,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29872989
1. Invoke <a>Run Service Worker</a> algorithm with |activeWorker| as the argument.
29882990
1. <a>Queue a task</a> |task| to run the following substeps:
29892991
1. Let |e| be the result of <a>creating an event</a> with {{FetchEvent}}.
2992+
1. Let |requestObject| be a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`".
29902993
1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}.
29912994
1. Initialize |e|’s {{Event/cancelable}} attribute to true.
2992-
1. Initialize |e|’s {{FetchEvent/request}} attribute to a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`".
2995+
1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject|.
29932996
1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|.
29942997
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
29952998
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/reservedClientId}} attribute to |reservedClient|'s [=environment/id=], and to the empty string otherwise.
@@ -3002,6 +3005,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
30023005
1. If |e|'s [=FetchEvent/respond-with error flag=] is set, set |handleFetchFailed| to true.
30033006
1. Else, set |response| to |e|'s [=FetchEvent/potential response=].
30043007
1. If |e|'s <a>canceled flag</a> is set, set |eventCanceled| to true.
3008+
1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}.
30053009

30063010
If |task| is discarded or the script has been aborted by the <a lt="terminate service worker">termination</a> of |activeWorker|, set |handleFetchFailed| to true.
30073011

0 commit comments

Comments
 (0)