Skip to content

Commit

Permalink
Set Window's timeOrigin to navigation fetch start time
Browse files Browse the repository at this point in the history
There's no need to measure the timestamp during navigation and account for beforeunload prompts. We can just use the start time already measured by Fetch.

This is in line with current WebKit implementation, and very close to Chromium implementation which currently doesn't count beforeunload time as part of the navigation time.

Closes whatwg#7716.
  • Loading branch information
noamr authored May 3, 2022
1 parent 5710d64 commit e33d330
Showing 1 changed file with 21 additions and 41 deletions.
62 changes: 21 additions & 41 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2613,6 +2613,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-request-add-range-header">add a range header</dfn></li>
</ul>
</li>
<li>
<dfn data-x="fetch-timing-info"
data-x-href="https://fetch.spec.whatwg.org/#fetch-timing-info">fetch timing info</dfn> and its
associated:
<ul class="brief">
<li><dfn data-x="fetch-timing-info-start-time" data-x-href="https://fetch.spec.whatwg.org/#fetch-timing-info-start-time">start time</dfn></li>
</ul>
</li>
</ul>

<p>The following terms are defined in <cite>Referrer Policy</cite>: <ref
Expand Down Expand Up @@ -88478,10 +88486,6 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
body</dfn></dt>
<dd>an algorithm expecting a <span data-x="concept-response">response</span></dd>

<dt><dfn data-x="navigation-params-unsafe-start-time">unsafe start time</dfn></dt>
<dd>a number, representing a value of the <span>unsafe shared current time</span> when the
navigation has started</dd>

<dt><dfn data-x="navigation-params-uncommitted-preloads">uncommitted preloads</dfn></dt>
<dd>null or a <span>list</span> of algorithms representing early preloaded links, to be committed
once the <code>Document</code> has been created</dd>
Expand Down Expand Up @@ -88539,8 +88543,6 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
algorithm that does nothing):</p>

<ol>
<li><p>Let <var>unsafeNavigationStartTime</var> be the <span>unsafe shared current time</span>.</p></li>

<li><p>If <var>resource</var> is a <span>URL</span>, then set <var>resource</var> to a new <span
data-x="concept-request">request</span> whose <span data-x="concept-request-url">URL</span> is
<var>resource</var>.</p></li>
Expand Down Expand Up @@ -88672,24 +88674,11 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
to completion.</p>
</li>

<li>
<p>Switch on <var>unloadPromptResult</var>:</p>

<dl class="switch">
<dt>"<code data-x="">no-prompt</code>"</dt>
<dd>Do nothing.</dd>

<dt>"<code data-x="">confirm</code>"</dt>
<dd>Set <var>unsafeNavigationStartTime</var> to the <span>unsafe shared current
time</span>.</dd>

<dt>"<code data-x="">refuse</code>"</dt>
<dd>Return a new <span>WebDriver BiDi navigation status</span> whose <span
data-x="navigation-status-id">id</span> is <var>navigationId</var> and <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-canceled">canceled</code>".</dd>
</dl>
</li>
<li><p>If <var>unloadPromptResult</var> is "<code data-x="">refuse</code>", then return a new
<span>WebDriver BiDi navigation status</span> whose <span
data-x="navigation-status-id">id</span> is <var>navigationId</var> and <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-canceled">canceled</code>".</p></li>

<li><p><span data-x="abort a document">Abort</span> the <span>active document</span> of
<var>browsingContext</var>.</p></li>
Expand Down Expand Up @@ -88792,8 +88781,6 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
<var>historyHandling</var>, <span
data-x="navigation-params-process-response-end-of-body">process response end of body</span>
is <var>processResponseEndOfBody</var>, <span
data-x="navigation-params-unsafe-start-time">unsafe start time</span> is
<var>unsafeNavigationStartTime</var>, <span
data-x="navigation-params-has-cross-origin-redirects">has cross-origin redirects</span> is
false, and <span
data-x="navigation-params-uncommitted-preloads">uncommitted preloads</span> is null.</p></li>
Expand Down Expand Up @@ -88855,8 +88842,6 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
<var>historyHandling</var>, <span
data-x="navigation-params-process-response-end-of-body">process response end of body</span>
is <var>processResponseEndOfBody</var>, <span
data-x="navigation-params-unsafe-start-time">unsafe start time</span> is
<var>unsafeNavigationStartTime</var>, <span
data-x="navigation-params-has-cross-origin-redirects">has cross-origin redirects</span> is
false, and <span
data-x="navigation-params-uncommitted-preloads">uncommitted preloads</span> is null.</p></li>
Expand Down Expand Up @@ -88886,8 +88871,7 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
<var>navigationType</var>, <var>sandboxFlags</var>, <var>historyPolicyContainer</var>,
<var>initiatorPolicyContainer</var>, <var>allowedToDownload</var>,
<var>hasTransientActivation</var>, <var>incumbentNavigationOrigin</var>,
<var>historyHandling</var>, <var>processResponseEndOfBody</var>, and
<var>unsafeNavigationStartTime</var>.</p></dd>
<var>historyHandling</var>, and <var>processResponseEndOfBody</var>.</p></dd>

<dt>Otherwise, <var>resource</var> is a <span data-x="concept-request">request</span> whose
<span data-x="concept-request-url">URL</span>'s <span data-x="concept-url-scheme">scheme</span>
Expand All @@ -88908,9 +88892,9 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
data-x="policy container">policy containers</span> <var>historyPolicyContainer</var> and
<var>initiatorPolicyContainer</var>, a boolean <var>allowedToDownload</var>, a boolean
<var>hasTransientActivation</var>, an <span>origin</span> <var>incumbentNavigationOrigin</var>, a
<span>history handling behavior</span> <var>historyHandling</var>,
<span>history handling behavior</span> <var>historyHandling</var>, and
<var>processResponseEndOfBody</var>, which is an algorithm accepting a <span
data-x="concept-response">response</span>, and a number <var>unsafeNavigationStartTime</var>:</p>
data-x="concept-response">response</span>:</p>

<ol>
<li><p>Let <var>response</var> be null.</p></li>
Expand Down Expand Up @@ -89214,8 +89198,7 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
<var>browsingContext</var>, <span data-x="navigation-params-hh">history handling</span> is
<var>historyHandling</var>, <span
data-x="navigation-params-process-response-end-of-body">process response end of body</span> is
<var>processResponseEndOfBody</var>, <span data-x="navigation-params-unsafe-start-time">unsafe
start time</span> is <var>unsafeNavigationStartTime</var>,
<var>processResponseEndOfBody</var>,
<span data-x="navigation-params-has-cross-origin-redirects">has cross-origin redirects</span> is
<var>hasCrossOriginRedirects</var>, and
<span data-x="navigation-params-uncommitted-preloads">uncommitted preloads</span> is
Expand Down Expand Up @@ -89701,11 +89684,9 @@ interface <dfn interface>Location</dfn> { // but see also <a href="#the-location
</li>

<li><p>Let <var>loadTimingInfo</var> be a new <span>document load timing info</span> with its
<span>navigation start time</span> set to the result of calling <span>coarsen time</span> with
<var>navigationParams</var>'s <span data-x="navigation-params-unsafe-start-time">unsafe start
time</span> and <var>document</var>'s <span>relevant settings object</span>'s <span
data-x="concept-settings-object-cross-origin-isolated-capability">cross-origin isolated
capability</span>.</p></li>
<span>navigation start time</span> set to <var>response</var>'s
<span data-x="concept-response-timing-info">timing info</span>'s
<span data-x="fetch-timing-info-start-time">start time</span>.</p></li>

<li>
<p>Let <var>document</var> be a new <code>Document</code>, whose <span
Expand Down Expand Up @@ -90370,8 +90351,7 @@ new PaymentRequest(&hellip;); // Allowed to use
enforcement result</span>, <span data-x="navigation-params-reserved-environment">reserved
environment</span> is null, <span
data-x="navigation-params-process-response-end-of-body">process response end of body</span> is
an algorithm that does nothing, <span data-x="navigation-params-unsafe-start-time">unsafe start
time</span> is the <span>unsafe shared current time</span>, and <span
an algorithm that does nothing, and <span
data-x="navigation-params-browsing-context">browsing context</span> is
<var>browsingContext</var>.</p>

Expand Down

0 comments on commit e33d330

Please sign in to comment.