Skip to content
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

workerStart and redirects #131

Open
wants to merge 20 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 90 additions & 52 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
'resource-timing-2#dom-performanceresourcetiming-secureconnectionstart'>
secureConnectionStart</a> attribute is now mandatory.
</li>
<li>exposes <a data-link-for=
"PerformanceNavigationTiming">workerStart</a></li>
</ul>
</section>
<section id="introduction" class='informative'>
Expand Down Expand Up @@ -302,18 +304,27 @@ <h3>
{{DOMString}} "<code>navigation</code>".
</li>
<li>The <dfn id='dom-PerformanceNavigationTiming-workerStart'><code>
workerStart</code></dfn> attribute MUST return the time immediately
before the user agent <a data-cite=
"service-workers#run-service-worker">ran the worker</a> (if the
<a>current document</a> has an <a data-cite=
"service-workers#dfn-containing-service-worker-registration">active
service worker registration</a> [[SERVICE-WORKERS]]) required to
service the request, or if the worker was already available, the
time immediately before the user agent <a data-cite=
"service-workers#fetchevent">fired an event named `fetch`</a> at
the <a data-cite="service-workers#dfn-active-worker">active
worker</a>. Otherwise, if there is no active worker this attribute
MUST return zero.
workerStart</code></dfn> attribute getter does the following:
<ul>
<li>If the <a>current document</a> has no <a data-cite=
"service-workers#dfn-containing-service-worker-registration">active
service worker registration</a> [[SERVICE-WORKERS]], this attribute MUST
return zero.</li>
<li>If there were redirects, this attribute MUST return a {{DOMHighResTimeStamp}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think these if statements are a bit hard to follow. In this if statement, we only see If there were redirect but the condition is more than that: there were redirects and we had to run a worker? Or am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words it seems this should be split into two, similar to the next two ifs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, to simplify it maybe something like:

If there were redirects, this attribute MUST return a {{DOMHighResTimeStamp}}
with the `workerStart` time recorded by the first request in final same-origin redirect chain.

Or is that too much of a circular dependency?

with a time immediately before the user agent <a data-cite=
"service-workers#run-service-worker">ran the worker</a> for
the first request in final same-origin redirect
chain.</li>
<li>If the worker was already available, this attribute MUST return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these last two be just the time immediately before we run the worker, or are we afraid it won't be called? I see that run the worker can be called when it already started. And also while at it, does the final in the redirect chain make sense for case where there's no redirect? (In that case we can merge almost all of this).

That said this is good for clarity at least, so I'd be fine leaving it as explicit as it is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current version of the spec has the two scenarios split out, so I was keeping that differentiation for clarity:

The workerStart attribute MUST return the time immediately before the user agent ran the worker (if the current document has an active service worker registration [SERVICE-WORKERS]) required to service the request, or if the worker was already available, the time immediately before the user agent fired an event named fetch at the active worker

And also while at it, does the final in the redirect chain make sense for case where there's no redirect

That clause is only in the "If there were redirects..." bullet, which I think makes sense to split it out based on the processing model.

I don't have a strong opinion so if you think it's clearer some other way that's fine.

a {{DOMHighResTimeStamp}} with a time immediately before the user agent <a data-cite=
"service-workers#fetchevent">fired an event named `fetch`</a> at
the <a data-cite="service-workers#dfn-active-worker">active
worker.</a></li>
<li>Otherwise, this attribute MUST return a {{DOMHighResTimeStamp}} with a
time immediately before the user agent <a data-cite=
"service-workers#run-service-worker">ran the worker</a> required to
service the request.</li>
</ul>
</li>
</ul>
<p class="note">
Expand Down Expand Up @@ -363,8 +374,7 @@ <h3>
</p>
<ol>
<li>If there is no previous document, or if the <a>same-origin
check</a> fails, return a {{DOMHighResTimeStamp}} with a time value
equal to zero.
check</a> fails, return zero.
</li>
<li>Otherwise, return a <a data-cite=
"hr-time-2#dom-domhighrestimestamp">DOMHighResTimeStamp</a> with a
Expand All @@ -380,8 +390,7 @@ <h3>
</p>
<ol>
<li>If there is no previous document, or if the <a>same-origin
check</a> fails, return a {{DOMHighResTimeStamp}} with a time value
equal to zero.
check</a> fails, return zero.
</li>
<li>Otherwise, return a {{DOMHighResTimeStamp}} with a time value
equal to the time immediately before the user agent starts the
Expand Down Expand Up @@ -440,18 +449,15 @@ <h3>
The <dfn>loadEventStart</dfn> attribute MUST return a <a data-cite=
"hr-time-2#dom-domhighrestimestamp">DOMHighResTimeStamp</a> with a
time value equal to the time immediately before the load event of the
<a>current document</a> is fired. It MUST return a <a data-cite=
"hr-time-2#dom-domhighrestimestamp">DOMHighResTimeStamp</a> with a
time value equal to zero when the load event is not fired yet.
<a>current document</a> is fired. It MUST return zero when the
load event is not fired yet.
</p>
<p data-dfn-for='PerformanceNavigationTiming'>
The <dfn>loadEventEnd</dfn> attribute MUST return a <a data-cite=
"hr-time-2#dom-domhighrestimestamp">DOMHighResTimeStamp</a> with a
time value equal to the time when the load event of the <a>current
document</a> is completed. It MUST return a <a data-cite=
"hr-time-2#dom-domhighrestimestamp">DOMHighResTimeStamp</a> with a
time value equal to zero when the load event is not fired or is not
completed.
document</a> is completed. It MUST return zero when the load
event is not fired or is not completed.
</p>
<p data-dfn-for='PerformanceNavigationTiming'>
The <dfn>type</dfn> attribute MUST return a {{DOMString}} describing
Expand Down Expand Up @@ -509,7 +515,7 @@ <h4>
<dfn>navigate</dfn>
</dt>
<dd>
Navigation where the
Navigation where the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
is set to
<a data-cite="HTML/browsing-the-web.html#hh-default">"default"</a>
Expand All @@ -521,7 +527,7 @@ <h4>
<dfn>reload</dfn>
</dt>
<dd>
Navigation where the
Navigation where the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
is set to
<a data-cite="HTML/browsing-the-web.html#hh-reload">"reload"</a>.
Expand All @@ -530,7 +536,7 @@ <h4>
<dfn>back_forward</dfn>
</dt>
<dd>
Navigation where the
Navigation where the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
is set to
<a data-cite="HTML/browsing-the-web.html#hh-entry-update">"entry update"</a>.
Expand Down Expand Up @@ -566,7 +572,7 @@ <h3>
This figure illustrates the timing attributes defined by the
{{PerformanceNavigationTiming}} interface. Attributes in
parenthesis indicate that they may not be available for navigations
involving documents from different <a data-cite=
involving documents or redirects from different <a data-cite=
"html#concept-origin" title='origin'>origins</a>.
</figcaption>
<!-- Source: https://docs.google.com/document/d/1I7XGNJ57Qgjkg9pL11s7MK7zGEcwAgdNj1W5f7NKbW8/ -->
Expand Down Expand Up @@ -616,30 +622,30 @@ <h3>
<li>Set <a>entryType</a> and <a>initiatorType</a> to the
{{DOMString}} "<code>navigation</code>".
</li>
<li>Set {{startTime}} to a {{DOMHighResTimeStamp}} with a time value
of zero, and <a data-cite=
<li>Set {{startTime}} to zero, and <a data-cite=
"resource-timing-2#dom-performanceresourcetiming-nexthopprotocol"><code>
nextHopProtocol</code></a> to the empty {{DOMString}}.
</li>
<li>Let |lastWorkerStartOrigin| be the [=opaque origin=].</li>
<li>Record the current navigation type in <a data-link-for=
"PerformanceNavigationTiming">type</a> if it has not been set:
<ol style="list-style-type:lower-alpha ;">
<li>If the navigation has the
<li>If the navigation has the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
set to
<a data-cite="HTML/browsing-the-web.html#hh-default">"default"</a>
or <a data-cite="HTML/browsing-the-web.html#hh-replace">"replace"</a>,
let the navigation type be the {{DOMString}}
"<a data-link-for="NavigationType">navigate</a>".
</li>
<li>If the navigation has the
<li>If the navigation has the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
set to
<a data-cite="HTML/browsing-the-web.html#hh-reload">"reload"</a>,
let the navigation type be
the {{DOMString}} "<a data-link-for="NavigationType">reload</a>".
</li>
<li>If the navigation has the
<li>If the navigation has the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
set to
<a data-cite="HTML/browsing-the-web.html#hh-entry-update">"entry update"</a>,
Expand All @@ -652,24 +658,50 @@ <h3>
fails, set both <a data-link-for=
"PerformanceNavigationTiming">unloadEventStart</a> and
<a data-link-for="PerformanceNavigationTiming">unloadEventEnd</a> to
0 then go to <a href="#fetch-start-step">fetch-start-step</a>.
0 then go to <a href="#worker-start-step">worker-start-step</a>.
Otherwise, record <a data-link-for=
"PerformanceNavigationTiming">unloadEventStart</a> as the time
immediately before the unload event.
</li>
<li>Immediately after the unload event is completed, record the
current time as <a data-link-for=
"PerformanceNavigationTiming">unloadEventEnd</a>. If the navigation
URL has an <a data-cite="service-workers#dfn-active-worker">active
worker registration</a>, immediately before the user agent
<a data-cite="service-workers#run-service-worker">runs the worker</a>
record the time as {{workerStart}}, or if the worker is available,
record the time before the <a data-cite=
"service-workers#on-fetch-request-algorithm">event named `fetch` is
fired</a> at the active worker. Otherwise, if the navigation URL has
no matching <a data-cite=
"service-workers#dfn-service-worker-registration">service worker
registration</a>, set {{workerStart}} value to zero.
"PerformanceNavigationTiming">unloadEventEnd</a>.
</li>
<li id="worker-start-step">
nicjansma marked this conversation as resolved.
Show resolved Hide resolved
<i>[worker-start-step]</i>
<ul>
<li>If the [=request/current url=]
has no matching <a data-cite=
"service-workers#dfn-service-worker-registration">service worker
registration</a>, set {{workerStart}} to a {{DOMHighResTimeStamp}}
with a time value of 0, and go to the
nicjansma marked this conversation as resolved.
Show resolved Hide resolved
<a href="#fetch-start-step">fetch-start-step</a>.</li>
<li>
If the [=request/current url=] has an <a data-cite="service-workers#dfn-active-worker">active
worker registration</a>:
<ul>
nicjansma marked this conversation as resolved.
Show resolved Hide resolved
<li>Let |worker| be the registration's active worker</li>
<li>If |lastWorkerStartOrigin| is not equal to the [=request/current url=]'s origin, set {{workerStart}} to a {{DOMHighResTimeStamp}}
with a time value of 0.</li>
nicjansma marked this conversation as resolved.
Show resolved Hide resolved
<li>If the user agent has not yet
<a data-cite="service-workers#run-service-worker">run the worker</a>,
immediately before the user agent
<a data-cite="service-workers#run-service-worker">runs the worker</a>:
<ol>
<li>Record the time as {{workerStart}}</dfn>.</li>
<li>Let |lastWorkerStartOrigin| be the [=request/current url=]'s origin.</li>
<li>Go to the <a href="#fetch-start-step">fetch-start-step</a>.</li>
</ol>
</li>
<li>If |lastWorkerStartOrigin| is equal to the [=request/current url=]'s origin, go to the
<a href="#fetch-start-step">fetch-start-step</a>.</li>
<li>If the worker is available, immediately before the <a data-cite=
"service-workers#on-fetch-request-algorithm">event named `fetch` is
fired</a> at the worker, record the time as {{workerStart}}.</li>
nicjansma marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</li>
</ul>
</li>
<li id="fetch-start-step">
<i>[fetch-start-step]</i> If the new resource is to be fetched
Expand Down Expand Up @@ -801,10 +833,10 @@ <h3>
redirectEnd</code></a>, <a data-link-for=
"PerformanceNavigationTiming">unloadEventStart</a>,
<a data-link-for=
"PerformanceNavigationTiming">unloadEventEnd</a> and
<a data-link-for=
"PerformanceNavigationTiming">unloadEventEnd</a>
and <a data-link-for=
"PerformanceNavigationTiming">redirectCount</a> to 0. Then,
return to <a href="#fetch-start-step">fetch-start-step</a> with
return to <a href="#worker-start-step">worker-start-step</a> with
the new resource.
</li>
<li>Increment <a data-link-for=
Expand Down Expand Up @@ -835,9 +867,11 @@ <h3>
<a data-cite=
"resource-timing-2#dom-performanceresourcetiming-nexthopprotocol">
<code>nextHopProtocol</code></a>, <a data-link-for=
"PerformanceNavigationTiming">unloadEventStart</a> and
"PerformanceNavigationTiming">unloadEventStart</a>,
<a data-link-for=
"PerformanceNavigationTiming">unloadEventEnd</a> and
<a data-link-for=
"PerformanceNavigationTiming">unloadEventEnd</a>. Set
"PerformanceNavigationTiming">workerStart</a>. Set
<a data-cite=
nicjansma marked this conversation as resolved.
Show resolved Hide resolved
"resource-timing-2#dom-performanceresourcetiming-nexthopprotocol">
<code>nextHopProtocol</code></a> to the empty {{DOMString}}.
Expand Down Expand Up @@ -913,6 +947,10 @@ <h3>
<a data-cite="FETCH#concept-request">request</a>.
</li>
<li>If <var>request</var>'s <a data-cite=
"FETCH#concept-request-redirect-count">redirect count</a> is zero, return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem quite right as this check seems to also involve the 'previous document' (i.e. the document being unloaded, since unload values rely on this check).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I'm not following -- the "previous document" check is at Step (1), which would return fail. Everything after is either because it's coming from no previous document or the previous document was the same origin, and Steps (2-5) just looks at the current document's redirects.

"pass".
</li>
<li>If <var>request</var>'s <a data-cite=
"FETCH#concept-request-redirect-count">redirect count</a> is not
zero, and all of <var>request</var>'s <a data-cite=
"FETCH#redirect-status">HTTP redirects</a> have the <a data-cite=
Expand Down Expand Up @@ -1445,7 +1483,7 @@ <h3>
</dt>
<dd>
<p>
Navigation where the
Navigation where the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
is set to
<a data-cite="HTML/browsing-the-web.html#hh-default">"default"</a> or
Expand All @@ -1457,7 +1495,7 @@ <h3>
</dt>
<dd>
<p>
Navigation where the
Navigation where the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
is set to
<a data-cite="HTML/browsing-the-web.html#hh-reload">"reload"</a>.
Expand All @@ -1468,7 +1506,7 @@ <h3>
</dt>
<dd>
<p>
Navigation where the
Navigation where the
<a data-cite="HTML/browsing-the-web.html#history-handling-behavior">history handling behavior</a>
is set to
<a data-cite="HTML/browsing-the-web.html#hh-entry-update">"entry update"</a>.
Expand Down
1,056 changes: 1,052 additions & 4 deletions timestamp-diagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.