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
1. Let |shouldSoftUpdate| be true if any of the following are true, and false otherwise:
3229
3229
* |request| is a [=non-subresource request=].
3230
3230
* |request| is a [=subresource request=] and |registration| is [=stale=].
3231
+
1. Let |raceResponse| be null.
3231
3232
1. If |activeWorker|'s [=service worker/list of router rules=][=list/is not empty=]:
3232
3233
1. Set |timingInfo|’s [=service worker timing info/worker router evaluation start=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
3233
3234
1. Let |source| be the result of running the [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> and |request|.
1. Set |routedResponse|'s [=service worker timing info=]'s [=service worker timing info/worker final router source=] be set to |result|'s [=race result/used route=].
3288
3289
1. Return |routedResponse|.
3289
3290
1. Assert: |source| is "{{RouterSourceEnum/fetch-event}}"
3290
-
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:
3291
-
3292
-
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.
3293
-
3294
-
1. Let |preloadRequest| be the result of [=request/cloning=] the request |request|.
3295
-
1. Let |preloadRequestHeaders| be |preloadRequest|'s [=request/header list=].
3296
-
1. Let |preloadResponseObject| be a new {{Response}} object associated with a new {{Headers}} object whose [=guard=] is "`immutable`".
3297
-
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=].
3298
-
1. Set |preloadRequest|'s [=service-workers mode=] to "`none`".
3299
-
1. Let |preloadFetchController| be null.
3300
-
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3301
-
1. Set |preloadFetchController| to the result of [=Fetch|fetching=] |preloadRequest|.
3302
-
3303
-
To [=fetch/processResponse=] for |navigationPreloadResponse|, run these substeps:
3304
-
3305
-
1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps.
3306
-
1. Associate |preloadResponseObject| with |navigationPreloadResponse|.
3307
-
1. Resolve |preloadResponse| with |preloadResponseObject|.
3308
-
1. [=If aborted=], then:
3309
-
1. Let |deserializedError| be the result of [=deserialize a serialized abort reason=] given null and |workerRealm|.
3310
-
1. [=fetch controller/Abort=] |preloadFetchController| with |deserializedError|.
3291
+
1. If |request| is a [=navigation request=], |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:
3292
+
1. If |registration|'s [=navigation preload enabled flag=] is set then:
3293
+
3294
+
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.
3295
+
3296
+
1. Let |preloadRequest| be the result of [=request/cloning=] the request |request|.
3297
+
1. Let |preloadRequestHeaders| be |preloadRequest|'s [=request/header list=].
3298
+
1. Let |preloadResponseObject| be a new {{Response}} object associated with a new {{Headers}} object whose [=guard=] is "`immutable`".
3299
+
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=].
3300
+
1. Set |preloadRequest|'s [=service-workers mode=] to "`none`".
3301
+
1. Let |preloadFetchController| be null.
3302
+
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3303
+
1. Set |preloadFetchController| to the result of [=Fetch|fetching=] |preloadRequest|.
3304
+
3305
+
To [=fetch/processResponse=] for |navigationPreloadResponse|, run these substeps:
3306
+
3307
+
1. If |navigationPreloadResponse|'s [=response/type=] is "`error`", reject |preloadResponse| with a `TypeError` and terminate these substeps.
3308
+
1. Associate |preloadResponseObject| with |navigationPreloadResponse|.
3309
+
1. Resolve |preloadResponse| with |preloadResponseObject|.
3310
+
1. [=If aborted=], then:
3311
+
1. Let |deserializedError| be the result of [=deserialize a serialized abort reason=] given null and |workerRealm|.
3312
+
1. [=fetch controller/Abort=] |preloadFetchController| with |deserializedError|.
3313
+
1. Else, a user agent may run the following substeps:
3314
+
3315
+
Note: A user agent may speculatively dispatch a network request in parallel with creating a fetch event in order to minimize the bootstrap cost.
3316
+
3317
+
1. Let |autoPreloadFetchController| be null.
3318
+
1. Set |raceResponse| to be a [=race response=] whose [=race response/value=] is "<code>pending</code>".
3319
+
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3320
+
1. Set |autoPreloadFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |autoPreloadRequestResponse|:
3321
+
1. If |autoPreloadRequestResponse|'s [=response/status=] is [=ok status=], set |raceResponse|'s [=race response/value=] to |autoPreloadRequestResponse|.
3322
+
1. [=If aborted=] and |autoPreloadFetchController| is not null, then:
1. Set |raceResponse| to a [=race response=] whose [=race response/value=] is null.
3325
+
1. Resolve |preloadResponse| with undefined.
3311
3326
1. Else, resolve |preloadResponse| with undefined.
3312
-
1. Let |fetchResult| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and null.
3327
+
1. Let |fetchResult| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
3313
3328
1. If |timingInfo|'s [=service worker timing info/worker final router source=] is not an empty string:
3314
3329
1. Assert |timingInfo|'s [=service worker timing info/worker final router source=] is {{RouterSourceEnum/"network"}}.
3315
3330
1. If |fetchResult| is null, then return |timingInfo|.
0 commit comments