Set window.closed immediately when close() is invoked
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 20:46:57 +0000 (20:46 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2019 20:46:57 +0000 (20:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195409

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing.

* web-platform-tests/html/browsers/the-window-object/close-method.window-expected.txt:
* web-platform-tests/html/browsers/the-window-object/closed-attribute.window-expected.txt:

Source/WebCore:

Window.closed should return true if it is closing:
- https://html.spec.whatwg.org/#dom-window-closed

Window.close() sets the 'is closing' flag to true synchronously, as per:
- https://html.spec.whatwg.org/#dom-window-close (step 3.1)

No new tests, rebaselined existing tests.

* page/DOMWindow.cpp:
(WebCore::DOMWindow::closed const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243661 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/close-method.window-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/closed-attribute.window-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/self-et-al.window-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/page/DOMWindow.cpp

index 5bbdcee..4c0ceb3 100644 (file)
@@ -1,5 +1,17 @@
 2019-03-29  Chris Dumez  <cdumez@apple.com>
 
+        Set window.closed immediately when close() is invoked
+        https://bugs.webkit.org/show_bug.cgi?id=195409
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline WPT tests now that more checks are passing.
+
+        * web-platform-tests/html/browsers/the-window-object/close-method.window-expected.txt:
+        * web-platform-tests/html/browsers/the-window-object/closed-attribute.window-expected.txt:
+
+2019-03-29  Chris Dumez  <cdumez@apple.com>
+
         Unreviewed, rebaseline WPT test after r243638.
 
         * web-platform-tests/html/browsers/the-window-object/named-access-on-the-window-object/navigated-named-objects.window-expected.txt:
index b991992..d7e451f 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL window.close() queues a task to discard, but window.closed knows immediately assert_equals: expected true but got false
-FAIL window.close() affects name targeting immediately assert_equals: expected true but got false
+PASS window.close() queues a task to discard, but window.closed knows immediately 
+PASS window.close() affects name targeting immediately 
 
index 2f7e0c2..3b1889a 100644 (file)
@@ -2,7 +2,7 @@
 Harness Error (TIMEOUT), message = null
 
 PASS closed and same-origin nested browsing context 
-FAIL closed/close() and same-origin auxiliary browsing context assert_equals: expected true but got false
+PASS closed/close() and same-origin auxiliary browsing context 
 TIMEOUT closed and cross-origin nested browsing context Test timed out
 TIMEOUT closed/close() and cross-origin auxiliary browsing context Test timed out
 TIMEOUT closed and cross-site nested browsing context Test timed out
index 40dae1e..93aa75e 100644 (file)
@@ -1,10 +1,10 @@
 
 FAIL iframeWindow.frames before and after removal assert_equals: frames got cleared after browsing context removal expected object "[object Window]" but got null
-FAIL popupWindow.frames before, after closing, and after discarding assert_true: expected true got false
+FAIL popupWindow.frames before, after closing, and after discarding assert_equals: frames got cleared after browsing context removal expected object "[object Window]" but got null
 PASS iframeWindow.globalThis before and after removal 
-FAIL popupWindow.globalThis before, after closing, and after discarding assert_true: expected true got false
+PASS popupWindow.globalThis before, after closing, and after discarding 
 FAIL iframeWindow.self before and after removal assert_equals: self got cleared after browsing context removal expected object "[object Window]" but got null
-FAIL popupWindow.self before, after closing, and after discarding assert_true: expected true got false
+FAIL popupWindow.self before, after closing, and after discarding assert_equals: self got cleared after browsing context removal expected object "[object Window]" but got null
 FAIL iframeWindow.window before and after removal assert_equals: window got cleared after browsing context removal expected object "[object Window]" but got null
-FAIL popupWindow.window before, after closing, and after discarding assert_true: expected true got false
+FAIL popupWindow.window before, after closing, and after discarding assert_equals: window got cleared after browsing context removal expected object "[object Window]" but got null
 
index 60bdf0b..8d4d88f 100644 (file)
@@ -1,3 +1,21 @@
+2019-03-29  Chris Dumez  <cdumez@apple.com>
+
+        Set window.closed immediately when close() is invoked
+        https://bugs.webkit.org/show_bug.cgi?id=195409
+
+        Reviewed by Alex Christensen.
+
+        Window.closed should return true if it is closing:
+        - https://html.spec.whatwg.org/#dom-window-closed
+
+        Window.close() sets the 'is closing' flag to true synchronously, as per:
+        - https://html.spec.whatwg.org/#dom-window-close (step 3.1)
+
+        No new tests, rebaselined existing tests.
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::closed const):
+
 2019-03-29  Zalan Bujtas  <zalan@apple.com>
 
         [Simple line layout] Turn off inline boxtree generation for multiline content
index 2c984f3..ac71b97 100644 (file)
@@ -1314,7 +1314,12 @@ int DOMWindow::scrollY() const
 
 bool DOMWindow::closed() const
 {
-    return !frame();
+    auto* frame = this->frame();
+    if (!frame)
+        return true;
+
+    auto* page = frame->page();
+    return !page || page->isClosing();
 }
 
 unsigned DOMWindow::length() const