Skip to content

Implement cross-thread postMessage - #15679

Merged
bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:script-postMessage-xorigin
Mar 15, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:script-postMessage-xorigin

Conversation

@asajeffrey

@asajeffrey asajeffrey commented Feb 21, 2017 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Contributor Author

cc @jdm

@bors-servo

Copy link
Copy Markdown
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
@asajeffrey
asajeffrey force-pushed the script-postMessage-xorigin branch from 6ea3d04 to 53043b3 Compare February 22, 2017 19:18
@bors-servo

Copy link
Copy Markdown
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 force-pushed the script-postMessage-xorigin branch from 53043b3 to 73acf86 Compare February 23, 2017 14:34
@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 force-pushed the script-postMessage-xorigin branch from 73acf86 to 72cd111 Compare February 27, 2017 21:19
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Feb 27, 2017
@bors-servo

Copy link
Copy Markdown
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
asajeffrey force-pushed the script-postMessage-xorigin branch from 72cd111 to f560c80 Compare March 15, 2017 19:10
@asajeffrey

Copy link
Copy Markdown
Contributor Author

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

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

r=me


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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops!

@asajeffrey asajeffrey left a comment

Copy link
Copy Markdown
Contributor Author

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!


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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops!

@asajeffrey
asajeffrey force-pushed the script-postMessage-xorigin branch from f560c80 to f9c5d0c Compare March 15, 2017 19:57
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@bors-servo r=emilio

@bors-servo

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

4 participants