Repository navigation
Use the correct origin in fetch - #18882
Conversation
|
Heads up! This PR modifies the following files:
|
|
@bors-servo try |
(WIP) Use the correct origin in fetch Fixes #18147. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18882) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-wpt |
|
So the problem here is always with the case where we have to do cross-origin redirects... somehow the tests do not expect the request's origin to be the original document's URL's origin... |
| let same_origin = location_url.origin() == request.current_url().origin(); | ||
| let same_origin = match request.origin { | ||
| Origin::Origin(ref origin) => *origin == location_url.origin(), | ||
| Origin::Client => false, |
There was a problem hiding this comment.
Why is this correct?
https://fetch.spec.whatwg.org/#concept-request-origin says you are not supposed to have a "client" value at this point in time, so at the very least that FIXME needs to stay.
There was a problem hiding this comment.
Because every time we create a request, we make sure to initialize it with the global's origin, so that the origin can never be client.
|
@bors-servo try |
|
⌛ Trying commit 9b3ddf3 with merge f8ccaae46d88d4be398c94b74113356ff14575d4... |
|
💔 Test failed - linux-rel-wpt |
|
@bors-servo try |
(WIP) Use the correct origin in fetch Fixes #18147. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18882) <!-- Reviewable:end -->
|
💔 Test failed - mac-rel-wpt3 |
|
I think I've found the problem - in HTTP redirect fetch step 10, we shouldn't be using the |
jdm
left a comment
There was a problem hiding this comment.
This looks good if the test fails without this change!
|
@jdm This is actually incredibly hard to test for. You mentioned on IRC:
Turns out the new code does indeed skip over the check at step 7, but then immediately fails at step 8:
The second redirection has the CORS flag set, and does include credentials, so it'll always fail. |
|
So an idea I have here is to check the error message and ensure that it's generating the error message from step 8, instead of step 7. But in order to do so, I'll have to change this line here to return the error that was encountered during fetch, instead of always returning "Network error occurred": servo/components/script/fetch.rs Lines 128 to 142 in a3f2fae |
|
Wow ok, that also comes with another problem - since this error string is specific to Servo, I need to extract this test out of WPT and put it under |
|
Ok, I've looked over the code and I do not believe it's worth all the effort to make a testcase that demonstrates this working correctly. It's particularly challenging because it's only this particular piece of code that gets the origin check wrong; the most important one in main_fetch does it right, which is why the cors flag is set. Therefore, let's remove 91c2b79 (because network errors are supposed to be opaque to content code) and let's remove 833501b as well. r=me with those omissions! |
|
@bors-servo r=jdm |
|
📌 Commit 1c8d049 has been approved by |
Use the correct origin in fetch Fixes #18147. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18882) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Fixes #18147.
This change is