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 diff --git a/tests/wpt/metadata/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html.ini b/tests/wpt/metadata/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html.ini deleted file mode 100644 index 4adc32981f0..00000000000 --- a/tests/wpt/metadata/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[document_domain.html] - type: testharness - [new document] - expected: FAIL -