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

Report EventSource & track ResourceTiming entries #7553

Merged
merged 10 commits into from
Feb 27, 2022
Merged
Changes from all commits
Commits
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
90 changes: 39 additions & 51 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#ok-status">ok status</dfn></li>
<li><dfn data-x="navigation-request" data-x-href="https://fetch.spec.whatwg.org/#navigation-request">navigation request</dfn></li>
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-network-error">network error</dfn></li>
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-aborted-network-error">aborted network error</dfn></li>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<li>`<dfn data-x="http-origin" data-x-href="https://fetch.spec.whatwg.org/#http-origin"><code>Origin</code></dfn>` header</li>
<li>`<dfn data-x-href="https://fetch.spec.whatwg.org/#http-cross-origin-resource-policy"><code>Cross-Origin-Resource-Policy</code></dfn>` header</li>
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#process-response">process response</dfn></li>
Expand Down Expand Up @@ -34547,7 +34548,7 @@ interface <dfn interface>MediaError</dfn> {
<span>media element</span>'s <span>node document</span>'s <span>relevant settings
object</span>.</p>

domenic marked this conversation as resolved.
Show resolved Hide resolved
<!--FETCH--><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.
<!--FETCH--><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p>

<p>The <var>response</var>'s <span>unsafe response</span> obtained in this fashion, if any,
contains the <span>media data</span>. It can be <span>CORS-same-origin</span> or
Expand Down Expand Up @@ -37818,7 +37819,11 @@ interface <dfn interface>VideoTrack</dfn> {
<code>track</code> element's <span>node document</span>'s <span>relevant settings
object</span>.</p></li>

<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>, with <i
data-x="processResponseEndOfBody">processResponseEndOfBody</i> given <span
data-x="concept-response">response</span> <var>res</var> set to <span>finalize and report
timing</span> with <var>res</var>, the element's <span>node document</span>'s <span>relevant
global object</span>, and "<code data-x="">track</code>".</p></li>
domenic marked this conversation as resolved.
Show resolved Hide resolved
</ol>

<p>The <span data-x="concept-task">tasks</span> <span data-x="queue a task">queued</span> by the
Expand Down Expand Up @@ -100084,12 +100089,42 @@ dictionary <dfn dictionary>EventSourceInit</dfn> {
<li><p>Set <var>ev</var>'s <span data-x="concept-event-stream-request">request</span> to
<var>request</var>.</p></li>

<li><p>Let <var>finalizeEventSourceFetch</var> given <span
data-x="concept-response">response</span> <var>res</var> be to <span>finalize and report
timing</span> with <var>res</var>, <var>settings</var>'s <span
data-x="concept-settings-object-global">global object</span>, and "<code
data-x="">other</code>".</p></li>

<li><p>Let <var>processEventSourceEndOfBody</var> given <span
data-x="concept-response">response</span> <var>res</var> be the following step: if
<var>res</var> is not a <span>network error</span>, then <var>finalizeEventSourceFetch</var>
with <var>res</var>, and <span>reestablish the connection</span>.</p></li>

<li>
<p>Run this step <span>in parallel</span>:</p>
<p><span data-x="concept-fetch">Fetch</span> <var>request</var> with <i
data-x="processResponseEndOfBody">processResponseEndOfBody</i> set to
<var>processEventSourceEndOfBody</var> and <i data-x="process response">processResponse</i> set
to the following steps given <span data-x="concept-response">response</span>
<var>res</var>:</p>

<ol>
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
<li><p>If <var>res</var> is an <span>aborted network error</span>, then <span>fail the
connection</span>.</p></li>

<li><p>Otherwise, if <var>res</var> is a <span>network error</span>, then call
<var>finalizeEventSourceFetch</var> given <var>res</var>, and <span>reestablish the
connection</span>, unless the user agent knows that to be futile, in which case the user agent
may <span>fail the connection</span>.</p></li>

<li><p>Otherwise, if <var>res</var>'s <span data-x="concept-response-status">status</span> is
not 200, or if <var>res</var>'s `<code>Content-Type</code>` is not
`<code>text/event-stream</code>`, then <span>fail the connection</span>.</p>

<li><p>Otherwise, <span>announce the connection</span> and <a
href="#event-stream-interpretation">interpret</a> <var>res</var>'s <span
data-x="concept-response-body">body</span> line by line.</p></li>
</ol>
</li>

<li><p>Return <var>ev</var>.</p></li>
</ol>
Expand Down Expand Up @@ -100162,53 +100197,6 @@ dictionary <dfn dictionary>EventSourceInit</dfn> {

<h4 id="sse-processing-model"><span id="processing-model-9"></span>Processing model</h4>

<p>The resource indicated in the argument to the <code data-x="dom-EventSource">EventSource</code>
constructor is fetched when the constructor is run.</p>

<p>As data is received, the <span data-x="concept-task">tasks</span> queued by the <span>networking
task source</span> to handle the data must act as follows.</p>

<p>HTTP 200 OK responses with a `<code>Content-Type</code>` header specifying the type
`<code>text/event-stream</code>`, ignoring any <span>MIME type</span> parameters, must be
processed line by line <a href="#event-stream-interpretation">as described below</a>.</p>

<p>When a successful response with a supported <span>MIME type</span> is received, such that the
user agent begins parsing the contents of the stream, the user agent must <span>announce the
connection</span>.</p>

<p>The <span data-x="concept-task">task</span> that the <span>networking task source</span> places
on the <span>task queue</span> once fetching for such a resource (with the correct <span>MIME
type</span>) has completed must cause the user agent to <span>reestablish the connection</span>
<span>in parallel</span>. This applies whether the connection is closed gracefully or unexpectedly
(but does not apply when fetching is canceled by the user agent, e.g., in response to <code
data-x="dom-window-stop">window.stop()</code>, since in those cases the final <span
data-x="concept-task">task</span> is actually discarded). It doesn't apply for the error
conditions listed below except where explicitly specified.</p>

<p>HTTP 200 OK responses that have a <span>Content-Type</span> specifying an unsupported type, or
that have no <span>Content-Type</span> at all, must cause the user agent to <span>fail the
connection</span>.</p> <!-- about:blank is defined as having no MIME type -->

<p id="event-source-network-errors-reconnect">Network errors that prevents the connection from
being established in the first place (e.g. DNS errors), should cause the user agent to
<span>reestablish the connection</span> <span>in parallel</span>, unless the user agent knows that
to be futile, in which case the user agent may <span>fail the connection</span>.</p>

<p id="event-source-fail-reasons">Any other HTTP response code not listed here, as well as the
cancelation of the fetch algorithm by the user agent (e.g. in response to <code
data-x="dom-window-stop">window.stop()</code> or the user canceling the network connection
manually) must cause the user agent to <span>fail the connection</span>.</p> <!-- including: HTTP
201 Created, 202 Accepted, 203 Non-Authoritative Information, 204 No Content, 205 Reset Content,
206 Partial Content, 300 Multiple Choices, 304 Not Modified, 400 Bad Request, 403 Forbidden, 404
Not Found, 405 Method Not Allowed, 406 Not Acceptable, 408 Request Timeout, 409 Conflict, 410
Gone, 411 Length Required, 412 Precondition Failed, 413 Request Entity Too Large, 414 Request-URI
Too Long, 415 Unsupported Media Type, 416 Requested Range Not Satisfiable, 417 Expectation Failed,
HTTP 500 Internal Server Error, 501 Not Implemented, 502 Bad Gateway, 503 Service Unavailable, and
504 Gateway Timeout responses, and 505 HTTP Version Not Supported responses --> <!-- mailto: is
defined as equivalent to HTTP 204 -->

<hr>

<p>When a user agent is to <dfn>announce the connection</dfn>, the user agent must <span>queue a
task</span> which, if the <code data-x="dom-EventSource-readyState">readyState</code> attribute is
set to a value other than <code data-x="dom-EventSource-CLOSED">CLOSED</code>, sets the <code
Expand Down