-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Implement cross-thread postMessage #15679
Implement cross-thread postMessage #15679
Conversation
Heads up! This PR modifies the following files:
|
cc @jdm |
☔ The latest upstream changes (presumably #15438) made this pull request unmergeable. Please resolve the merge conflicts. |
6ea3d04
to
53043b3
Compare
☔ The latest upstream changes (presumably #14962) made this pull request unmergeable. Please resolve the merge conflicts. |
53043b3
to
73acf86
Compare
73acf86
to
72cd111
Compare
☔ The latest upstream changes (presumably #15536) made this pull request unmergeable. Please resolve the merge conflicts. |
72cd111
to
f560c80
Compare
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.
r=me
@@ -1795,6 +1799,21 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | |||
} | |||
} | |||
|
|||
fn handle_post_message_msg(&mut self, frame_id: FrameId, origin: Option<ImmutableOrigin>, data: Vec<u8>) { | |||
let pipeline_id = match self.frames.get(&frame_id) { | |||
None => return warn!("postMessage to closed frame {}.", frame_id), |
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.
(As a side note, I seriously believe that we should convert all these to panics during testing).
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.
That's an interesting idea. These warnings can happen during correct execution (e.g. post a message to an iframe's content window after it's been removed from the frame tree) but I don't think that should come up in wpt testing. File an issue?
@@ -0,0 +1,13 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> |
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 lot of the tags here (and in the other tests) can go away and would make this a bit less noisy, but your choice :)
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 like my html old skool :)
<body> | ||
<script> | ||
window.addEventListener("message", function(e) { | ||
window.location.href = e.data; |
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.
heh. this is quite tricky. I guess it works :)
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 guess so :)
// child1 is a dissimilar-origin document | ||
var childURL1 = new URL("cross-origin-postMessage-child1.html", document.location); | ||
childURL1.hostname = "127.0.0.1"; | ||
// child2 is a same-orogin document |
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.
typo: origin
.
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.
Oops!
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 for the quick review!
@@ -1795,6 +1799,21 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | |||
} | |||
} | |||
|
|||
fn handle_post_message_msg(&mut self, frame_id: FrameId, origin: Option<ImmutableOrigin>, data: Vec<u8>) { | |||
let pipeline_id = match self.frames.get(&frame_id) { | |||
None => return warn!("postMessage to closed frame {}.", frame_id), |
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.
That's an interesting idea. These warnings can happen during correct execution (e.g. post a message to an iframe's content window after it's been removed from the frame tree) but I don't think that should come up in wpt testing. File an issue?
@@ -0,0 +1,13 @@ | |||
<!DOCTYPE html> | |||
<html> | |||
<head> |
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 like my html old skool :)
<body> | ||
<script> | ||
window.addEventListener("message", function(e) { | ||
window.location.href = e.data; |
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 guess so :)
// child1 is a dissimilar-origin document | ||
var childURL1 = new URL("cross-origin-postMessage-child1.html", document.location); | ||
childURL1.hostname = "127.0.0.1"; | ||
// child2 is a same-orogin document |
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.
Oops!
f560c80
to
f9c5d0c
Compare
@bors-servo r=emilio |
📌 Commit f9c5d0c has been approved by |
Implement cross-thread postMessage <!-- Please describe your changes on the following line: --> This PR implements cross-thread postMessage, It builds on #15438 and #15478, only the last commit is part of this PR. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15679) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev |
This PR implements cross-thread postMessage,
It builds on #15438 and #15478, only the last commit is part of this PR.
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is