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

Resource Timing integration #319

Merged
merged 13 commits into from
Feb 11, 2022
19 changes: 16 additions & 3 deletions xhr.bs
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,10 @@ return <a>this</a>'s <a>cross-origin credentials</a>.
</ol>
</ol>

<p>To <dfn>report timing</dfn> for an {{XMLHttpRequest}} object <var>xhr</var>,
<a for=/>finalize and report timing</a> with <var>xhr</var>'s <a for=XMLHttpRequest>response</a>,
<var>xhr</var>'s <a>relevant global object</a>, and "<code>xmlhttprequest</code>".

<p id=handle-response-end-of-file>To <dfn>handle response end-of-body</dfn> for an
{{XMLHttpRequest}} object <var>xhr</var>, run these steps:

Expand All @@ -963,6 +967,8 @@ return <a>this</a>'s <a>cross-origin credentials</a>.
<li><p>If <var>xhr</var>'s <a for=XMLHttpRequest>response</a> is a <a>network error</a>, then
return.

<li><p><a for=/>Report timing</a> for <var>xhr</var>.

Choose a reason for hiding this comment

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

Could we move this to line 966, and avoid calling report timing from 2 different places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because handle errors needs to report errors only in certain conditions + we need to report it if there are no errors. So there will always be two places

Copy link
Member

Choose a reason for hiding this comment

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

It seems to me we could move this up if we make it conditional upon the timed out flag? (And in the future perhaps the timed out flag can be replaced by using an aborted network error.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah it wouldn't work because handle errors is also called from processBodyError, in which case the processEndOfBody callback will not be reached at all. We've been through this in early iterations of this PR


<li><p>Let <var>transmitted</var> be <var>xhr</var>'s <a>received bytes</a>'s
<a for="byte sequence">length</a>.

Expand Down Expand Up @@ -1001,9 +1007,16 @@ return <a>this</a>'s <a>cross-origin credentials</a>.
<a for=response>aborted flag</a> is set, run the <a>request error steps</a> for <var>xhr</var>,
<a event><code>abort</code></a>, and "{{AbortError!!exception}}" {{DOMException}}.

<li><p>Otherwise, if <var>xhr</var>'s <a for=XMLHttpRequest>response</a>'s is a
<a for=/>network error</a>, run the <a>request error steps</a> for <var>xhr</var>,
<a event><code>error</code></a>, and "{{NetworkError!!exception}}" {{DOMException}}.
<li>
<p>Otherwise, if <var>xhr</var>'s <a for=XMLHttpRequest>response</a> is a
<a for=/>network error</a>, then:

<ol>
<li><p><a for=/>Report timing</a> for <var>xhr</var>.

<li><p>Run the <a>request error steps</a> for <var>xhr</var>,
<a event><code>error</code></a>, and "{{NetworkError!!exception}}" {{DOMException}}.
</ol>
</ol>

<p>The <dfn>request error steps</dfn> for an {{XMLHttpRequest}} object <var>xhr</var>,
Expand Down