Skip to content

Commit 4b5d041

Browse files
authored
Maintain timing for worker start/ready, for navigation requests. (#1575)
* Maintain timing for worker start/ready, for navigation requests. The timing when worker is started or ready are web-accessible via the navigation timing API (https://w3c.github.io/navigation-timing/). `workerStart` is specified to be the time when the service worker is run. In Chromium and Gecko, `worker ready time` (exposed as `fetchStart`) is set to the right before the time when the Fetch event can be dispatched for the newly created worker. In preparation for w3c/navigation-timing#136
1 parent e005153 commit 4b5d041

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/index.bs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29852985

29862986
: Input
29872987
:: |request|, a [=/request=]
2988+
:: |useHighResPerformanceTimers|, a boolean
29882989
: Output
29892990
:: |response|, a [=/response=]
29902991

@@ -2998,6 +2999,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
29982999
1. Let |preloadResponse| be a new [=promise=].
29993000
1. Let |workerRealm| be null.
30003001
1. Let |eventHandled| be null.
3002+
1. Let |timingInfo| be a new [=service worker timing info=].
30013003
1. Let |fetchInstance| be the instance of the [=/fetch=] algorithm representing the ongoing fetch.
30023004
1. Assert: |request|'s [=request/destination=] is not "<code>serviceworker</code>".
30033005
1. If |request|'s [=request/destination=] is either "<code>embed</code>" or "<code>object</code>", then:
@@ -3046,6 +3048,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
30463048
1. If the result of running the [=Should Skip Event=] algorithm with "fetch" and |activeWorker| is true, then:
30473049
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|.
30483050
1. Return null.
3051+
1. If |useHighResPerformanceTimers| is true, then set |useHighResPerformanceTimers| to |activeWorker|'s [=service worker/global object=]'s [=WorkerGlobalScope/cross-origin isolated capability=].
3052+
1. Let |timingInfo|'s [=service worker timing info/start time=] be the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
30493053
1. If |activeWorker|'s <a>state</a> is "`activating`", wait for |activeWorker|'s <a>state</a> to become "`activated`".
30503054
1. If the result of running the [=Run Service Worker=] algorithm with |activeWorker| is *failure*, then set |handleFetchFailed| to true.
30513055
1. Else:
@@ -3062,6 +3066,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
30623066
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.
30633067
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.
30643068
1. Initialize |e|’s {{FetchEvent/handled}} to |eventHandled|.
3069+
1. Let |timingInfo|'s [=service worker timing info/fetch event dispatch time=] to the [=coarsened shared current time=] given |useHighResPerformanceTimers|.
30653070
1. <a>Dispatch</a> |e| at |activeWorker|'s [=service worker/global object=].
30663071
1. Invoke [=Update Service Worker Extended Events Set=] with |activeWorker| and |e|.
30673072
1. If |e|'s [=FetchEvent/respond-with entered flag=] is set, set |respondWithEntered| to true.
@@ -3072,6 +3077,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
30723077
1. If |response| is null, |request|'s [=request/body=] is not null, and |request|'s [=request/body=]'s [=Body/source=] is null, then:
30733078
1. If |request|'s [=request/body=] is [=Body/unusable=], set |handleFetchFailed| to true.
30743079
1. Else, [=ReadableStream/cancel=] |request|'s [=request/body=] with undefined.
3080+
1. If |response| is not null, then set |response|'s [=response/service worker timing info=] to |timingInfo|.
30753081
1. If |e|'s <a>canceled flag</a> is set, set |eventCanceled| to true.
30763082
1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}.
30773083

0 commit comments

Comments
 (0)