diff --git a/components/script/dom/webidls/Window.webidl b/components/script/dom/webidls/Window.webidl index 548821ac971..3c962f2795e 100644 --- a/components/script/dom/webidls/Window.webidl +++ b/components/script/dom/webidls/Window.webidl @@ -23,7 +23,7 @@ //[Replaceable] readonly attribute BarProp toolbar; attribute DOMString status; void close(); - //readonly attribute boolean closed; + readonly attribute boolean closed; //void stop(); //void focus(); //void blur(); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 7d25b985c2c..b4459bf15db 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -509,6 +509,13 @@ impl WindowMethods for Window { } } + // https://html.spec.whatwg.org/multipage/#dom-window-closed + fn Closed(&self) -> bool { + self.window_proxy.get() + .map(|ref proxy| proxy.is_browsing_context_discarded()) + .unwrap_or(true) + } + // https://html.spec.whatwg.org/multipage/#dom-window-close fn Close(&self) { self.main_thread_script_chan() diff --git a/tests/wpt/metadata/html/browsers/the-window-object/security-window/window-security.html.ini b/tests/wpt/metadata/html/browsers/the-window-object/security-window/window-security.html.ini index 4fc54b9edaa..746b6a1c9c8 100644 --- a/tests/wpt/metadata/html/browsers/the-window-object/security-window/window-security.html.ini +++ b/tests/wpt/metadata/html/browsers/the-window-object/security-window/window-security.html.ini @@ -339,9 +339,6 @@ [A SecurityError exception must be thrown when window.stop is accessed from a different origin.] expected: FAIL - [A SecurityError exception should not be thrown when window.closed is accessed from a different origin.] - expected: FAIL - [A SecurityError exception should not be thrown when window.length is accessed from a different origin.] expected: FAIL diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index 2058e5125dc..dc075e84954 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -4341,9 +4341,6 @@ [Window interface: attribute toolbar] expected: FAIL - [Window interface: attribute closed] - expected: FAIL - [Window interface: operation stop()] expected: FAIL @@ -4422,9 +4419,6 @@ [Window interface: window must inherit property "toolbar" with the proper type (11)] expected: FAIL - [Window interface: window must inherit property "closed" with the proper type (14)] - expected: FAIL - [Window interface: window must inherit property "stop" with the proper type (15)] expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 6e1e2c6fd99..ce6f56d9361 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -31734,7 +31734,7 @@ "testharness" ], "mozilla/window.html": [ - "8cfb22096cf713709d6206945ad1bb98a52c4136", + "455b488925ce1798c89c2944d4f13dee0cfa32b1", "testharness" ], "mozilla/window_performance.html": [ diff --git a/tests/wpt/mozilla/tests/mozilla/window.html b/tests/wpt/mozilla/tests/mozilla/window.html index 1bc363a1122..b6dde8c6b8a 100644 --- a/tests/wpt/mozilla/tests/mozilla/window.html +++ b/tests/wpt/mozilla/tests/mozilla/window.html @@ -9,6 +9,7 @@ test(function() { assert_equals(window, window.self); assert_true(window.self instanceof Window, "Should be Window"); + assert_true(window.closed === false); });