-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Create a new reserved environment for cross-origin redirects. #3891
Conversation
Hum, there's a problem here. Is the intent of The current PR will update creation URL after cross-origin redirects but not same-origin ones, which would be too inconsistent. @wanderview @jungkees @jakearchibald what do you think? |
I think the most sane thing is to set the creation URL at the time the settings object is marked execution ready. That would be after all redirects. (FWIW, this is what I implemented in firefox.) I think we discussed this a bit in regard to SharedWorker here: Also a bit in here regarding documents: I'm not sure, though, if the current spec says anything like that. |
I guess since we don't expose reserved clients it may not matter if the creation URL is set earlier. Any redirects should be complete before execution ready is set and causes the client to be exposed. Changing the reserved environment on redirect should update the creation URL prior to execution ready IMO. |
@wanderview Thanks, that makes sense. I'll update the creation URL on redirects. I agree it shouldn't matter if we do that right after the redirect on the reserved client, or right before execution ready, since reserved clients aren't exposed. Setting it after redirect seems good to me because it's where most of the reserved client is created, and the SW spec might try to access the creation URL of the reserved client rather than the request URL. Do you know off-hand if we have WPT for this (Client#url after redirects)? |
Revised. This will need WPT for the service worker spec. I'll work on those soon but would prefer to merge this change in parallel of that if it looks good.. |
I don't see one. And of course we also don't have a WPT test that showing history.pushState() does not change the client.url either. Both of those tests would be great to clarify behavior here. |
Thanks. Another quick question while you're around: do you recall if Client.url for windows is intended to reflect the final response URL (i.e., including respondWith(fetch(url)) or just the request URL after redirects? I know workers are supposed to reflect the response URL (#3771). There was some talk at w3c/ServiceWorker#1031 too. Yea.. WPT would be good for all this. |
Oh, interesting question. Since window navigation is a special case and does not reflect the final URL provided to I think that is what we implemented in firefox. See the navigation check here: (The comment isn't making sense to me right now, though.) The client.url is then set to nsIDocument::GetOriginalURI() which is the after-redirect URL of the document: |
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#585738}
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#585738}
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#585738}
In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#585738}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unclear why we need request cloning here and manipulation of request's URL list. It seems too much of Fetch is creeping into the navigate algorithm.
source
Outdated
<span data-x="concept-environment-creation-url">creation URL</span> matches a service worker | ||
registration. <ref spec="SW"></p> | ||
</li> | ||
<li><p>Repeat the following steps until <var>done</var> is true:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While done is false*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, since this has more than one nested element the <p>
needs to be newlined
source
Outdated
@@ -2830,10 +2830,13 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute | |||
data-x-href="https://fetch.spec.whatwg.org/#concept-request">request</dfn> and its associated: | |||
<ul class="brief"> | |||
<li><dfn data-x="concept-request-url" data-x-href="https://fetch.spec.whatwg.org/#concept-request-url">url</dfn></li> | |||
<li><dfn data-x="concept-request-url-list" data-x-href="https://fetch.spec.whatwg.org/#concept-request-url-list">url list</dfn></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL list*
<li><dfn data-x="concept-request-method" data-x-href="https://fetch.spec.whatwg.org/#concept-request-method">method</dfn></li> | ||
<li><dfn data-x="concept-request-header-list" data-x-href="https://fetch.spec.whatwg.org/#concept-request-header-list">header list</dfn></li> | ||
<li><dfn data-x="concept-request-body" data-x-href="https://fetch.spec.whatwg.org/#concept-request-body">body</dfn></li> | ||
<li><dfn data-x="concept-request-client" data-x-href="https://fetch.spec.whatwg.org/#concept-request-client">client</dfn></li> | ||
<li><dfn data-x="concept-request-clone" data-x-href="https://fetch.spec.whatwg.org/#concept-request-clone">clone</dfn></li> | ||
<li><dfn data-x="concept-request-current-url" data-x-href="https://fetch.spec.whatwg.org/#concept-request-current-url">current url</dfn></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current URL
source
Outdated
client</span> to <var>reservedEnvironment</var>.</p></li> | ||
<ol> | ||
<li><p>Let <var>newRequest</var> be a <span data-x="concept-request-clone">clone</span> of | ||
<var>request</var>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing </p>
source
Outdated
<ref spec="CSP"></p> | ||
<li><p>If <var>response</var> is not null, append <var>response</var>'s <span | ||
data-x="concept-response-location-url">location URL</span> to <var>newRequest</var>'s | ||
<span data-x="concept-request-url-list">url list.</span></p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dot outside the span
element.
source
Outdated
|
||
<p>Otherwise:</p> | ||
<li> | ||
<p>If <var>reservedEnvironment</var> is not null, and <var>newRequest's</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
's outside the var
element
source
Outdated
|
||
<li><p>If <var>reservedEnvironment</var> is null, let <var>reservedEnvironment</var> be a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/let/then set/
s/be/to/
source
Outdated
|
||
<li><p>If <var>reservedEnvironment</var> is null, let <var>reservedEnvironment</var> be a new | ||
<span>environment</span>, and set its <span data-x="concept-environment-id">id</span> to a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a new environment whose id is ... and target browsing context is ..."
source
Outdated
<var>browsingContext</var>, then set <var>response</var> to a network error, and set | ||
<var>done</var> to true. <ref spec="CSP"></p></li> | ||
|
||
<li><p>Otherwise:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline <p>
source
Outdated
<li><p>If the <span>Should navigation request of type from source in target be blocked by Content | ||
Security Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon | ||
<var>newRequest</var>, <var>navigationType</var>, <var>sourceBrowsingContext</var>, and | ||
<var>browsingContext</var>, then set <var>response</var> to a network error, and set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link network error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for comma before "and set" as there's only two actions.
(Apologies for the delay here by the way. I overlooked this somehow.) |
… navigation-redirect.https.html., a=testonly Automatic update from web-platform-testsWPT: service worker: Refactor and format navigation-redirect.https.html. In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#585738} -- wpt-commits: 1bc6d9975ef38c3ade2986dff737b4421c6352df wpt-pr: 12610
… navigation-redirect.https.html., a=testonly Automatic update from web-platform-testsWPT: service worker: Refactor and format navigation-redirect.https.html. In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#585738} -- wpt-commits: 1bc6d9975ef38c3ade2986dff737b4421c6352df wpt-pr: 12610
Thank you for the review! Sorry I'm not good at git... looks like I messed up this PR trying to sync with upstream changes. |
Hum, I think I needed this for the "Should navigation request of type from source in target be blocked by Content Security Policy?" step. I thought it should use request with the new URL added to it. But we can't modify request directly here since the Fetch spec also modifies it in HTTP-redirect fetch. However, it looks like https://w3c.github.io/webappsec-csp/#should-block-navigation-request uses "request's URL". There are two problems here:
I guess I can keep CSP as is for this change (keep passing request), and can probably forgo the cloning. |
@annevk thanks, I addressed your feedback. (I think I was able to recover the PR by using git push -f to cancel the previous bad push) |
@annevk: ping. I also have a WPT at https://chromium-review.googlesource.com/c/chromium/src/+/1206054 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a lot better, thanks. Did you file issues against CSP for the issues you found?
Thanks! I will be away for some time but plan to get back to this ASAP. |
Previously, a navigation would create a reserved environment once, and use it for all redirects. This commit changes that so a new environment is created on a cross-origin redirect. This also runs CSP for each redirect, which is probably more correct. Per w3c/ServiceWorker#1316
Thanks! I'm preparing a patch in response to your comments.
Filed w3c/webappsec-csp#343 |
@annevk I believe I addressed your comments. Please take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good, modulo nits. You should also ensure there are two newlines between any </p>
and <ol>
.
I'd love it if @wanderview could have a look as well, given he's somewhat familiar with all this and might be able to spot more.
Thanks @annevk! Updated. @wanderview did you want to look as well? |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Tests already landed? And presumably there's cross-browser support since this is a bug fix.
Thanks! Yes, tests landed in web-platform-tests/wpt@2df7f9f#diff-f23ebe2bdee04a9c0b8ab094be59f318 And yes, I think this was the consensus from previous F2Fs and in the latest issue: |
Great, are there implementation bugs? If those are filed this is ready to land. |
There are bugs against resultingClientId (which the WPT depends on) at:
|
Thanks! |
… navigation-redirect.https.html., a=testonly Automatic update from web-platform-testsWPT: service worker: Refactor and format navigation-redirect.https.html. In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falkenchromium.org> Reviewed-by: Kinuko Yasuda <kinukochromium.org> Reviewed-by: Makoto Shimazu <shimazuchromium.org> Cr-Commit-Position: refs/heads/master{#585738} -- wpt-commits: 1bc6d9975ef38c3ade2986dff737b4421c6352df wpt-pr: 12610 UltraBlame original commit: 3da52ed85a2cb6a6c6b61cb230bd008bb397e629
… navigation-redirect.https.html., a=testonly Automatic update from web-platform-testsWPT: service worker: Refactor and format navigation-redirect.https.html. In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falkenchromium.org> Reviewed-by: Kinuko Yasuda <kinukochromium.org> Reviewed-by: Makoto Shimazu <shimazuchromium.org> Cr-Commit-Position: refs/heads/master{#585738} -- wpt-commits: 1bc6d9975ef38c3ade2986dff737b4421c6352df wpt-pr: 12610 UltraBlame original commit: 3da52ed85a2cb6a6c6b61cb230bd008bb397e629
… navigation-redirect.https.html., a=testonly Automatic update from web-platform-testsWPT: service worker: Refactor and format navigation-redirect.https.html. In preparation for extending or modifying the test to test Client.url and resultingClientId for whatwg/html#3891. Bug: 876223 Change-Id: I50e8b8c21c5f8639a24a9c2ec00df3ccafdc8ac8 Reviewed-on: https://chromium-review.googlesource.com/1184656 Commit-Queue: Matt Falkenhagen <falkenchromium.org> Reviewed-by: Kinuko Yasuda <kinukochromium.org> Reviewed-by: Makoto Shimazu <shimazuchromium.org> Cr-Commit-Position: refs/heads/master{#585738} -- wpt-commits: 1bc6d9975ef38c3ade2986dff737b4421c6352df wpt-pr: 12610 UltraBlame original commit: 3da52ed85a2cb6a6c6b61cb230bd008bb397e629
Previously, a navigation would create a reserved environment once,
and use it for all redirects. This commit changes that so
a new environment is created on a cross-origin redirect.
This also runs CSP for each redirect, which is probably more
correct.
Per w3c/ServiceWorker#1316
/browsing-the-web.html ( diff )
/infrastructure.html ( diff )