Repository navigation
script: Inherit initiator origin when loading about:blank and about:srcdoc - #47630
Conversation
|
🔨 Triggering try run (#33262851349) for Linux (WPT) |
|
Test results for linux-wpt from try job (#33262851349): Flaky unexpected result (29)
Stable unexpected results that are known to be intermittent (22)
|
|
✨ Try run (#33262851349) succeeded. |
| LoadOrigin::Script(ref snapshot) => { | ||
| Some(MutableOrigin::from_snapshot(snapshot.clone())) | ||
| }, | ||
| LoadOrigin::Script(ref snapshot) => Some( | ||
| self.parent_info | ||
| .and_then(ScriptThread::find_document) | ||
| .map(|document| document.origin().clone()) | ||
| .unwrap_or_else(|| MutableOrigin::from_snapshot(snapshot.clone())), | ||
| ), |
There was a problem hiding this comment.
I am very confused why this change is correct, since we're supposed to be using the snapshot of the initiator's origin, not whatever the document's origin currently is. I think this actually points to some code that initiated the navigation providing the wrong origin in the LoadOrigin.
There was a problem hiding this comment.
I think the change isn't quite correct, because we should probably be using creator_pipeline_id here rather than parent_info. This is trying to fix the concepts summarized by these two notes in the specification:
Origins can be shared, e.g., among multiple Document objects. Furthermore, origins are generally immutable. Only the domain of a tuple origin can be changed, and only through the document.domain API.
The cases that return sourceOrigin result in two Documents that end up with the same underlying origin, meaning that document.domain affects both.
The cases where sourceOrigin is returned from determining the origin (called immediately after this code) are for about:blank and about:srcdoc. In these cases, if either the creating page or the child page modifies document.domain, both origins should be updated (they are aliased and not clones). So it's a snapshot typically, but not in these cases. I believe these are the tests that start failing with the increased security from #47632. This should also be the case for javascript: URLs, but via a different mechanism that I'm still trying to wrap my head around.
bebf873 to
509de80
Compare
|
🔨 Triggering try run (#33299558616) for Linux (WPT) |
|
Test results for linux-wpt from try job (#33299558616): Flaky unexpected result (27)
Stable unexpected results that are known to be intermittent (31)
Stable unexpected results (8)
|
|
|
509de80 to
c83dbc0
Compare
about:blank and about:srcdoc
|
🔨 Triggering try run (#33305511631) for Linux (WPT) |
c83dbc0 to
abd693a
Compare
|
Test results for linux-wpt from try job (#33305511631): Flaky unexpected result (36)
Stable unexpected results that are known to be intermittent (26)
Stable unexpected results (7)
|
|
|
|
I've reworked this change to read |
TimvdLippe
left a comment
There was a problem hiding this comment.
The commit abd693a LGTM. Taking a look at the WindowProxy PR that is the prerequisite, but I am not well-versed in that part of Servo yet.
…cation (servo#47632) This change re-implements the `ProxyTraps` for `WindowProxy` according to the specification which says that they should always take into account same origin concerns. In addition to fixing security and correctness issues, this means that now there is only a single type of `WindowProxy` `ProxyTrap` instead of two, simplifying the code. This change exposes quite a few places that we should be inheriting the `Origin`, but are not properly doing so. servo#47630 is an example of a fix necessary to get more of these tests passing. Testing: This gets many tests passing and reveal quite a few new fails that are progressions. Fixes: servo#28556. Fixes: servo#44669. Fixes: servo#47548. Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Josh Bowman-Matthews <[email protected]>
abd693a to
e7bab65
Compare
| .unwrap_or_else(|| MutableOrigin::from_snapshot(snapshot.clone())), | ||
| ), | ||
| _ => None, | ||
| }; |
There was a problem hiding this comment.
I've worked through the logic that is behind this PR, and it makes sense to me. My only concern is this block right here: I find the logic difficult to follow, because it's trying to account for both the origin aliasing behaviours as well as the origin snapshot case for normal navigations, and this is necessary in this branch because we create the InProgressLoad before branching into the logic for about:blank/about:srcdoc/normal navigation.
I've been playing around with a branch where I replaced ParserContext::load_origin with a Option<MutableOrigin>, and I moved the logic that decides what origin to provide right before each ParserContext::new. This makes the normal navigation logic very straightforward:
let source_origin = match incomplete.load_data.load_origin {
LoadOrigin::Script(ref snapshot) => {
Some(MutableOrigin::from_snapshot(snapshot.clone()))
},
_ => None,
};It then becomes easier to focus on the logic for when to use origin aliasing. I'm relatively confident that we can make something that is less complex than the logic right here, but I wouldn't mind if I took that on as a followup.
What do you think?
There was a problem hiding this comment.
Having the ParserContext hold the origin sounds good to me and that was actually the original approach I tried to take. I ran into issues because ParserContext implements FetchResponseListener which needs Send. Since MutableOrigin holds Rc it can't implement send. This approach felt cleaner than putting a Mutex around the origin or making MutableOrigin work across threads.
That said, if you have a better approach I'm all for it. My main concern is ensuring that the behavior is correct (fixing the tests that I broke when working on WindowProxy) and also that things are readable. I think long term, pages like about:blank and javascript: URLs shouldn't even use the ParserContext (once we more faithfully implement the navigation specification), so in a sense making this work properly for ParserContext is a temporary change.
It wasn't clear from your message how you'd like things to land and if you'd like to work on the followup or if you'd like me to, but either thing is absolutely fine with me. I'm just a little nervous about having this behavior be broken by my change for too long.
There was a problem hiding this comment.
Your changes in #47777 removed the issue with FetchResponseListener, so the changes to store the origin are now striaghtforward!
There was a problem hiding this comment.
If you're ok with following my suggestion, I can do the followup of trying to simplify the logic for the about:blank and about:srcdoc cases.
There was a problem hiding this comment.
Okay. I've tried to follow your suggestion in the latest version of this change. PTAL.
The [specification] says that `about:blank` and `about:srcdoc` should inherit their source origin. This means that instead of always creating a new opaque origin in the parser for these kind of pages, we should try harder to preserve the source origin. [specification]: https://html.spec.whatwg.org/multipage/#determining-the-origin Signed-off-by: Martin Robinson <[email protected]>
f945481 to
3cc7054
Compare
|
🔨 Triggering try run (#33951463550) for Linux (WPT) |
jdm
left a comment
There was a problem hiding this comment.
Thanks; I find this revision much clearer to follow!
|
|
|
Ok, if you would rather merge the known-good previous version, I don't mind. I can look at trying to get this version to work as a follow up. |
…nd `about:` URLs Signed-off-by: Martin Robinson <[email protected]>
I think the issue was that I neglected to fall back to the snapshotted origin in the |
|
🔨 Triggering try run (#33978685590) for Linux (WPT) |
|
✨ Try run (#33978685590) succeeded. |
…cation (servo#47632) This change re-implements the `ProxyTraps` for `WindowProxy` according to the specification which says that they should always take into account same origin concerns. In addition to fixing security and correctness issues, this means that now there is only a single type of `WindowProxy` `ProxyTrap` instead of two, simplifying the code. This change exposes quite a few places that we should be inheriting the `Origin`, but are not properly doing so. servo#47630 is an example of a fix necessary to get more of these tests passing. Testing: This gets many tests passing and reveal quite a few new fails that are progressions. Fixes: servo#28556. Fixes: servo#44669. Fixes: servo#47548. Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Josh Bowman-Matthews <[email protected]>
…t:srcdoc` (servo#47630) The [specification] says that `about:blank` and `about:srcdoc` should inherit their source origin. This means that instead of always creating a new opaque origin in the parser for these kind of pages, we should try harder to preserve the source origin. [specification]: https://html.spec.whatwg.org/multipage/#determining-the-origin Testing: This will cause more tests to pass once servo#47632 lands. --------- Signed-off-by: Martin Robinson <[email protected]> Signed-off-by: Martin Robinson <[email protected]>
…cation (servo#47632) This change re-implements the `ProxyTraps` for `WindowProxy` according to the specification which says that they should always take into account same origin concerns. In addition to fixing security and correctness issues, this means that now there is only a single type of `WindowProxy` `ProxyTrap` instead of two, simplifying the code. This change exposes quite a few places that we should be inheriting the `Origin`, but are not properly doing so. servo#47630 is an example of a fix necessary to get more of these tests passing. Testing: This gets many tests passing and reveal quite a few new fails that are progressions. Fixes: servo#28556. Fixes: servo#44669. Fixes: servo#47548. Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Josh Bowman-Matthews <[email protected]>
…t:srcdoc` (servo#47630) The [specification] says that `about:blank` and `about:srcdoc` should inherit their source origin. This means that instead of always creating a new opaque origin in the parser for these kind of pages, we should try harder to preserve the source origin. [specification]: https://html.spec.whatwg.org/multipage/#determining-the-origin Testing: This will cause more tests to pass once servo#47632 lands. --------- Signed-off-by: Martin Robinson <[email protected]> Signed-off-by: Martin Robinson <[email protected]>
… and `about:srcdoc` (servo#47630) (linux-wpt) {"fail_fast": false, "matrix": [{"name": "Linux (WPT)", "workflow": "linux", "wpt": true, "profile": "checked-release", "unit_tests": false, "devtools_tests": false, "build_libservo": false, "bencher": false, "coverage": false, "capi": false, "build_args": "", "wpt_args": "", "number_of_wpt_chunks": 20}]}
…to specification (#47632) This change re-implements the `ProxyTraps` for `WindowProxy` according to the specification which says that they should always take into account same origin concerns. In addition to fixing security and correctness issues, this means that now there is only a single type of `WindowProxy` `ProxyTrap` instead of two, simplifying the code. This change exposes quite a few places that we should be inheriting the `Origin`, but are not properly doing so. #47630 is an example of a fix necessary to get more of these tests passing. Testing: This gets many tests passing and reveal quite a few new fails that are progressions. Fixes: #28556. Fixes: #44669. Fixes: #47548. Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Josh Bowman-Matthews <[email protected]> (cherry picked from commit dfac8fa)
… and `about:srcdoc` (#47630) The [specification] says that `about:blank` and `about:srcdoc` should inherit their source origin. This means that instead of always creating a new opaque origin in the parser for these kind of pages, we should try harder to preserve the source origin. [specification]: https://html.spec.whatwg.org/multipage/#determining-the-origin Testing: This will cause more tests to pass once #47632 lands. --------- Signed-off-by: Martin Robinson <[email protected]> Signed-off-by: Martin Robinson <[email protected]> (cherry picked from commit fb160c4)
The specification says that
about:blankandabout:srcdocshouldinherit their source origin. This means that instead of always creating
a new opaque origin in the parser for these kind of pages, we should try
harder to preserve the source origin.
Testing: This will cause more tests to pass once #47632 lands.