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

@highfive
Copy link

highfive commented Feb 21, 2017

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

highfive commented Feb 21, 2017

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
@asajeffrey
Copy link
Member Author

asajeffrey commented Feb 21, 2017

cc @jdm

@bors-servo
Copy link
Contributor

bors-servo commented Feb 22, 2017

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-postMessage-xorigin branch from 6ea3d04 to 53043b3 Feb 22, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Feb 23, 2017

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-postMessage-xorigin branch from 53043b3 to 73acf86 Feb 23, 2017
@asajeffrey asajeffrey force-pushed the asajeffrey:script-postMessage-xorigin branch from 73acf86 to 72cd111 Feb 27, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Mar 15, 2017

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-postMessage-xorigin branch from 72cd111 to f560c80 Mar 15, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 15, 2017

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

@emilio
emilio approved these changes Mar 15, 2017
Copy link
Member

emilio left a comment

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

This comment has been minimized.

Copy link
@emilio

emilio Mar 15, 2017

Member

(As a side note, I seriously believe that we should convert all these to panics during testing).

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

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>

This comment has been minimized.

Copy link
@emilio

emilio Mar 15, 2017

Member

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

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

I like my html old skool :)

<body>
<script>
window.addEventListener("message", function(e) {
window.location.href = e.data;

This comment has been minimized.

Copy link
@emilio

emilio Mar 15, 2017

Member

heh. this is quite tricky. I guess it works :)

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

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

This comment has been minimized.

Copy link
@emilio

emilio Mar 15, 2017

Member

typo: origin.

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

Oops!

Copy link
Member Author

asajeffrey left a comment

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

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

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>

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

I like my html old skool :)

<body>
<script>
window.addEventListener("message", function(e) {
window.location.href = e.data;

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

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

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 15, 2017

Author Member

Oops!

@asajeffrey asajeffrey force-pushed the asajeffrey:script-postMessage-xorigin branch from f560c80 to f9c5d0c Mar 15, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 15, 2017

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

bors-servo commented Mar 15, 2017

📌 Commit f9c5d0c has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Mar 15, 2017

Testing commit f9c5d0c with merge 1caf8a7...

bors-servo added 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

bors-servo commented Mar 15, 2017

@bors-servo bors-servo merged commit f9c5d0c into servo:master Mar 15, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.