aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-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