Skip to content

Implement setter for document.domain - #15536

Merged
bors-servo merged 2 commits into
servo:masterfrom
asajeffrey:script-document-domain-setter
Mar 15, 2017
Merged

bors-servo merged 2 commits into
servo:masterfrom
asajeffrey:script-document-domain-setter

Conversation

@asajeffrey

@asajeffrey asajeffrey commented Feb 13, 2017 •

Copy link
Copy Markdown
Contributor

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 Implement document.domain  #934.
  • There are tests for these changes.

This change is Reviewable

@asajeffrey asajeffrey added A-content/script Related to the script thread A-security labels Feb 13, 2017
@highfive

Copy link
Copy Markdown

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

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!

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

Copy link
Copy Markdown
Contributor Author

cc @jdm @Ms2ger

@asajeffrey asajeffrey changed the title Script document domain setter Implement setter for document.domain Feb 13, 2017
@asajeffrey
asajeffrey force-pushed the script-document-domain-setter branch from e33dace to e2d4a51 Compare February 15, 2017 22:16
@asajeffrey

Copy link
Copy Markdown
Contributor Author

Updated the wpt manifest.

@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 script-document-domain-setter branch from e2d4a51 to d68a989 Compare February 22, 2017 19:25
@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-document-domain-setter branch from d68a989 to 34f1164 Compare February 23, 2017 14:32
@asajeffrey

Copy link
Copy Markdown
Contributor Author

@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Feb 27, 2017
@asajeffrey

Copy link
Copy Markdown
Contributor Author

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 script-document-domain-setter branch from 94ae9b2 to 7ce7340 Compare February 27, 2017 15:56
@asajeffrey

Copy link
Copy Markdown
Contributor Author

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.

[/*PutForwards=href, */Unforgeable]
readonly attribute Location? location;
readonly attribute DOMString domain;
[Throws] attribute DOMString domain;

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.

Can this use [SetterThrows]?

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.

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

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.

Done.

@asajeffrey

Copy link
Copy Markdown
Contributor Author

Fixes #15233.

@nox nox added the S-needs-squash Some (or all) of the commits in the PR should be combined. label Mar 3, 2017
@asajeffrey
asajeffrey force-pushed the script-document-domain-setter branch from 971794d to 4d82e40 Compare March 8, 2017 16:30
@asajeffrey

Copy link
Copy Markdown
Contributor Author

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

Pushed again to get appveyor to rebuild.

Comment thread components/net_traits/pub_domains.rs Outdated
Some(Host::Domain(String::from(reg_suffix(&*domain))))
} else {
Some(host)
},

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.

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.

Comment thread components/script/dom/document.rs Outdated
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> {

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.

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,
};

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.

let host = is_a_registrable_domain_suffix_of_or_is_equal_to(&*value, effective_domain).ok_or(Error::Security)?;

@nox

nox commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 7c91817 with merge ea09005...

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

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-tests-failed The changes caused existing tests to fail. labels Mar 15, 2017
_ => Some(host),
},
ImmutableOrigin::Opaque(_) => None,
}

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.

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

@nox nox Mar 15, 2017 •

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.

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

nox commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

r=me when the tests pass.

@nox

nox commented Mar 15, 2017

Copy link
Copy Markdown
Contributor

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

Added #15962.

@asajeffrey
asajeffrey force-pushed the script-document-domain-setter branch from 0ae1849 to 5348b63 Compare March 15, 2017 15:34
@asajeffrey

Copy link
Copy Markdown
Contributor Author

Squashed down to two commits.

@bors-servo: r=nox

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 5348b63 has been approved by nox

@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 Mar 15, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 5348b63 with merge e600e04...

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

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: nox
Pushing e600e04 to master...

@bors-servo
bors-servo merged commit 5348b63 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
bors-servo pushed 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 pushed a commit to web-platform-tests/wpt that referenced this pull request Apr 17, 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 A-security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement document.domain

6 participants