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 setter for document.domain #15536

Merged
merged 2 commits into from Mar 15, 2017

Conversation

@asajeffrey
Copy link
Member

asajeffrey commented Feb 13, 2017

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.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #934.
  • There are tests for these changes.

This change is Reviewable

@highfive
Copy link

highfive commented Feb 13, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/servoparser/mod.rs, components/script/dom/window.rs, components/script/dom/location.rs, components/script/dom/document.rs, components/script/dom/xmlhttprequest.rs, components/script/devtools.rs, 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/webidls/Document.webidl, components/script/dom/bindings/trace.rs, components/script/origin.rs
  • @KiChjang: components/script/dom/servoparser/mod.rs, components/script/dom/window.rs, components/script/dom/location.rs, components/script/dom/document.rs, components/net/http_loader.rs, components/script/dom/xmlhttprequest.rs, components/script/devtools.rs, 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/webidls/Document.webidl, 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 13, 2017

warning Warning warning

  • These commits include an empty title element (<title></title>). Consider adding appropriate metadata.
  • These commits modify unsafe code. Please review it carefully!
@asajeffrey
Copy link
Member Author

asajeffrey commented Feb 13, 2017

@asajeffrey asajeffrey changed the title Script document domain setter Implement setter for document.domain Feb 13, 2017
@asajeffrey asajeffrey force-pushed the asajeffrey:script-document-domain-setter branch from e33dace to e2d4a51 Feb 15, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Feb 15, 2017

Updated the wpt manifest.

@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2017

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

@asajeffrey asajeffrey force-pushed the asajeffrey:script-document-domain-setter branch from e2d4a51 to d68a989 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-document-domain-setter branch from d68a989 to 34f1164 Feb 23, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Feb 27, 2017

IRC conversation with @jdm: http://logs.glob.uno/?c=mozilla%23servo&s=24+Feb+2017&e=24+Feb+2017#c619500

TL;DR: closed #15478 in favour of merging with this PR, so we can include wpt tests.

@asajeffrey
Copy link
Member Author

asajeffrey commented Feb 27, 2017

The spec for document.domain changed: whatwg/html@03bbc6e

I added some more wpt tests.

@emilio, @Ms2ger and @jdm: This is ready for review, since #15478 was closed in favour of this PR.

@asajeffrey asajeffrey force-pushed the asajeffrey:script-document-domain-setter branch from 94ae9b2 to 7ce7340 Feb 27, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Feb 27, 2017

The spec for document.open() changed: whatwg/html#2288

IRC chat with @Ms2ger: http://logs.glob.uno/?c=mozilla%23servo&s=27+Feb+2017&e=27+Feb+2017#c620440 - now that there's a wpt test for document.open() we should have sufficient test coverage.

@@ -81,7 +81,7 @@ partial /*sealed*/ interface Document {
// resource metadata management
[/*PutForwards=href, */Unforgeable]
readonly attribute Location? location;
readonly attribute DOMString domain;
[Throws] attribute DOMString domain;

This comment has been minimized.

Copy link
@Ms2ger

Ms2ger Mar 2, 2017

Contributor

Can this use [SetterThrows]?

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 2, 2017

Author Member

Oh, I didn't know there was such a thing! Yes, it should.

This comment has been minimized.

Copy link
@asajeffrey

asajeffrey Mar 2, 2017

Author Member

Done.

@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 2, 2017

Fixes #15233.

@nox nox added the S-needs-squash label Mar 3, 2017
@asajeffrey asajeffrey force-pushed the asajeffrey:script-document-domain-setter branch from 971794d to 4d82e40 Mar 8, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 8, 2017

Squashed down into two commits. The first used to be #15478, the second is the implementation of the setter for document.domain.

@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 14, 2017

Pushed again to get appveyor to rebuild.

Some(Host::Domain(String::from(reg_suffix(&*domain))))
} else {
Some(host)
},

This comment has been minimized.

Copy link
@nox

nox Mar 15, 2017

Member

This is worse than before or what I suggested and the formatting is wrong. Don't nest an if let expression inside a match arm without enclosing it in braces.

fn is_a_registrable_domain_suffix_of_or_is_equal_to(host_suffix_string: &str, original_host: Host) -> bool {
// The spec says to return a bool, we actually return an Option<Host> containing
// the parsed host in the successful case, to avoid having to re-parse the host.
fn is_a_registrable_domain_suffix_of_or_is_equal_to(host_suffix_string: &str, original_host: Host) -> Option<Host> {

This comment has been minimized.

Copy link
@nox

nox Mar 15, 2017

Member

Rename the method to something that doesn't sound like a boolean.

let host = match is_a_registrable_domain_suffix_of_or_is_equal_to(&*value, effective_domain) {
None => return Err(Error::Security),
Some(host) => host,
};

This comment has been minimized.

Copy link
@nox

nox Mar 15, 2017

Member
let host = is_a_registrable_domain_suffix_of_or_is_equal_to(&*value, effective_domain).ok_or(Error::Security)?;
@nox
Copy link
Member

nox commented Mar 15, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Mar 15, 2017

Trying commit 7c91817 with merge ea09005...

bors-servo added 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
Copy link
Contributor

bors-servo commented Mar 15, 2017

💔 Test failed - linux-rel-wpt

_ => Some(host),
},
ImmutableOrigin::Opaque(_) => None,
}

This comment has been minimized.

Copy link
@nox

nox Mar 15, 2017

Member

Still the same issue?

Either just copy/paste my original comment, or wrap the nested match in braces.

match url.origin() {
    ImmutableOrigin::Tuple(_, Host::Domain(domain), _) => Some(Host::Domain(String::from(reg_suffix(&*domain)))),
    ImmutableOrigin::Tuple(_, ip, _) => Some(ip),
    ImmutableOrigin::Opaque(_) => None,
}

This comment has been minimized.

Copy link
@nox

nox Mar 15, 2017

Member

Or a mix of the two.

match url.origin() {
    ImmutableOrigin::Tuple(_, Host::Domain(domain), _) => {
        Some(Host::Domain(String::from(reg_suffix(&*domain))))
    },
    ImmutableOrigin::Tuple(_, ip, _) => Some(ip),
    ImmutableOrigin::Opaque(_) => None,
}
@nox
Copy link
Member

nox commented Mar 15, 2017

r=me when the tests pass.

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

nox commented Mar 15, 2017

The intermittent crash seems to be a race condition when writing the alert() message, please add a security check to it so that it will throw SecurityError as the spec mandates in the test, thus avoiding the intermittent crash entirely.

@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 15, 2017

Added #15962.

@asajeffrey asajeffrey force-pushed the asajeffrey:script-document-domain-setter branch from 0ae1849 to 5348b63 Mar 15, 2017
@asajeffrey
Copy link
Member Author

asajeffrey commented Mar 15, 2017

Squashed down to two commits.

@bors-servo: r=nox

@bors-servo
Copy link
Contributor

bors-servo commented Mar 15, 2017

📌 Commit 5348b63 has been approved by nox

@bors-servo
Copy link
Contributor

bors-servo commented Mar 15, 2017

Testing commit 5348b63 with merge e600e04...

bors-servo added 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
Copy link
Contributor

bors-servo commented Mar 15, 2017

@bors-servo bors-servo merged commit 5348b63 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
bors-servo added a commit that referenced this pull request Mar 17, 2017
Implement dissimilar-origin window.parent and window.top

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

This PR implements `window.parent` and `window.top` for dissimilar-origin windows.

This PR builds on #15536, 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] These changes fix #14996 and fix #11660.
- [X] These changes do not require tests because there's already a parentage test in `mozilla/cross-origin-objects/cross-origin-objects.html`.

<!-- 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/15799)
<!-- Reviewable:end -->
jdm added a commit to web-platform-tests/wpt that referenced this pull request Apr 17, 2017
Upstreamed from servo/servo#15536 [ci skip]
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.

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