diff options
author | Josh Matthews <josh@joshmatthews.net> | 2016-04-13 10:38:53 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2016-04-13 12:07:04 +0200 |
commit | fa42b452a0287fbdbec8cb709c08a9becfbe37eb (patch) | |
tree | acccadcbdcef7b200105f2f93937314e813e89f9 /components/script | |
parent | a8233a135ec37bca77c238f78eea0c454af4c175 (diff) | |
download | servo-fa42b452a0287fbdbec8cb709c08a9becfbe37eb.tar.gz servo-fa42b452a0287fbdbec8cb709c08a9becfbe37eb.zip |
Use origin for document.domain.
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/document.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9bb9a656719..76e33565e63 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -1881,9 +1881,18 @@ 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(); - DOMString::from(origin.serialize_host().unwrap_or_else(|| "".to_owned())) + // Step 1. + if self.browsing_context().is_none() { + return DOMString::new(); + } + + if let Some(host) = self.origin.host() { + // Step 4. + DOMString::from(host.serialize()) + } else { + // Step 3. + DOMString::new() + } } // https://dom.spec.whatwg.org/#dom-document-documenturi |