Title: [231037] trunk
Revision
231037
Author
[email protected]
Date
2018-04-25 17:55:49 -0700 (Wed, 25 Apr 2018)

Log Message

window.postMessage() / focus() / blur() throw a TypeError when called on a RemoteDOMWindow
https://bugs.webkit.org/show_bug.cgi?id=184981

Reviewed by Sam Weinig.

Source/WebCore:

window.postMessage() / focus() / blur() was throwing a TypeError when called on a RemoteDOMWindow,
complaining that |this| is not a Window. This was caused by a copy & paste mistake in
JSDOMWindowCustom where we were calling the JSDOMWindow methods instead of the JSRemoteDOMWindow
ones.

No new tests, updated existing tests.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
* page/RemoteDOMWindow.cpp:
(WebCore::RemoteDOMWindow::postMessage):
* page/RemoteDOMWindow.h:
* page/RemoteDOMWindow.idl:

LayoutTests:

Add layout test coverage.

* http/tests/navigation/process-swap-window-open-expected.txt:
* http/tests/navigation/process-swap-window-open.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (231036 => 231037)


--- trunk/LayoutTests/ChangeLog	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/LayoutTests/ChangeLog	2018-04-26 00:55:49 UTC (rev 231037)
@@ -1,3 +1,15 @@
+2018-04-25  Chris Dumez  <[email protected]>
+
+        window.postMessage() / focus() / blur() throw a TypeError when called on a RemoteDOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=184981
+
+        Reviewed by Sam Weinig.
+
+        Add layout test coverage.
+
+        * http/tests/navigation/process-swap-window-open-expected.txt:
+        * http/tests/navigation/process-swap-window-open.html:
+
 2018-04-25  Jiewen Tan  <[email protected]>
 
         Unreviewed test gardening

Modified: trunk/LayoutTests/http/tests/navigation/process-swap-window-open-expected.txt (231036 => 231037)


--- trunk/LayoutTests/http/tests/navigation/process-swap-window-open-expected.txt	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/LayoutTests/http/tests/navigation/process-swap-window-open-expected.txt	2018-04-26 00:55:49 UTC (rev 231037)
@@ -28,6 +28,9 @@
 PASS w.focus is an instance of Function
 PASS w.blur is an instance of Function
 PASS w.postMessage is an instance of Function
+PASS w.postMessage('test', '*') did not throw exception.
+PASS w.focus() did not throw exception.
+PASS w.blur() did not throw exception.
 PASS w.location did not throw exception.
 FAIL w.location should not be null.
 PASS areArraysEqual(actual_properties, expected_property_names) is true

Modified: trunk/LayoutTests/http/tests/navigation/process-swap-window-open.html (231036 => 231037)


--- trunk/LayoutTests/http/tests/navigation/process-swap-window-open.html	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/LayoutTests/http/tests/navigation/process-swap-window-open.html	2018-04-26 00:55:49 UTC (rev 231037)
@@ -36,6 +36,9 @@
     shouldBeType("w.focus", "Function");
     shouldBeType("w.blur", "Function");
     shouldBeType("w.postMessage", "Function");
+    shouldNotThrow("w.postMessage('test', '*')");
+    shouldNotThrow("w.focus()");
+    shouldNotThrow("w.blur()");
 
     shouldNotThrow("w.location");
     shouldNotBe("w.location", "null");

Modified: trunk/Source/WebCore/ChangeLog (231036 => 231037)


--- trunk/Source/WebCore/ChangeLog	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/Source/WebCore/ChangeLog	2018-04-26 00:55:49 UTC (rev 231037)
@@ -1,3 +1,24 @@
+2018-04-25  Chris Dumez  <[email protected]>
+
+        window.postMessage() / focus() / blur() throw a TypeError when called on a RemoteDOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=184981
+
+        Reviewed by Sam Weinig.
+
+        window.postMessage() / focus() / blur() was throwing a TypeError when called on a RemoteDOMWindow,
+        complaining that |this| is not a Window. This was caused by a copy & paste mistake in
+        JSDOMWindowCustom where we were calling the JSDOMWindow methods instead of the JSRemoteDOMWindow
+        ones.
+
+        No new tests, updated existing tests.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::jsDOMWindowGetOwnPropertySlotRestrictedAccess):
+        * page/RemoteDOMWindow.cpp:
+        (WebCore::RemoteDOMWindow::postMessage):
+        * page/RemoteDOMWindow.h:
+        * page/RemoteDOMWindow.idl:
+
 2018-04-25  Simon Fraser  <[email protected]>
 
         brightness() filter should default to 1, and not allow negative values

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (231036 => 231037)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2018-04-26 00:55:49 UTC (rev 231037)
@@ -100,15 +100,15 @@
         return true;
     }
     if (propertyName == builtinNames.closePublicName()) {
-        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>);
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionClose, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionClose, 0>);
         return true;
     }
     if (propertyName == builtinNames.focusPublicName()) {
-        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>);
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionFocus, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionFocus, 0>);
         return true;
     }
     if (propertyName == builtinNames.postMessagePublicName()) {
-        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>);
+        slot.setCustom(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum), windowType == DOMWindowType::Remote ? nonCachingStaticFunctionGetter<jsRemoteDOMWindowInstanceFunctionPostMessage, 0> : nonCachingStaticFunctionGetter<jsDOMWindowInstanceFunctionPostMessage, 2>);
         return true;
     }
 

Modified: trunk/Source/WebCore/page/RemoteDOMWindow.cpp (231036 => 231037)


--- trunk/Source/WebCore/page/RemoteDOMWindow.cpp	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/Source/WebCore/page/RemoteDOMWindow.cpp	2018-04-26 00:55:49 UTC (rev 231037)
@@ -115,7 +115,7 @@
     return &m_frame->windowProxy();
 }
 
-ExceptionOr<void> RemoteDOMWindow::postMessage(JSC::ExecState&, DOMWindow& incumbentWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&)
+void RemoteDOMWindow::postMessage(JSC::ExecState&, DOMWindow& incumbentWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&)
 {
     UNUSED_PARAM(incumbentWindow);
     UNUSED_PARAM(message);
@@ -122,7 +122,6 @@
     UNUSED_PARAM(targetOrigin);
 
     // FIXME: Implemented this.
-    return Exception { NotSupportedError };
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/RemoteDOMWindow.h (231036 => 231037)


--- trunk/Source/WebCore/page/RemoteDOMWindow.h	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/Source/WebCore/page/RemoteDOMWindow.h	2018-04-26 00:55:49 UTC (rev 231037)
@@ -65,7 +65,7 @@
     WindowProxy* top() const;
     WindowProxy* opener() const;
     WindowProxy* parent() const;
-    ExceptionOr<void> postMessage(JSC::ExecState&, DOMWindow& incumbentWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&);
+    void postMessage(JSC::ExecState&, DOMWindow& incumbentWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&);
 
 private:
     WEBCORE_EXPORT RemoteDOMWindow(Ref<RemoteFrame>&&, GlobalWindowIdentifier&&);

Modified: trunk/Source/WebCore/page/RemoteDOMWindow.idl (231036 => 231037)


--- trunk/Source/WebCore/page/RemoteDOMWindow.idl	2018-04-26 00:42:20 UTC (rev 231036)
+++ trunk/Source/WebCore/page/RemoteDOMWindow.idl	2018-04-26 00:55:49 UTC (rev 231037)
@@ -55,5 +55,5 @@
     [Unforgeable] readonly attribute WindowProxy? top;
     readonly attribute WindowProxy? opener;
     [Replaceable] readonly attribute WindowProxy? parent;
-    [CallWith=ScriptState&IncumbentWindow, ForwardDeclareInHeader, MayThrowException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
+    [CallWith=ScriptState&IncumbentWindow, ForwardDeclareInHeader] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to