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
* |request| is a [=subresource request=] and |registration| is [=stale=].
3217
3217
1. If |activeWorker|'s [=service worker/list of router rules=][=list/is not empty=]:
3218
3218
1. Let |source| be the result of running the [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> and |request|.
3219
-
1. If |source| is {{RouterSourceEnum/"network"}}:
3220
-
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3221
-
1. Return null.
3222
-
1. Else if |source| is {{RouterSourceEnum/"cache"}}, or |source|["{{RouterSourceDict/cacheName}}"][=map/exists=], then:
3223
-
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3224
-
1. [=map/For each=] |cacheName| → |cache| of the |registration|'s [=service worker registration/storage key=]'s [=name to cache map=].
3225
-
1. If |source|["{{RouterSourceDict/cacheName}}"][=map/exists=] and |source|["{{RouterSourceDict/cacheName}}"][=string/is=] not |cacheName|, [=continue=].
3226
-
1. Let |requestResponses| be the result of running [=Query Cache=] with |request|, a new {{CacheQueryOptions}}, and |cache|.
3227
-
1. If |requestResponses| is an empty [=list=], return null.
3228
-
1. Else:
3229
-
1. Let |requestResponse| be the first element of |requestResponses|.
3230
-
1. Let |response| be |requestResponse|'s response.
3231
-
1. Let |globalObject| be |activeWorker|'s [=service worker/global object=].
3232
-
1. If |globalObject| is null:
3233
-
1. Set |globalObject| to the result of running [=Setup ServiceWorkerGlobalScope=] with |activeWorker|.
3234
-
1. If |globalObject| is null, return null.
3235
-
3236
-
Note: This only creates a ServiceWorkerGlobalScope because CORS checks require that. It is not expected that implementations will actually create a ServiceWorkerGlobalScope here.
3237
-
3238
-
1. If |response|'s [=response/type=] is "`opaque`", and [=cross-origin resource policy check=] with |globalObject|'s [=environment settings object/origin=], |globalObject|, "", and |response|'s [=filtered response/internal response=] returns <b>blocked</b>, then return null.
3239
-
1. Return |response|.
3240
-
1. Return null.
3241
-
1. Else if |source| is {{RouterSourceEnum/"race-network-and-fetch-handler"}}, and |request|'s [=request/method=] is \`<code>GET</code>\` then:
3242
-
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3243
-
1. Let |queue| be an empty [=queue=] of [=/response=].
3244
-
1. Let |raceFetchController| be null.
3245
-
1. Let |raceResponse| be a [=race response=] whose [=race response/value=] is "<code>pending</code>".
3246
-
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3247
-
1. Set |raceFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |raceNetworkRequestResponse|:
3248
-
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then:
3249
-
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|.
3250
-
1. [=queue/Enqueue=] |raceNetworkRequestResponse| to |queue|.
3251
-
1. Otherwise, set |raceResponse|'s [=race response/value=] to a [=network error=].
3252
-
1. [=If aborted=] and |raceFetchController| is not null, then:
1. Set |raceResponse| to a [=race response=] whose [=race response/value=] is null.
3255
-
1. Resolve |preloadResponse| with undefined.
3256
-
1. Run the following substeps [=in parallel=]:
3257
-
1. Let |fetchHandlerResponse| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
3258
-
1. If |fetchHandlerResponse| is not null and not a [=network error=], and |raceFetchController| is not null, [=fetch controller/abort=] |raceFetchController|.
3259
-
1. [=queue/Enqueue=] |fetchHandlerResponse| to |queue|.
3260
-
1. Wait until |queue| is not empty.
3261
-
1. Return the result of [=dequeue=] |queue|.
3262
-
1. Assert: |source| is "{{RouterSourceEnum/fetch-event}}"
3219
+
1. If |source| is non-null, then:
3220
+
1. If |source| is {{RouterSourceEnum/"network"}}:
3221
+
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3222
+
1. Return null.
3223
+
1. Else if |source| is {{RouterSourceEnum/"cache"}}, or |source|["{{RouterSourceDict/cacheName}}"][=map/exists=], then:
3224
+
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3225
+
1. [=map/For each=] |cacheName| → |cache| of the |registration|'s [=service worker registration/storage key=]'s [=name to cache map=].
3226
+
1. If |source|["{{RouterSourceDict/cacheName}}"][=map/exists=] and |source|["{{RouterSourceDict/cacheName}}"][=string/is=] not |cacheName|, [=continue=].
3227
+
1. Let |requestResponses| be the result of running [=Query Cache=] with |request|, a new {{CacheQueryOptions}}, and |cache|.
3228
+
1. If |requestResponses| is an empty [=list=], return null.
3229
+
1. Else:
3230
+
1. Let |requestResponse| be the first element of |requestResponses|.
3231
+
1. Let |response| be |requestResponse|'s response.
3232
+
1. Let |globalObject| be |activeWorker|'s [=service worker/global object=].
3233
+
1. If |globalObject| is null:
3234
+
1. Set |globalObject| to the result of running [=Setup ServiceWorkerGlobalScope=] with |activeWorker|.
3235
+
1. If |globalObject| is null, return null.
3236
+
3237
+
Note: This only creates a ServiceWorkerGlobalScope because CORS checks require that. It is not expected that implementations will actually create a ServiceWorkerGlobalScope here.
3238
+
3239
+
1. If |response|'s [=response/type=] is "`opaque`", and [=cross-origin resource policy check=] with |globalObject|'s [=environment settings object/origin=], |globalObject|, "", and |response|'s [=filtered response/internal response=] returns <b>blocked</b>, then return null.
3240
+
1. Return |response|.
3241
+
1. Return null.
3242
+
1. Else if |source| is {{RouterSourceEnum/"race-network-and-fetch-handler"}}, and |request|'s [=request/method=] is \`<code>GET</code>\` then:
3243
+
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3244
+
1. Let |queue| be an empty [=queue=] of [=/response=].
3245
+
1. Let |raceFetchController| be null.
3246
+
1. Let |raceResponse| be a [=race response=] whose [=race response/value=] is "<code>pending</code>".
3247
+
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3248
+
1. Set |raceFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |raceNetworkRequestResponse|:
3249
+
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then:
3250
+
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|.
3251
+
1. [=queue/Enqueue=] |raceNetworkRequestResponse| to |queue|.
3252
+
1. Otherwise, set |raceResponse|'s [=race response/value=] to a [=network error=].
3253
+
1. [=If aborted=] and |raceFetchController| is not null, then:
1. Set |raceResponse| to a [=race response=] whose [=race response/value=] is null.
3256
+
1. Resolve |preloadResponse| with undefined.
3257
+
1. Run the following substeps [=in parallel=]:
3258
+
1. Let |fetchHandlerResponse| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
3259
+
1. If |fetchHandlerResponse| is not null and not a [=network error=], and |raceFetchController| is not null, [=fetch controller/abort=] |raceFetchController|.
3260
+
1. [=queue/Enqueue=] |fetchHandlerResponse| to |queue|.
3261
+
1. Wait until |queue| is not empty.
3262
+
1. Return the result of [=dequeue=] |queue|.
3263
+
1. Assert: |source| is "{{RouterSourceEnum/fetch-event}}"
3263
3264
1. If |request| is a [=navigation request=], |registration|'s [=navigation preload enabled flag=] is set, |request|'s [=request/method=] is \`<code>GET</code>\`, |registration|'s [=active worker=]'s [=set of event types to handle=][=set/contains=]<code>fetch</code>, and |registration|'s [=active worker=]'s [=all fetch listeners are empty flag=] is not set then:
3264
3265
3265
3266
Note: If the above is true except |registration|'s [=active worker=]'s <a>set of event types to handle</a> **does not** contain <code>fetch</code>, then the user agent may wish to show a console warning, as the developer's intent isn't clear.
0 commit comments