-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify how timeOrigin
is computed
#7339
Conversation
See whatwg/html#7339 `time origin` is now an `environment settings object` algorithm, so the reference here should forward there. Closes #131
source
Outdated
@@ -87911,7 +87940,7 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location | |||
data-x="concept-response-timing-info">timing info</span>, | |||
<span data-x="navigation-params-response">response</span>'s <span | |||
data-x="concept-response-service-worker-timing-info">service worker timing info</span>, | |||
<var>redirectCount</var>, and <var>navigationType</var>.</p></li> | |||
<var>redirectCount</var>, <var>navigationType</var>, and <var>previousTimeOrigin</var>.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to pass the previous time origin because of w3c/navigation-timing#166
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just about to ask the same... Worthwhile to add a note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can you clarify why this is correct? Are we replacing the value later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to adjust the values of the ResourceTiming attributes in navigation timing
. I didn't get to that patch yet...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a note below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm trying to extract the high-level design here:
- We're setting loadTimingInfo's startTime when a new browsing context is created
- When navigating, we set the navigationParams startTime to the moment of the navigation, but then override it after the unload handlers ran.
- When creating and initializing a Document, we keep the time origin of the previous document and use it for initialization.
- At the same time, we use the navigationParams' startTime to initialize the Document's loadTimingInfo.
Is that about right? It might be useful to add a description outlining the role of the environment settings object's time origin
, the navigationParams start time
and the loadTimingInfo's startTime.
source
Outdated
@@ -87911,7 +87940,7 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location | |||
data-x="concept-response-timing-info">timing info</span>, | |||
<span data-x="navigation-params-response">response</span>'s <span | |||
data-x="concept-response-service-worker-timing-info">service worker timing info</span>, | |||
<var>redirectCount</var>, and <var>navigationType</var>.</p></li> | |||
<var>redirectCount</var>, <var>navigationType</var>, and <var>previousTimeOrigin</var>.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just about to ask the same... Worthwhile to add a note?
source
Outdated
@@ -87911,7 +87940,7 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location | |||
data-x="concept-response-timing-info">timing info</span>, | |||
<span data-x="navigation-params-response">response</span>'s <span | |||
data-x="concept-response-service-worker-timing-info">service worker timing info</span>, | |||
<var>redirectCount</var>, and <var>navigationType</var>.</p></li> | |||
<var>redirectCount</var>, <var>navigationType</var>, and <var>previousTimeOrigin</var>.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can you clarify why this is correct? Are we replacing the value later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-authoritative LGTM!!
Thanks for the latest revamp - the handling of unsafe timers is much clearer now
@domenic care to review? |
source
Outdated
unloaded</span>, then return.</p></li> | ||
<li><p>If the result of calling <span>prompt to unload</span> with the | ||
<span>active document</span> of the <var>specified browsing context</var> is | ||
"<code data-x="">refuse</code>", then return.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preexisting problem, but if you could fix while you're here it'd be nice: since we're in a queued task, we use "abort these steps" instead of "return"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I commented on the wrong line. "close a browsing context" should be "return"; "traverse the history by a delta" should be "abort these steps".
The time origin, which is the epoch for all performance timeline APIs, was previously defined [here](https://w3c.github.io/hr-time/#dfn-time-origin). This PR makes its computation explicity, without changing its current definition and behavior. - `time origin` becomes an `environment settings object` algorithm, computed differently for windows vs. worker scopes - The 4 places where this timestamp is set are creation of an `about:blank` context, beginning of navigation, confirmation of an unload prompt, and creating a worker. - The timestamp is a `shared monotonic clock` value, which is defined in HR-TIME (and internally in ECMAScript). As part of this PR, also refactored unload prompts to return a result rather than rely on a somewhat hand-wavy "refused to allow" property. See w3c/hr-time#131 and w3c/navigation-timing#166
In [this HTML PR](whatwg/html#7339) we add a `time origin` getter to the `environment settings object`. We need to account for that value in service workers, which would be the time the worker environment is created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Refactored worker creation time initialization to use closure variables instead of new associated things
- Threaded through
unsafeNavigationStartTime
- Refactored prompt-result switch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray!
* Remove own version of `timeOrigin` definition See whatwg/html#7339 `time origin` is now an `environment settings object` algorithm, so the reference here should forward there. Closes #131 * Refactor and add note
In [this HTML PR](whatwg/html#7339) we add a `time origin` getter to the `environment settings object`. We need to account for that value in service workers, which would be the time the worker environment is created.
The time origin, which is the epoch for all performance timeline APIs,
was previously defined here.
This PR makes its computation explicity, without changing its current
definition and behavior.
time origin
becomes anenvironment settings object
algorithm,computed differently for windows vs. worker scopes
The 4 places where this timestamp is set are creation of an
about:blank
context, beginning of navigation, confirmation of anunload prompt, and creating a worker.
The timestamp is a
shared monotonic clock
value, which is definedin HR-TIME (and internally in ECMAScript).
As part of this PR, also refactored unload prompts to return a result
rather than rely on a somewhat hand-wavy "refused to allow" property.
See w3c/hr-time#131
and w3c/navigation-timing#166
At least two implementers are interested (and none opposed):
Tests are written and can be reviewed and commented upon at:
Implementation bugs are filed:
(See WHATWG Working Mode: Changes for more details.)
/browsers.html ( diff )
/browsing-the-web.html ( diff )
/dom.html ( diff )
/history.html ( diff )
/infrastructure.html ( diff )
/webappapis.html ( diff )
/window-object.html ( diff )
/workers.html ( diff )
/worklets.html ( diff )