Title: [243669] trunk
Revision
243669
Author
cdu...@apple.com
Date
2019-03-29 17:21:31 -0700 (Fri, 29 Mar 2019)

Log Message

Make someWindow.frames, .self, .window always return someWindow
https://bugs.webkit.org/show_bug.cgi?id=195406

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline WPT test now that all its checks are passing.

* web-platform-tests/html/browsers/the-window-object/self-et-al.window-expected.txt:

Source/WebCore:

Make someWindow.frames, .self, .window always return someWindow. Previously, they
would return null when the window would lose its browsing context.

This aligns our behavior with Firefox and the HTML specification:
- https://github.com/whatwg/html/pull/4410

Chrome has also recently aligned with Firefox and the HTML specification here so
it makes sense for WebKit to follow.

No new tests, rebaselined existing tests.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::self const):
(WebCore::JSDOMWindow::window const):
(WebCore::JSDOMWindow::frames const):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::focus):
* page/DOMWindow.h:
* page/DOMWindow.idl:

LayoutTests:

Update / rebaseline existing test to reflect behavior change.

* fast/frames/detached-frame-property-expected.txt:
* fast/frames/detached-frame-property.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243668 => 243669)


--- trunk/LayoutTests/ChangeLog	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/LayoutTests/ChangeLog	2019-03-30 00:21:31 UTC (rev 243669)
@@ -1,3 +1,15 @@
+2019-03-29  Chris Dumez  <cdu...@apple.com>
+
+        Make someWindow.frames, .self, .window always return someWindow
+        https://bugs.webkit.org/show_bug.cgi?id=195406
+
+        Reviewed by Alex Christensen.
+
+        Update / rebaseline existing test to reflect behavior change.
+
+        * fast/frames/detached-frame-property-expected.txt:
+        * fast/frames/detached-frame-property.html:
+
 2019-03-29  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Delete WebMetal implementation in favor of WebGPU

Modified: trunk/LayoutTests/fast/frames/detached-frame-property-expected.txt (243668 => 243669)


--- trunk/LayoutTests/fast/frames/detached-frame-property-expected.txt	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/LayoutTests/fast/frames/detached-frame-property-expected.txt	2019-03-30 00:21:31 UTC (rev 243669)
@@ -15,9 +15,9 @@
 PASS detachedWindow.opener is null
 PASS detachedWindow.parent is null
 PASS detachedWindow.frameElement is null
-PASS detachedWindow.window is null
-PASS detachedWindow.frames is null
-PASS detachedWindow.self is null
+PASS detachedWindow.window is detachedWindow
+PASS detachedWindow.frames is detachedWindow
+PASS detachedWindow.self is detachedWindow
 PASS !detachedWindow.localStorage is true
 PASS !!detachedWindow.document is true
 PASS !!detachedWindow.XMLHttpRequest is true

Modified: trunk/LayoutTests/fast/frames/detached-frame-property.html (243668 => 243669)


--- trunk/LayoutTests/fast/frames/detached-frame-property.html	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/LayoutTests/fast/frames/detached-frame-property.html	2019-03-30 00:21:31 UTC (rev 243669)
@@ -19,10 +19,9 @@
     shouldBeNull("detachedWindow.opener");
     shouldBeNull("detachedWindow.parent");
     shouldBeNull("detachedWindow.frameElement"); // Technically, Chrome returns undefined here, not null.
-    // Chrome agrees with us but Firefox returns the detachedWindow.
-    shouldBeNull("detachedWindow.window");
-    shouldBeNull("detachedWindow.frames");
-    shouldBeNull("detachedWindow.self");
+    shouldBe("detachedWindow.window", "detachedWindow");
+    shouldBe("detachedWindow.frames", "detachedWindow");
+    shouldBe("detachedWindow.self", "detachedWindow");
 
     // Chrome returns undefined but Firefox has a valid object.
     shouldBeTrue("!detachedWindow.localStorage");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (243668 => 243669)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-03-30 00:21:31 UTC (rev 243669)
@@ -1,3 +1,14 @@
+2019-03-29  Chris Dumez  <cdu...@apple.com>
+
+        Make someWindow.frames, .self, .window always return someWindow
+        https://bugs.webkit.org/show_bug.cgi?id=195406
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline WPT test now that all its checks are passing.
+
+        * web-platform-tests/html/browsers/the-window-object/self-et-al.window-expected.txt:
+
 2019-03-29  Javier Fernandez  <jfernan...@igalia.com>
 
         Update the CSS Text WPT test suite

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/self-et-al.window-expected.txt (243668 => 243669)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/self-et-al.window-expected.txt	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/self-et-al.window-expected.txt	2019-03-30 00:21:31 UTC (rev 243669)
@@ -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_equals: frames got cleared after browsing context removal expected object "[object Window]" but got null
+PASS iframeWindow.frames before and after removal 
+PASS popupWindow.frames before, after closing, and after discarding 
 PASS iframeWindow.globalThis before and after removal 
 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_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_equals: window got cleared after browsing context removal expected object "[object Window]" but got null
+PASS iframeWindow.self before and after removal 
+PASS popupWindow.self before, after closing, and after discarding 
+PASS iframeWindow.window before and after removal 
+PASS popupWindow.window before, after closing, and after discarding 
 

Modified: trunk/Source/WebCore/ChangeLog (243668 => 243669)


--- trunk/Source/WebCore/ChangeLog	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/Source/WebCore/ChangeLog	2019-03-30 00:21:31 UTC (rev 243669)
@@ -1,3 +1,30 @@
+2019-03-29  Chris Dumez  <cdu...@apple.com>
+
+        Make someWindow.frames, .self, .window always return someWindow
+        https://bugs.webkit.org/show_bug.cgi?id=195406
+
+        Reviewed by Alex Christensen.
+
+        Make someWindow.frames, .self, .window always return someWindow. Previously, they
+        would return null when the window would lose its browsing context.
+
+        This aligns our behavior with Firefox and the HTML specification:
+        - https://github.com/whatwg/html/pull/4410
+
+        Chrome has also recently aligned with Firefox and the HTML specification here so
+        it makes sense for WebKit to follow.
+
+        No new tests, rebaselined existing tests.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::self const):
+        (WebCore::JSDOMWindow::window const):
+        (WebCore::JSDOMWindow::frames const):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::focus):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+
 2019-03-29  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Delete WebMetal implementation in favor of WebGPU

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (243668 => 243669)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2019-03-30 00:21:31 UTC (rev 243669)
@@ -548,4 +548,19 @@
     replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "opener"), value);
 }
 
+JSValue JSDOMWindow::self(JSC::ExecState&) const
+{
+    return globalThis();
+}
+
+JSValue JSDOMWindow::window(JSC::ExecState&) const
+{
+    return globalThis();
+}
+
+JSValue JSDOMWindow::frames(JSC::ExecState&) const
+{
+    return globalThis();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (243668 => 243669)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2019-03-30 00:21:31 UTC (rev 243669)
@@ -940,8 +940,9 @@
 
 void DOMWindow::focus(DOMWindow& incumbentWindow)
 {
-    auto* opener = this->opener();
-    focus(opener && opener != self() && incumbentWindow.self() == opener);
+    auto* frame = this->frame();
+    auto* openerFrame = frame ? frame->loader().opener() : nullptr;
+    focus(openerFrame && openerFrame != frame && incumbentWindow.frame() == openerFrame);
 }
 
 void DOMWindow::focus(bool allowFocus)
@@ -1380,15 +1381,6 @@
     page->chrome().setStatusbarText(*frame, m_defaultStatus);
 }
 
-WindowProxy* DOMWindow::self() const
-{
-    auto* frame = this->frame();
-    if (!frame)
-        return nullptr;
-
-    return &frame->windowProxy();
-}
-
 WindowProxy* DOMWindow::opener() const
 {
     auto* frame = this->frame();

Modified: trunk/Source/WebCore/page/DOMWindow.h (243668 => 243669)


--- trunk/Source/WebCore/page/DOMWindow.h	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/Source/WebCore/page/DOMWindow.h	2019-03-30 00:21:31 UTC (rev 243669)
@@ -210,8 +210,6 @@
     String defaultStatus() const;
     void setDefaultStatus(const String&);
 
-    WindowProxy* self() const;
-
     WindowProxy* opener() const;
     void disownOpener();
     WindowProxy* parent() const;

Modified: trunk/Source/WebCore/page/DOMWindow.idl (243668 => 243669)


--- trunk/Source/WebCore/page/DOMWindow.idl	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2019-03-30 00:21:31 UTC (rev 243669)
@@ -50,8 +50,8 @@
     PrimaryGlobal,
 ] interface DOMWindow : EventTarget {
     // The current browsing context.
-    [DoNotCheckSecurity, Unforgeable, ImplementedAs=self] readonly attribute WindowProxy window;
-    [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy self;
+    [DoNotCheckSecurity, Unforgeable, CustomGetter] readonly attribute WindowProxy window;
+    [Replaceable, DoNotCheckSecurityOnGetter, CustomGetter] readonly attribute WindowProxy self;
     [Unforgeable] readonly attribute Document document;
     attribute DOMString name;
     [DoNotCheckSecurity, PutForwards=href, Unforgeable] readonly attribute Location location;
@@ -71,7 +71,7 @@
     [DoNotCheckSecurity, ForwardDeclareInHeader] void blur();
 
     // Other browsing contexts.
-    [Replaceable, DoNotCheckSecurityOnGetter, ImplementedAs=self] readonly attribute WindowProxy frames;
+    [Replaceable, DoNotCheckSecurityOnGetter, CustomGetter] readonly attribute WindowProxy frames;
     [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
     [DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute WindowProxy? top;
     [DoNotCheckSecurityOnGetter, CustomSetter] attribute WindowProxy? opener;

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp (243668 => 243669)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp	2019-03-29 23:57:18 UTC (rev 243668)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDOMWindow.cpp	2019-03-30 00:21:31 UTC (rev 243669)
@@ -970,9 +970,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_DOM_WINDOW(self), 0);
     WebCore::DOMWindow* item = WebKit::core(self);
-    auto* selfWindowProxy = item->self();
-    RefPtr<WebCore::DOMWindow> gobjectResult = downcast<WebCore::DOMWindow>(selfWindowProxy->window());
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(item);
 }
 
 WebKitDOMDOMWindow* webkit_dom_dom_window_get_window(WebKitDOMDOMWindow* self)
@@ -980,9 +978,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_DOM_WINDOW(self), 0);
     WebCore::DOMWindow* item = WebKit::core(self);
-    auto* selfWindowProxy = item->self();
-    RefPtr<WebCore::DOMWindow> gobjectResult = downcast<WebCore::DOMWindow>(selfWindowProxy->window());
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(item);
 }
 
 WebKitDOMDOMWindow* webkit_dom_dom_window_get_frames(WebKitDOMDOMWindow* self)
@@ -990,9 +986,7 @@
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_DOM_WINDOW(self), 0);
     WebCore::DOMWindow* item = WebKit::core(self);
-    auto* selfWindowProxy = item->self();
-    RefPtr<WebCore::DOMWindow> gobjectResult = downcast<WebCore::DOMWindow>(selfWindowProxy->window());
-    return WebKit::kit(gobjectResult.get());
+    return WebKit::kit(item);
 }
 
 WebKitDOMDOMWindow* webkit_dom_dom_window_get_opener(WebKitDOMDOMWindow* self)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to