Skip to content

Add ImmutableOrigin to allow for serializing origins - #15438

Merged
bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:url-serializable-origin
Feb 22, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
asajeffrey:url-serializable-origin

Conversation

@asajeffrey

@asajeffrey asajeffrey commented Feb 8, 2017 •

Copy link
Copy Markdown
Contributor

This PR adds a serializable type ImmutableOrigin and a non-serializable type MutableOrigin. The immutable type represents an origin with null domain, and the mutable type represents an origin with a mutable domain. This separation is needed for implementing setting document.domain.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix Serializing origins #14892.
  • These changes do not require tests because it's a refactoring which will enable other features.

This change is Reviewable

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

highfive commented Feb 8, 2017

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/script/dom/node.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/xmldocument.rs, components/script/dom/domparser.rs, components/script/dom/bindings/trace.rs, components/script/lib.rs, components/script/script_thread.rs, components/script/dom/servoparser/mod.rs, components/script/dom/window.rs, components/script/origin.rs, components/script/dom/domimplementation.rs
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/document.rs, components/net/http_loader.rs, components/script/dom/node.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/xmldocument.rs, components/net_traits/request.rs, components/net_traits/request.rs, components/script/dom/domparser.rs, components/script/dom/bindings/trace.rs, components/script/lib.rs, components/script/script_thread.rs, components/script/dom/servoparser/mod.rs, components/script/dom/window.rs, components/script/origin.rs, components/script/dom/domimplementation.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 8, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

The original work on this was by @cbrewster. r? @jdm

@highfive highfive assigned jdm and unassigned metajack Feb 8, 2017
@asajeffrey asajeffrey added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Feb 9, 2017
@asajeffrey asajeffrey mentioned this pull request Feb 9, 2017
3 tasks done
Comment thread components/script/dom/document.rs Outdated
None,
// https://github.com/whatwg/html/issues/2109
Origin::opaque_identifier(),
self.origin.clone(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's up here?

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.

Well the latest opinion on that discussion was @smaug---- saying whatwg/html#2109 (comment) which looks like it's coming down on the side of a template inheriting its origin, rather than generating a new opaque origin. Can the template document cause script to run? If so, we may need to make sure it runs in the right script thread.

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.

Is this the only remaining issue? I can revert it if we want to keep the old behaviour.

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.

Let's leave this as it is until that issue resolves one way or another.

Comment thread components/url/origin.rs Outdated
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// #[cfg(feature = "servo")] use heapsize::HeapSizeOf;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Uh...

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

let doc = XMLDocument::new(win,
HasBrowsingContext::No,
None,
self.document.origin().alias(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel we should keep the alias/copy distinction.

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.

The Rust naming contention seems to be that clone copies the reference to Rc.

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.

Since the spec does not talk about aliasing any more there is no need for a special name here.

Comment thread components/script/dom/document.rs Outdated
fn Domain(&self) -> DOMString {
// Step 1.
if self.browsing_context().is_none() {
if self.has_browsing_context {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing !?

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 mentioned this pull request Feb 13, 2017
4 tasks done
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@jdm ping?

@jdm

jdm commented Feb 17, 2017

Copy link
Copy Markdown
Member

Clearly the original origin code is older than March 2016, and I've somehow missed that whatwg/html@438155d happened in the meantime.

@asajeffrey

Copy link
Copy Markdown
Contributor Author

Yes, the "alias" concept is gone, we may as well use the Rust naming convention for clone.

@bors-servo

Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Feb 18, 2017
@asajeffrey
asajeffrey force-pushed the url-serializable-origin branch from 3087ea2 to b7055cb Compare February 20, 2017 15:45
@asajeffrey asajeffrey added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Feb 20, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@SimonSapin

Copy link
Copy Markdown
Member

Should be unblocked now: servo/rust-url#280 (comment)

@asajeffrey

Copy link
Copy Markdown
Contributor Author

Thanks!

@asajeffrey
asajeffrey force-pushed the url-serializable-origin branch from b7055cb to 5d703b9 Compare February 20, 2017 19:57
Comment thread components/url/Cargo.toml
serde_derive = {version = "0.9", optional = true}
url = "1.2"
url_serde = {version = "0.1", optional = true}
servo_rand = {path = "../rand"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Alphabetical order.

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.

Fixed.

@jdm

jdm commented Feb 21, 2017

Copy link
Copy Markdown
Member

I intend to complete me review today.

@asajeffrey

Copy link
Copy Markdown
Contributor Author

@jdm: thanks!

@asajeffrey asajeffrey mentioned this pull request Feb 21, 2017
3 tasks done

@jdm jdm 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.

Only a couple small comments. Sorry about the delay!

Comment thread components/script/dom/document.rs Outdated
None,
// https://github.com/whatwg/html/issues/2109
Origin::opaque_identifier(),
self.origin.clone(),

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.

Let's leave this as it is until that issue resolves one way or another.

let doc = XMLDocument::new(win,
HasBrowsingContext::No,
None,
self.document.origin().alias(),

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.

Since the spec does not talk about aliasing any more there is no need for a special name here.

url: ServoUrl,
origin: Origin,
/// The origin for the document
origin: MutableOrigin,

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.

I think it might be clearer if we left this as an immutable one, since the domain of the origin can't change while the document is being fetch.

The one case I'm unsure about is if this can represent the origin of an about:blank loaded in a document that has set document.domain. If we need to provide a MutableOrigin for that, then I guess this needs to stay as-is.

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.

Indeed, that is the one case.

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Feb 22, 2017
@asajeffrey
asajeffrey force-pushed the url-serializable-origin branch from 1c8c7af to 66049a0 Compare February 22, 2017 15:08
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 22, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@nox suggests a forced push then an r+, so...

@bors-servo: r=jdm

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 66049a0 has been approved by jdm

@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. labels Feb 22, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 66049a0 with merge 2f73c51...

bors-servo pushed a commit that referenced this pull request Feb 22, 2017
Add ImmutableOrigin to allow for serializing origins

<!-- Please describe your changes on the following line: -->

This PR adds a serializable type `ImmutableOrigin` and a non-serializable type `MutableOrigin`. The immutable type represents an origin with `null` domain, and the mutable type represents an origin with a mutable domain. This separation is needed for implementing setting `document.domain`.

---
<!-- 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] These changes fix #14892.
- [X] These changes do not require tests because it's a refactoring which will enable other features.

<!-- 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/15438)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 22, 2017
@asajeffrey
asajeffrey force-pushed the url-serializable-origin branch from 66049a0 to bfd7b95 Compare February 22, 2017 17:12
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 22, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

Oh yes ./mach build-geckolib.

@asajeffrey

Copy link
Copy Markdown
Contributor Author

@bors-servo r=jdm

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit bfd7b95 has been approved by jdm

@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. labels Feb 22, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit bfd7b95 with merge 78e8c31...

bors-servo pushed a commit that referenced this pull request Feb 22, 2017
Add ImmutableOrigin to allow for serializing origins

<!-- Please describe your changes on the following line: -->

This PR adds a serializable type `ImmutableOrigin` and a non-serializable type `MutableOrigin`. The immutable type represents an origin with `null` domain, and the mutable type represents an origin with a mutable domain. This separation is needed for implementing setting `document.domain`.

---
<!-- 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] These changes fix #14892.
- [X] These changes do not require tests because it's a refactoring which will enable other features.

<!-- 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/15438)
<!-- 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: jdm
Pushing 78e8c31 to master...

@bors-servo
bors-servo merged commit bfd7b95 into servo:master Feb 22, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Feb 22, 2017
bors-servo pushed a commit that referenced this pull request Mar 15, 2017
Implement setter for document.domain

<!-- Please describe your changes on the following line: -->

This PR implements the setter for `document.domain`.

It builds on #15438 and #15478, only the last commit is part of this PR.

It includes tests for similar-origin security checks.

---
<!-- 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] These changes fix #934.
- [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/15536)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Mar 15, 2017
Implement setter for document.domain

<!-- Please describe your changes on the following line: -->

This PR implements the setter for `document.domain`.

It builds on #15438 and #15478, only the last commit is part of this PR.

It includes tests for similar-origin security checks.

---
<!-- 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] These changes fix #934.
- [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/15536)
<!-- Reviewable:end -->
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 -->
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serializing origins

10 participants