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
Service workers mark certain points in time that are later exposed by the <a interface lt="PerformanceNavigationTiming">navigation timing</a> API.
244
+
Service workers mark certain points in time that are later exposed by the <a interface lt="PerformanceNavigationTiming">navigation timing</a> API and <a interface lt="PerformanceResourceTiming">resource timing</a> API.
245
245
246
246
A <dfn export>service worker timing info</dfn> is a [=/struct=]. It has the following [=struct/items=]:
A {{ServiceWorkerGlobalScope}} object has an associated <dfn for="ServiceWorkerGlobalScope">force bypass cache for import scripts flag</dfn>. It is initially unset.
1094
1102
1095
-
A {{ServiceWorkerGlobalScope}} object has an associated <dfn for="ServiceWorkerGlobalScope">race response map</dfn> which is an [=ordered map=] where the [=map/keys=] are [=/requests=] and the [=map/values=] are [=race response=].
1103
+
A {{ServiceWorkerGlobalScope}} object has an associated <dfn for="ServiceWorkerGlobalScope">race response map</dfn> which is an [=ordered map=] where the [=map/keys=] are [=/requests=] and the [=map/values=] are [=/race response=].
1096
1104
1097
1105
A <dfn id="dfn-race-response">race response</dfn> is a [=struct=] used to contain the network response when {{RouterSourceEnum/"race-network-and-fetch-handler"}} performs. It has a <dfn for="race response">value</dfn>, which is a [=/response=], "<code>pending</code>", or null.
* |request| is a [=subresource request=] and |registration| is [=stale=].
3217
3231
1. If |activeWorker|'s [=service worker/list of router rules=][=list/is not empty=]:
3232
+
1. Set |timingInfo|’s [=service worker timing info/worker router evaluation start=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
3218
3233
1. Let |source| be the result of running the [=Get Router Source=] algorithm with |registration|'s <a>active worker</a> and |request|.
3219
3234
1. If |source| is non-null, then:
3235
+
1. Set |timingInfo|'s [=service worker timing info/worker matched router source=] be set to |source|, and [=service worker timing info/worker final router source=] be set to {{RouterSourceEnum/"network"}}.
3220
3236
1. If |source| is {{RouterSourceEnum/"network"}}:
3221
3237
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3222
3238
1. Return null.
3223
3239
1. Else if |source| is {{RouterSourceEnum/"cache"}}, or |source|["{{RouterSourceDict/cacheName}}"][=map/exists=], then:
3224
3240
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
3241
+
1. Set |timingInfo|’s [=service worker timing info/worker cache lookup start=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
3225
3242
1. [=map/For each=] |cacheName| → |cache| of the |registration|'s [=service worker registration/storage key=]'s [=name to cache map=].
3226
3243
1. If |source|["{{RouterSourceDict/cacheName}}"][=map/exists=] and |source|["{{RouterSourceDict/cacheName}}"][=string/is=] not |cacheName|, [=continue=].
3227
3244
1. Let |requestResponses| be the result of running [=Query Cache=] with |request|, a new {{CacheQueryOptions}}, and |cache|.
Note: This only creates a ServiceWorkerGlobalScope because CORS checks require that. It is not expected that implementations will actually create a ServiceWorkerGlobalScope here.
3238
3255
3239
3256
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.
3257
+
1. Set |timingInfo|'s [=service worker timing info/worker final router source=] be set to {{RouterSourceEnum/"cache"}}.
3240
3258
1. Return |response|.
3241
3259
1. Return null.
3242
3260
1. Else if |source| is {{RouterSourceEnum/"race-network-and-fetch-handler"}}, and |request|'s [=request/method=] is \`<code>GET</code>\` then:
3243
3261
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=].
3262
+
1. Let |queue| be an empty [=queue=] of [=race result=].
3245
3263
1. Let |raceFetchController| be null.
3246
3264
1. Let |raceResponse| be a [=race response=] whose [=race response/value=] is "<code>pending</code>".
3247
3265
1. Run the following substeps [=in parallel=], but [=abort when=] |fetchController|'s [=fetch controller/state=] is "<code>terminated</code>" or "<code>aborted</code>":
3248
3266
1. Set |raceFetchController| to the result of calling [=fetch=] given |request|, with [=fetch/processResponse=] set to the following steps given a [=/response=] |raceNetworkRequestResponse|:
3249
3267
1. If |raceNetworkRequestResponse|'s [=response/status=] is [=ok status=], then:
3250
3268
1. Set |raceResponse|'s [=race response/value=] to |raceNetworkRequestResponse|.
3251
-
1. [=queue/Enqueue=] |raceNetworkRequestResponse| to |queue|.
3269
+
1. Let |raceNetworkResult| be a [=race result=] whose [=race result/routed response=] is |raceNetworkRequestResponse| and [=race result/used route=] is {{RouterSourceEnum/"network"}}.
3270
+
1. [=queue/Enqueue=] |raceNetworkResult| to |queue|.
3252
3271
1. Otherwise, set |raceResponse|'s [=race response/value=] to a [=network error=].
3253
3272
1. [=If aborted=] and |raceFetchController| is not null, then:
1. Let |fetchHandlerResponse| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and |raceResponse|.
3259
3278
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|.
3279
+
1. Let |raceFetchHandlerResult| be a [=race result=] whose [=race result/routed response=] is |fetchHandlerResponse| and [=race result/used route=] is {{RouterSourceEnum/"fetch-event"}}.
3280
+
1. [=queue/Enqueue=] |raceFetchHandlerResult| to |queue|.
3261
3281
1. Wait until |queue| is not empty.
3262
-
1. Return the result of [=dequeue=] |queue|.
3282
+
1. Let |result| be the result of [=dequeue=] |queue|.
3283
+
1. Set |timingInfo|'s [=service worker timing info/worker final router source=] be set to |result|'s [=race result/used route=].
3284
+
1. Return |result|'s [=/race response=].
3263
3285
1. Assert: |source| is "{{RouterSourceEnum/fetch-event}}"
3264
3286
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:
1. Let |deserializedError| be the result of [=deserialize a serialized abort reason=] given null and |workerRealm|.
3284
3306
1. [=fetch controller/Abort=] |preloadFetchController| with |deserializedError|.
3285
3307
1. Else, resolve |preloadResponse| with undefined.
3286
-
1. Return the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and null.
3308
+
1. Let |fetchResult| be the result of [=Create Fetch Event and Dispatch=] with |request|, |registration|, |useHighResPerformanceTimers|, |timingInfo|, |workerRealm|, |reservedClient|, |preloadResponse|, and null.
3309
+
1. If |fetchResult| is not null and |timingInfo|'s [=service worker timing info/worker final router source=] is set to {{RouterSourceEnum/"network"}}:
3310
+
1. Set |timingInfo|'s [=service worker timing info/worker final router source=] to {{RouterSourceEnum/"fetch-event"}}.
0 commit comments