aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2016-04-13 10:38:53 +0200
committerMs2ger <Ms2ger@gmail.com>2016-04-13 12:07:04 +0200
commitfa42b452a0287fbdbec8cb709c08a9becfbe37eb (patch)
treeacccadcbdcef7b200105f2f93937314e813e89f9 /components/script
parenta8233a135ec37bca77c238f78eea0c454af4c175 (diff)
downloadservo-fa42b452a0287fbdbec8cb709c08a9becfbe37eb.tar.gz
servo-fa42b452a0287fbdbec8cb709c08a9becfbe37eb.zip
Use origin for document.domain.
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/document.rs15
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