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

Implement cross-thread postMessage #15679

Merged
merged 1 commit into from Mar 15, 2017

Conversation

asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Feb 21, 2017

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 errors
  • There are tests for these changes

This change is Reviewable

@asajeffrey asajeffrey added the A-content/script Related to the script thread label Feb 21, 2017
@highfive
Copy link

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/servoparser/mod.rs, components/script/dom/dissimilaroriginwindow.rs, components/script/dom/window.rs, components/script_traits/lib.rs, components/script_traits/lib.rs, components/script/dom/location.rs, components/script/dom/document.rs, components/script/dom/browsingcontext.rs, components/script/dom/xmlhttprequest.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/devtools.rs, components/script/dom/webidls/DissimilarOriginWindow.webidl, components/script/dom/history.rs, components/script/webdriver_handlers.rs, components/script/lib.rs, components/script/dom/domparser.rs, components/script/script_thread.rs, components/script/dom/domimplementation.rs, components/script/dom/htmliframeelement.rs, components/script/dom/webidls/Location.webidl, components/script/dom/node.rs, components/script/dom/xmldocument.rs, components/script/dom/bindings/trace.rs, components/script/origin.rs
  • @KiChjang: components/script/dom/servoparser/mod.rs, components/script/dom/dissimilaroriginwindow.rs, components/script/dom/window.rs, components/script_traits/lib.rs, components/script_traits/lib.rs, components/script/dom/location.rs, components/script/dom/document.rs, components/net/http_loader.rs, components/script/dom/browsingcontext.rs, components/script/dom/xmlhttprequest.rs, components/script_traits/script_msg.rs, components/script_traits/script_msg.rs, components/script/devtools.rs, components/script/dom/webidls/DissimilarOriginWindow.webidl, components/script/dom/history.rs, components/script/webdriver_handlers.rs, components/script/lib.rs, components/script/dom/domparser.rs, components/script/script_thread.rs, components/script/dom/domimplementation.rs, components/script/dom/htmliframeelement.rs, components/net_traits/pub_domains.rs, components/net_traits/pub_domains.rs, components/script/dom/webidls/Location.webidl, components/script/dom/node.rs, components/script/dom/xmldocument.rs, components/script/dom/bindings/trace.rs, components/script/origin.rs, components/net_traits/request.rs, components/net_traits/request.rs

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 21, 2017
@asajeffrey
Copy link
Member Author

cc @jdm

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #15438) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 22, 2017
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #14962) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 23, 2017
@asajeffrey asajeffrey added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Feb 27, 2017
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Feb 27, 2017
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #15536) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Mar 15, 2017
@asajeffrey
Copy link
Member Author

@emilio #15536 landed, this is now ready for review!

Copy link
Member

@emilio emilio left a 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),
Copy link
Member

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).

Copy link
Member Author

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>
Copy link
Member

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 :)

Copy link
Member Author

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;
Copy link
Member

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 :)

Copy link
Member Author

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
Copy link
Member

Choose a reason for hiding this comment

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

typo: origin.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops!

Copy link
Member Author

@asajeffrey asajeffrey left a 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),
Copy link
Member Author

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>
Copy link
Member Author

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;
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

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

Oops!

@asajeffrey
Copy link
Member Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit f9c5d0c has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Mar 15, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit f9c5d0c with merge 1caf8a7...

bors-servo pushed a commit that referenced this pull request Mar 15, 2017
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 -->
@bors-servo
Copy link
Contributor

☀️ 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
Approved by: emilio
Pushing 1caf8a7 to master...

@bors-servo bors-servo merged commit f9c5d0c into servo:master Mar 15, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/script Related to the script thread S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants