Auto merge of #8655 - jdm:domain, r=jdm

Implement document.domain getter

Rebased from #6840 + test fixes.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8655)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-24 06:01:13 +05:30
commit 0905088e83
7 changed files with 50 additions and 10 deletions

View file

@ -105,7 +105,7 @@ use string_cache::{Atom, QualName};
use style::restyle_hints::ElementSnapshot;
use style::stylesheets::Stylesheet;
use time;
use url::Url;
use url::{Host, Url};
use util::str::{DOMString, split_html_space_chars, str_join};
#[derive(JSTraceable, PartialEq, HeapSizeOf)]
@ -1647,6 +1647,19 @@ impl DocumentMethods for Document {
}
}
// https://html.spec.whatwg.org/multipage/#relaxing-the-same-origin-restriction
fn Domain(&self) -> DOMString {
// TODO: This should use the effective script origin when it exists
let origin = self.window.get_url();
if let Some(&Host::Ipv6(ipv6)) = origin.host() {
// Omit square brackets for IPv6 addresses.
return DOMString::from(ipv6.serialize());
}
DOMString::from(origin.serialize_host().unwrap_or_else(|| "".to_owned()))
}
// https://dom.spec.whatwg.org/#dom-document-documenturi
fn DocumentURI(&self) -> DOMString {
self.URL()

View file

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