From a00a8ca1bdf571715947a19c22e24ba3cb3ecae6 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Fri, 4 Aug 2017 12:47:15 +0100 Subject: [PATCH 1/3] Handing fetch termination --- docs/index.bs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index e4522623..93cfd7bf 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -2991,9 +2991,10 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Invoke Run Service Worker algorithm with |activeWorker| as the argument. 1. Queue a task |task| to run the following substeps: 1. Let |e| be the result of creating an event with {{FetchEvent}}. + 1. Let |requestObject| be a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`". 1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}. 1. Initialize |e|’s {{Event/cancelable}} attribute to true. - 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`". + 1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject| 1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|. 1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=]. 1. If |request| is a non-subresource request 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. @@ -3006,6 +3007,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |e|'s [=FetchEvent/respond-with error flag=] is set, set |handleFetchFailed| to true. 1. Else, set |response| to |e|'s [=FetchEvent/potential response=]. 1. If |e|'s canceled flag is set, set |eventCanceled| to true. + 1. Run the following steps [=in parallel=]: + 1. Wait for the fetch to become [=fetch/terminated=]. + 1. [=Queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s [=Request/signal=]. If |task| is discarded or the script has been aborted by the termination of |activeWorker|, set |handleFetchFailed| to true. From d4fd56b4a91add07e9c288c8e3d1e8b1c7754b31 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Thu, 28 Sep 2017 13:34:26 +0100 Subject: [PATCH 2/3] Catering for navigation preloads --- docs/index.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 93cfd7bf..ff20aebf 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -2940,6 +2940,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |client| be |request|'s [=request/client=]. 1. Let |reservedClient| be |request|'s [=request/reserved client=]. 1. Let |preloadResponse| be a new [=promise=]. + 1. Let |fetchInstance| be the instance of the [=/fetch=] algorithm representing the ongoing fetch. 1. Assert: |request|'s [=request/destination=] is not "serviceworker". 1. If |request| is a potential-navigation-or-subresource request, then: 1. Return null. @@ -2965,13 +2966,14 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. [=header list/Append=] to |preloadRequestHeaders| a new [=header=] whose [=header/name=] is \`Service-Worker-Navigation-Preload\` and [=header/value=] is |registration|'s [=navigation preload header value=]. 1. Set |preloadRequest|'s [=service-workers mode=] to "`none`". 1. Run the following substeps [=in parallel=]: - 1. [=Fetch=] |preloadRequest|. + 1. [=Fetch=] |preloadRequest| and let |preloadFetchInstance| be the instance of the [=/fetch=] algorithm. To [=process response=] for |navigationPreloadResponse|, run these substeps: 1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps. 1. Associate |preloadResponseObject| with |navigationPreloadResponse|. 1. Resolve |preloadResponse| with |navigationPreloadResponse|. + 1. If |fetchInstance| is [=fetch/terminated=], then [=fetch/terminate=] |preloadFetchInstance| with the aborted flag set. 1. Else, resolve |preloadResponse| with undefined. Note: From this point, the [=/service worker client=] starts to use its active service worker's containing service worker registration. @@ -3007,9 +3009,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |e|'s [=FetchEvent/respond-with error flag=] is set, set |handleFetchFailed| to true. 1. Else, set |response| to |e|'s [=FetchEvent/potential response=]. 1. If |e|'s canceled flag is set, set |eventCanceled| to true. - 1. Run the following steps [=in parallel=]: - 1. Wait for the fetch to become [=fetch/terminated=]. - 1. [=Queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s [=Request/signal=]. + 1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}. If |task| is discarded or the script has been aborted by the termination of |activeWorker|, set |handleFetchFailed| to true. From b03549219f326b6a62c50bb29ce19e0fbd8b7272 Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Thu, 28 Sep 2017 14:18:03 +0100 Subject: [PATCH 3/3] Missing dot --- docs/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.bs b/docs/index.bs index ff20aebf..72195fc6 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -2996,7 +2996,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Let |requestObject| be a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`". 1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}. 1. Initialize |e|’s {{Event/cancelable}} attribute to true. - 1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject| + 1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject|. 1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|. 1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=]. 1. If |request| is a non-subresource request 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.