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
<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.
<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=].
1. If |activeWorker|'s <a>state</a> is "`activating`", wait for |activeWorker|'s <a>state</a> to become "`activated`".
2984
2997
1. If the result of running the [=Run Service Worker=] algorithm with |activeWorker| is *failure*, then set |handleFetchFailed| to true.
2985
-
1. Else [=queue a task=] |task| to run the following substeps:
2986
-
1. Let |e| be the result of <a>creating an event</a> with {{FetchEvent}}.
2987
-
1. Let |requestObject| be a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`".
2988
-
1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}.
2989
-
1. Initialize |e|’s {{Event/cancelable}} attribute to true.
2990
-
1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject|.
2991
-
1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|.
2992
-
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
2993
-
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.
2994
-
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.
2995
-
1. <a>Dispatch</a> |e| at |activeWorker|'s [=service worker/global object=].
2996
-
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|.
2997
-
1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true.
2998
-
1. If |e|'s [=FetchEvent/wait to respond flag=] is set, then:
2999
-
1. Wait until |e|'s [=FetchEvent/wait to respond flag=] is unset.
3000
-
1. If |e|'s [=FetchEvent/respond-with error flag=] is set, set |handleFetchFailed| to true.
3001
-
1. Else, set |response| to |e|'s [=FetchEvent/potential response=].
3002
-
1. If |e|'s <a>canceled flag</a> is set, set |eventCanceled| to true.
3003
-
1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}.
3004
-
3005
-
If |task| is discarded, set |handleFetchFailed| to true.
3006
-
3007
-
The |task| *must* use |activeWorker|'s <a>event loop</a> and the <a>handle fetch task source</a>.
2998
+
1. Else:
2999
+
1. Set |workerRealm| to the [=relevant realm=] of the |activeWorker|'s [=service worker/global object=].
3000
+
1. Set |eventHandled| to [=a new promise=] in |workerRealm|.
3001
+
1. [=Queue a task=] |task| to run the following substeps:
3002
+
1. Let |e| be the result of <a>creating an event</a> with {{FetchEvent}}.
3003
+
1. Let |requestObject| be a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`".
3004
+
1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}.
3005
+
1. Initialize |e|’s {{Event/cancelable}} attribute to true.
3006
+
1. Initialize |e|’s {{FetchEvent/request}} attribute to |requestObject|.
3007
+
1. Initialize |e|’s {{FetchEvent/preloadResponse}} to |preloadResponse|.
3008
+
1. Initialize |e|'s {{FetchEvent/clientId}} attribute to |client|'s [=environment/id=].
3009
+
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.
3010
+
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.
3011
+
1. Initialize |e|’s {{FetchEvent/handled}} to |eventHandled|.
3012
+
1. <a>Dispatch</a> |e| at |activeWorker|'s [=service worker/global object=].
3013
+
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|.
3014
+
1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true.
3015
+
1. If |e|'s [=FetchEvent/wait to respond flag=] is set, then:
3016
+
1. Wait until |e|'s [=FetchEvent/wait to respond flag=] is unset.
3017
+
1. If |e|'s [=FetchEvent/respond-with error flag=] is set, set |handleFetchFailed| to true.
3018
+
1. Else, set |response| to |e|'s [=FetchEvent/potential response=].
3019
+
1. If |e|'s <a>canceled flag</a> is set, set |eventCanceled| to true.
3020
+
1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}.
3021
+
3022
+
If |task| is discarded, set |handleFetchFailed| to true.
3023
+
3024
+
The |task| *must* use |activeWorker|'s <a>event loop</a> and the <a>handle fetch task source</a>.
3008
3025
3009
3026
1. Wait for |task| to have executed or for |handleFetchFailed| to be true.
3010
3027
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3011
-
1. If |respondWithEntered| is false, then return a [=network error=] if |eventCanceled| is true and null otherwise.
3012
-
1. If |handleFetchFailed| is true, then return a [=network error=].
3028
+
1. If |respondWithEntered| is false, then:
3029
+
1. If |eventCanceled| is true, then:
3030
+
1. If |eventHandled| is not null, then [=reject=] |eventHandled| with a "{{NetworkError}}" {{DOMException}} in |workerRealm|.
3031
+
2. Return a [=network error=].
3032
+
1. If |eventHandled| is not null, then [=resolve=] |eventHandled|.
3033
+
1. Return null.
3034
+
1. If |handleFetchFailed| is true, then:
3035
+
1. If |eventHandled| is not null, then [=reject=] |eventHandled| with a "{{NetworkError}}" {{DOMException}} in |workerRealm|.
3036
+
2. Return a [=network error=].
3037
+
1. If |eventHandled| is not null, then [=resolve=] |eventHandled|.
0 commit comments