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

Pass in response status to mark resource timing #1468

Merged
merged 5 commits into from
Oct 22, 2022

Conversation

abinpaul1
Copy link
Contributor

@abinpaul1 abinpaul1 commented Jul 9, 2022

These changes are to support addition of http response status code to Perfomance resource timing. Further details are available at w3c/resource-timing#335

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

fetch.bs Outdated Show resolved Hide resolved
Copy link
Collaborator

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

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

Non-authoritative LGTM

fetch.bs Outdated
@@ -5536,6 +5539,9 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:

<li><p>Let <var>status</var> be the HTTP response's status code.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@annevk - Would it make sense to also explicitly set the response's status to |status| here? (maybe as a separate PR)

Copy link
Member

Choose a reason for hiding this comment

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

It might be worth having a follow-up issue on how to better integrate with HTTP or indicate that's what's happening. We basically want to map an HTTP response to a Fetch response. There has been some discussion about this also with the HTTP WG, but I don't think we'll get anything formal out of that.

@yoavweiss
Copy link
Collaborator

Also, we'd want tests and implementation issues before this lands.

fetch.bs Outdated
@@ -301,6 +301,9 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
<dt><dfn export for="response body info" id="fetch-timing-info-decoded-body-size">decoded
size</dfn> (default 0)
<dd>A number.
<dt><dfn export for="response body info" id="fetch-timing-info-response-status">response
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed. You have response's status when you set the report timing steps in fetch response handover. I would add it as another parameter to Mark resource timing.

Also, as we talked on the Chromium CL, I don't think we should automatically make this TAO-protected rather than CORS-protected. It's not exactly timing information.

Copy link
Contributor Author

@abinpaul1 abinpaul1 Jul 27, 2022

Choose a reason for hiding this comment

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

Okay, just to be sure I understand. We would pass in the status as a new parameter to Mark resource time which would in turn pass it to Setup the resource timing entry where we would use it to set the entry's responseStatus.

Also, as we talked on the Chromium CL, I don't think we should automatically make this TAO-protected rather than CORS-protected. It's not exactly timing information.

Yeah, we don't want to. I am a bit unsure as to where the exact place to specify this is. Does it make sense to add this to fetch response handover as well - If the CORS check fails pass in 0 as the status to Mark resource timing

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, just to be sure I understand. We would pass in the status as a new parameter to Mark resource time which would in turn pass it to Setup the resource timing entry where we would use it to set the entry's responseStatus.

Exactly

Also, as we talked on the Chromium CL, I don't think we should automatically make this TAO-protected rather than CORS-protected. It's not exactly timing information.

Yeah, we don't want to. I am a bit unsure as to where the exact place to specify this is. Does it make sense to add this to fetch response handover as well - If the CORS check fails pass in 0 as the status to Mark resource timing

Actually I don't think you need to do anything. If this is a no-cors request, response would already be an opaque filtered response with a status of 0.

Copy link
Member

Choose a reason for hiding this comment

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

I think there might be an existing problem here in that an opaque response wouldn't expose body info.

Copy link
Contributor

Choose a reason for hiding this comment

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

We set the body info to an empty body info if TAO fails.

fetch.bs Outdated
@@ -5536,6 +5539,9 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:

<li><p>Let <var>status</var> be the HTTP response's status code.
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth having a follow-up issue on how to better integrate with HTTP or indicate that's what's happening. We basically want to map an HTTP response to a Fetch response. There has been some discussion about this also with the HTTP WG, but I don't think we'll get anything formal out of that.

fetch.bs Outdated
@@ -301,6 +301,9 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
<dt><dfn export for="response body info" id="fetch-timing-info-decoded-body-size">decoded
size</dfn> (default 0)
<dd>A number.
<dt><dfn export for="response body info" id="fetch-timing-info-response-status">response
status</dfn> (default 0)
Copy link
Member

Choose a reason for hiding this comment

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

One minor thing here that I notice is incorrect for some other fields as well is that fetch.bs shouldn't wrap inside phrasing elements such as <dfn> so you can more easily search for the terms inside of them.

fetch.bs Outdated
@@ -301,6 +301,9 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
<dt><dfn export for="response body info" id="fetch-timing-info-decoded-body-size">decoded
size</dfn> (default 0)
<dd>A number.
<dt><dfn export for="response body info" id="fetch-timing-info-response-status">response
Copy link
Member

Choose a reason for hiding this comment

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

I think there might be an existing problem here in that an opaque response wouldn't expose body info.

@abinpaul1 abinpaul1 changed the title Add response status to response body info Pass in response status to mark resource timing Jul 29, 2022
Copy link
Contributor

@noamr noamr left a comment

Choose a reason for hiding this comment

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

Non-authoritative LGTM

fetch.bs Outdated Show resolved Hide resolved
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 30, 2022
This CL introduces a responseStatus field to Performance Resource Timing object.
This field is behind a Runtime Enabled Flag.
Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug:1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 30, 2022
This CL introduces a responseStatus field to Performance Resource
Timing object. This field is behind a Runtime Enabled Flag.

Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug:1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
aarongable pushed a commit to chromium/chromium that referenced this pull request Aug 30, 2022
This CL introduces a responseStatus field to Performance Resource
Timing object. This field is behind a Runtime Enabled Flag.

Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug: 1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3754923
Reviewed-by: Noam Rosenthal <nrosenthal@chromium.org>
Commit-Queue: Abin Paul <abin.paul1@gmail.com>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1040902}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 30, 2022
This CL introduces a responseStatus field to Performance Resource
Timing object. This field is behind a Runtime Enabled Flag.

Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug: 1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3754923
Reviewed-by: Noam Rosenthal <nrosenthal@chromium.org>
Commit-Queue: Abin Paul <abin.paul1@gmail.com>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1040902}
KyleJu pushed a commit to web-platform-tests/wpt that referenced this pull request Aug 30, 2022
This CL introduces a responseStatus field to Performance Resource
Timing object. This field is behind a Runtime Enabled Flag.

Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug: 1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3754923
Reviewed-by: Noam Rosenthal <nrosenthal@chromium.org>
Commit-Queue: Abin Paul <abin.paul1@gmail.com>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1040902}

Co-authored-by: Abin K Paul <abin.paul1@gmail.com>
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 5, 2022
…ing, a=testonly

Automatic update from web-platform-tests
Add response status code to Resource Timing (#34828)

This CL introduces a responseStatus field to Performance Resource
Timing object. This field is behind a Runtime Enabled Flag.

Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug: 1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3754923
Reviewed-by: Noam Rosenthal <nrosenthal@chromium.org>
Commit-Queue: Abin Paul <abin.paul1@gmail.com>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1040902}

Co-authored-by: Abin K Paul <abin.paul1@gmail.com>
--

wpt-commits: 9e8b0dbba979679efc9230834ea89cb3b0f06685
wpt-pr: 34828
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

If you rebase this I think Build will succeed again. There was a temporary issue that is now resolved.

fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated
Comment on lines 4390 to 4394
<li><p>Let <var>responseStatus</var> be 0 if <var>fetchParams</var>'s
<a for="fetch params">request</a>'s <a for=request>mode</a> is "<code>navigate</code>" and
<var>response</var>'s <a for=response>URL</a>'s <a for=url>origin</a> is not
<a>same origin</a> with <var>request</var>'s <a for=request>origin</a>, and
<var>response</var>'s <a for=response>status</a> otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the same origin check here is good. This doesn't take redirects into account.

Also, is this the internal response or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To take redirects into acount, would introducing a new flag to request be a good idea - is navigation same origin. As HTTP fetch step 6.6 we would check if request’s mode is "navigate" and request’s current URL’s origin is same origin with request’s origin. If at any time this is not the case we set is navigation same origin to false.

This flag would then be used instead of the current check. Would this work?

Copy link
Member

Choose a reason for hiding this comment

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

Can we use https://fetch.spec.whatwg.org/#concept-request-tainted-origin? I think request's URL list is still being build up by HTML's navigate algorithm so that should be fine. cc @noamr

Copy link
Contributor Author

@abinpaul1 abinpaul1 Sep 27, 2022

Choose a reason for hiding this comment

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

Okay, so just to be clear we let responseStatus be 0 if request’s mode is "navigate" and request has a redirect-tainted origin?

Also, is this the internal response or not?

I don't think it is the internal response. We want the filtered response's status, so that status would be 0 if its say a no-cors request as well.

Copy link
Member

Choose a reason for hiding this comment

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

I think so, but now I wonder why this is different from the other measurements. If this is specifically for navigation timing it should probably follow the current model for those. cc @noamr

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not about navigation timing but about iframe navigations being reported to their parent. Since they cannot be CORS fetches, we don't want to report their status if they are cross origin.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but don't we have existing infrastructure for that which needs to meet the same constraints?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't believe we do, but I could be wrong. Are you aware of such infrastructure?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@yoavweiss
Copy link
Collaborator

A rough sketch of using existing infrastructure:

@abinpaul1 @annevk - does this make sense?

@annevk
Copy link
Member

annevk commented Oct 7, 2022

Kinda, but then "has cross-origin redirects" needs to be state that Fetch maintains, I suspect. I'm also confused by "navigate an iframe" as I suspect some of those steps also need to apply to embed and object and processing the final response doesn't just result in a report but also needs to actually render something and such.

@abinpaul1
Copy link
Contributor Author

abinpaul1 commented Oct 11, 2022

  • The information regarding if there were any cross origin redirects can be determined if needed in fetch, but currently its stored in the has cross-origin redirects boolean on navigation params struct in HTML.
  • I could see this boolean is used mainly in two places ([1], [2]). In both these places we also have access to the response as navigation param's response.
  • Is it possible to consider moving the has cross-origin redirects boolean as a field to the response? Its value could be determined in the Fetch spec and it could be used as needed in the above two places as well and for our use case as well. This would maybe help us to easily reuse the boolean without having to pass it along to different algorithms.

@annevk @yoavweiss

mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
This CL introduces a responseStatus field to Performance Resource
Timing object. This field is behind a Runtime Enabled Flag.

Resource Timing PR : w3c/resource-timing#335
Fetch PR : whatwg/fetch#1468

Bug: 1343293
Change-Id: I60d1b6ba00f055481ca526a490144d88ddaf881b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3754923
Reviewed-by: Noam Rosenthal <nrosenthal@chromium.org>
Commit-Queue: Abin Paul <abin.paul1@gmail.com>
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1040902}
NOKEYCHECK=True
GitOrigin-RevId: fe7385a80df9cb4f7b7bc07609f3ac8228281541
@annevk
Copy link
Member

annevk commented Oct 17, 2022

Yeah that seems reasonable. And since we copy request's URL list over to the eventual response we might be able to reuse part of https://fetch.spec.whatwg.org/#concept-request-tainted-origin somehow.

(Apologies for taking so long. In the future please bug me on Matrix if I'm not responsive. Or ask the design question there as others might be able to answer as well.)

@abinpaul1
Copy link
Contributor Author

abinpaul1 commented Oct 18, 2022

Have added the has-cross-origin-redirects boolean to the response. I'll also modify html spec to reuse this in place of has cross-origin redirects boolean on navigation params. Building html spec seems to be failing since it can't reference this new boolean.

@annevk
Copy link
Member

annevk commented Oct 19, 2022

In HTML you have to explicitly add the reference (search for data-x-href). If you cannot figure it out please PR what you do have and ask for help. Should not be too hard to get it all working. (Also, if it was not HTML it would be somewhat expected that CI fails and we just have to land things carefully with some delay so there's time for indexing the new terms.)

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This looks perfect, let me know when there's an HTML PR up.

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Oct 19, 2022
@abinpaul1
Copy link
Contributor Author

@annevk Thanks for the pointer. I've opened the HTML PR with the changes. whatwg/html#8405

@annevk
Copy link
Member

annevk commented Oct 21, 2022

@abinpaul1 can you file bugs on Gecko and WebKit? That's the last thing remaining here.

@abinpaul1
Copy link
Contributor Author

Filed the bugs

<li><p>Let <var>responseStatus</var> be 0 if <var>fetchParams</var>'s
<a for="fetch params">request</a>'s <a for=request>mode</a> is "<code>navigate</code>" and
<var>response</var>'s <a for=response>has-cross-origin-redirects</a> is true; otherwise
<var>response</var>'s <a for=response>status</a>.
Copy link
Member

Choose a reason for hiding this comment

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

I was about to merge this, but I don't understand how this protects the response status when mode isn't "navigate". Shouldn't we be using the timing allow passed flag in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As noted in #1468 (comment), wouldn't the response be a filtered response here thereby protecting the response status?

@annevk annevk merged commit 7c30987 into whatwg:main Oct 22, 2022
annevk pushed a commit to whatwg/html that referenced this pull request Oct 22, 2022
@abinpaul1 abinpaul1 deleted the resource-response-status branch October 22, 2022 07:17
@annevk annevk removed the do not merge yet Pull request must not be merged per rationale in comment label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants