Diff
Modified: trunk/LayoutTests/ChangeLog (226841 => 226842)
--- trunk/LayoutTests/ChangeLog 2018-01-12 03:31:27 UTC (rev 226841)
+++ trunk/LayoutTests/ChangeLog 2018-01-12 04:47:31 UTC (rev 226842)
@@ -1,3 +1,18 @@
+2018-01-11 Chris Dumez <[email protected]>
+
+ Setting Window.opener to null should disown its opener
+ https://bugs.webkit.org/show_bug.cgi?id=181505
+ <rdar://problem/36443151>
+
+ Reviewed by Ryosuke Niwa.
+
+ Add layout test coverage.
+
+ * fast/dom/Window/window-opener-set-to-null-expected.txt: Added.
+ * fast/dom/Window/window-opener-set-to-null.html: Added.
+ * fast/dom/Window/window-opener-shadowing-expected.txt: Added.
+ * fast/dom/Window/window-opener-shadowing.html: Added.
+
2018-01-11 Myles C. Maxfield <[email protected]>
[Cocoa] Star character disappears when bolded
Added: trunk/LayoutTests/fast/dom/Window/window-opener-set-to-null-expected.txt (0 => 226842)
--- trunk/LayoutTests/fast/dom/Window/window-opener-set-to-null-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/window-opener-set-to-null-expected.txt 2018-01-12 04:47:31 UTC (rev 226842)
@@ -0,0 +1,13 @@
+Tests that setting window.opener to null disown its opener
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS newWindow.opener is window
+PASS newWindow.opener = null did not throw exception.
+PASS newWindow.opener is null
+PASS openerGetter.call(newWindow) is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Window/window-opener-set-to-null.html (0 => 226842)
--- trunk/LayoutTests/fast/dom/Window/window-opener-set-to-null.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/window-opener-set-to-null.html 2018-01-12 04:47:31 UTC (rev 226842)
@@ -0,0 +1,28 @@
+<DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that setting window.opener to null disown its opener");
+jsTestIsAsync = true;
+
+_onload_ = function() {
+ if (window.testRunner)
+ testRunner.setCanOpenWindows();
+
+ newWindow = open("resources/blank.html");
+ newWindow._onload_ = function() {
+ shouldBe("newWindow.opener", "window");
+
+ openerGetter = Object.getOwnPropertyDescriptor(newWindow, "opener").get;
+
+ shouldNotThrow("newWindow.opener = null");
+ shouldBeNull("newWindow.opener");
+ shouldBeNull("openerGetter.call(newWindow)");
+
+ finishJSTest();
+ };
+};
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/dom/Window/window-opener-shadowing-expected.txt (0 => 226842)
--- trunk/LayoutTests/fast/dom/Window/window-opener-shadowing-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/window-opener-shadowing-expected.txt 2018-01-12 04:47:31 UTC (rev 226842)
@@ -0,0 +1,27 @@
+Tests shadowing of window.opener property
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.opener is null
+desc = Object.getOwnPropertyDescriptor(window, 'opener')
+PASS desc.get is an instance of Function
+PASS desc.set is an instance of Function
+PASS desc.enumerable is true
+PASS desc.configurable is true
+PASS window.opener = 'foo' did not throw exception.
+desc = Object.getOwnPropertyDescriptor(window, 'opener')
+PASS desc.value is "foo"
+PASS desc.writable is true
+PASS desc.enumerable is true
+PASS desc.configurable is true
+PASS openerGetter.call(window) is null
+PASS delete window.opener did not throw exception.
+PASS window.opener is undefined.
+PASS openerGetter.call(window) is null
+desc = Object.getOwnPropertyDescriptor(window, 'opener')
+PASS desc is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Window/window-opener-shadowing.html (0 => 226842)
--- trunk/LayoutTests/fast/dom/Window/window-opener-shadowing.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/window-opener-shadowing.html 2018-01-12 04:47:31 UTC (rev 226842)
@@ -0,0 +1,36 @@
+<DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests shadowing of window.opener property");
+
+shouldBeNull("window.opener");
+evalAndLog("desc = Object.getOwnPropertyDescriptor(window, 'opener')");
+shouldBeType("desc.get", "Function");
+shouldBeType("desc.set", "Function");
+shouldBeTrue("desc.enumerable");
+shouldBeTrue("desc.configurable");
+
+openerGetter = desc.get;
+
+shouldNotThrow("window.opener = 'foo'");
+evalAndLog("desc = Object.getOwnPropertyDescriptor(window, 'opener')");
+
+shouldBeEqualToString("desc.value", "foo");
+shouldBeTrue("desc.writable");
+shouldBeTrue("desc.enumerable");
+shouldBeTrue("desc.configurable");
+
+shouldBeNull("openerGetter.call(window)");
+
+shouldNotThrow("delete window.opener");
+shouldBeUndefined("window.opener");
+
+shouldBeNull("openerGetter.call(window)");
+
+evalAndLog("desc = Object.getOwnPropertyDescriptor(window, 'opener')");
+shouldBeUndefined("desc");
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (226841 => 226842)
--- trunk/Source/WebCore/ChangeLog 2018-01-12 03:31:27 UTC (rev 226841)
+++ trunk/Source/WebCore/ChangeLog 2018-01-12 04:47:31 UTC (rev 226842)
@@ -1,3 +1,27 @@
+2018-01-11 Chris Dumez <[email protected]>
+
+ Setting Window.opener to null should disown its opener
+ https://bugs.webkit.org/show_bug.cgi?id=181505
+ <rdar://problem/36443151>
+
+ Reviewed by Ryosuke Niwa.
+
+ Setting Window.opener to null should disown its opener as per:
+ - https://html.spec.whatwg.org/#dom-opener
+
+ With this change, tabs opened by clicking link inside Gmail no
+ longer have the Gmail window as opener.
+
+ Tests: fast/dom/Window/window-opener-set-to-null.html
+ fast/dom/Window/window-opener-shadowing.html
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::setOpener):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::disownOpener):
+ * page/DOMWindow.h:
+ * page/DOMWindow.idl:
+
2018-01-11 Myles C. Maxfield <[email protected]>
[Cocoa] Star character disappears when bolded
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (226841 => 226842)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2018-01-12 03:31:27 UTC (rev 226841)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2018-01-12 04:47:31 UTC (rev 226842)
@@ -466,4 +466,16 @@
return nullptr;
}
+void JSDOMWindow::setOpener(JSC::ExecState& state, JSC::JSValue value)
+{
+ if (!BindingSecurity::shouldAllowAccessToDOMWindow(&state, wrapped(), ThrowSecurityError))
+ return;
+
+ if (value.isNull()) {
+ wrapped().disownOpener();
+ return;
+ }
+ replaceStaticPropertySlot(state.vm(), this, Identifier::fromString(&state.vm(), "opener"), value);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (226841 => 226842)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2018-01-12 03:31:27 UTC (rev 226841)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2018-01-12 04:47:31 UTC (rev 226842)
@@ -1425,6 +1425,12 @@
return opener->document()->domWindow();
}
+void DOMWindow::disownOpener()
+{
+ if (m_frame)
+ m_frame->loader().setOpener(nullptr);
+}
+
DOMWindow* DOMWindow::parent() const
{
if (!m_frame)
Modified: trunk/Source/WebCore/page/DOMWindow.h (226841 => 226842)
--- trunk/Source/WebCore/page/DOMWindow.h 2018-01-12 03:31:27 UTC (rev 226841)
+++ trunk/Source/WebCore/page/DOMWindow.h 2018-01-12 04:47:31 UTC (rev 226842)
@@ -198,6 +198,7 @@
DOMWindow* frames() const { return self(); }
DOMWindow* opener() const;
+ void disownOpener();
DOMWindow* parent() const;
DOMWindow* top() const;
Modified: trunk/Source/WebCore/page/DOMWindow.idl (226841 => 226842)
--- trunk/Source/WebCore/page/DOMWindow.idl 2018-01-12 03:31:27 UTC (rev 226841)
+++ trunk/Source/WebCore/page/DOMWindow.idl 2018-01-12 04:47:31 UTC (rev 226842)
@@ -73,7 +73,7 @@
[Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow frames;
[Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
[DoNotCheckSecurityOnGetter, Unforgeable] readonly attribute DOMWindow? top;
- [Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow? opener;
+ [DoNotCheckSecurityOnGetter, CustomSetter] attribute DOMWindow? opener;
[Replaceable, DoNotCheckSecurityOnGetter] readonly attribute DOMWindow? parent;
[CheckSecurityForNode] readonly attribute Element? frameElement;
[CallWith=ActiveWindow&FirstWindow] DOMWindow? open(optional USVString url = "" optional DOMString target = "_blank", optional [TreatNullAs=EmptyString] DOMString features = "");