Skip to content

Commit

Permalink
Add FetchEvent.handled (w3c#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
tingshao committed Jan 10, 2020
1 parent 910cdd8 commit dcdd173
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
readonly attribute DOMString clientId;
readonly attribute DOMString resultingClientId;
readonly attribute DOMString replacesClientId;
readonly attribute Promise<void> handled;

void respondWith(Promise<Response> r);
};
Expand All @@ -1495,6 +1496,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
DOMString clientId = "";
DOMString resultingClientId = "";
DOMString replacesClientId = "";
Promise<void> handled;
};
</pre>

Expand Down Expand Up @@ -1536,6 +1538,12 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
<dfn attribute for="FetchEvent"><code>replacesClientId</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to the empty string.
</section>

<section>
<h4 id="fetch-event-handled">{{FetchEvent/handled|event.handled}}</h4>

<dfn attribute for="FetchEvent"><code>handled</code></dfn> attribute *must* return the value it was initialized to. When an <a>event</a> is created the attribute *must* be initialized to a pending [=promise=].
</section>

<section algorithm="fetch-event-respondwith">
<h4 id="fetch-event-respondwith">{{FetchEvent/respondWith(r)|event.respondWith(r)}}</h4>

Expand Down Expand Up @@ -2932,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 |eventHandled| 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 "<code>serviceworker</code>".
1. If |request|'s [=request/destination=] is either "<code>embed</code>" or "<code>object</code>", then:
Expand Down Expand Up @@ -2992,6 +3001,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
1. If |request| is a <a>non-subresource request</a> and |request|'s [=request/destination=] is not {{RequestDestination/"report"}}, initialize |e|'s {{FetchEvent/resultingClientId}} attribute to |reservedClient|'s [=environment/id=], and to the empty string otherwise.
1. If |request| is a <a>navigation request</a>, initialize |e|'s {{FetchEvent/replacesClientId}} attribute to |request|'s [=request/replaces client id=], and to the empty string otherwise.
1. Initialize |e|’s {{FetchEvent/handled}} to |eventHandled|.
1. <a>Dispatch</a> |e| at |activeWorker|'s [=service worker/global object=].
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|.
1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true.
Expand All @@ -3007,6 +3017,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
The |task| *must* use |activeWorker|'s <a>event loop</a> and the <a>handle fetch task source</a>.

1. Wait for |task| to have executed or for |handleFetchFailed| to be true.
1. If |handleFetchFailed| is false and |eventCanceled| is false, then resolve |eventHandled| with undefined, otherwise reject it with "{{NetworkError}}" {{DOMException}}.
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
1. If |respondWithEntered| is false, then return a [=network error=] if |eventCanceled| is true and null otherwise.
1. If |handleFetchFailed| is true, then return a [=network error=].
Expand Down

0 comments on commit dcdd173

Please sign in to comment.