diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/document.rs | 15 | ||||
-rw-r--r-- | components/script/dom/webidls/Document.webidl | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 1fda0761c66..be57cf45ae4 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -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() diff --git a/components/script/dom/webidls/Document.webidl b/components/script/dom/webidls/Document.webidl index 5ccd72d087d..328c54b1c2e 100644 --- a/components/script/dom/webidls/Document.webidl +++ b/components/script/dom/webidls/Document.webidl @@ -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; |