Title: [203846] trunk
Revision
203846
Author
[email protected]
Date
2016-07-28 15:17:49 -0700 (Thu, 28 Jul 2016)

Log Message

2 first parameters to window.postMessage() should be mandatory
https://bugs.webkit.org/show_bug.cgi?id=160319

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

2 first parameters to window.postMessage() should be mandatory:
- https://html.spec.whatwg.org/multipage/browsers.html#the-window-object

Firefox and Chrome agree with the specification.

No new tests, rebaselined existing test.

* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::handlePostMessage):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203845 => 203846)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-28 22:05:49 UTC (rev 203845)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-28 22:17:49 UTC (rev 203846)
@@ -1,5 +1,16 @@
 2016-07-28  Chris Dumez  <[email protected]>
 
+        2 first parameters to window.postMessage() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160319
+
+        Reviewed by Darin Adler.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
+2016-07-28  Chris Dumez  <[email protected]>
+
         First parameter to canvas.getContext() / probablySupportsContext() should be mandatory
         https://bugs.webkit.org/show_bug.cgi?id=160312
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (203845 => 203846)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-07-28 22:05:49 UTC (rev 203845)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-07-28 22:17:49 UTC (rev 203846)
@@ -5322,9 +5322,7 @@
 PASS Window interface: window must inherit property "showModalDialog" with the proper type (34) 
 PASS Window interface: calling showModalDialog(DOMString,any) on window with too few arguments must throw TypeError 
 PASS Window interface: window must inherit property "postMessage" with the proper type (35) 
-FAIL Window interface: calling postMessage(any,DOMString,[object Object]) on window with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "SyntaxError (DOM Exception 12): The string did not match ..." ("SyntaxError") expected object "TypeError" ("TypeError")
+PASS Window interface: calling postMessage(any,DOMString,[object Object]) on window with too few arguments must throw TypeError 
 PASS Window interface: window must inherit property "captureEvents" with the proper type (36) 
 PASS Window interface: window must inherit property "releaseEvents" with the proper type (37) 
 PASS Window interface: window must inherit property "onabort" with the proper type (38) 

Modified: trunk/Source/WebCore/ChangeLog (203845 => 203846)


--- trunk/Source/WebCore/ChangeLog	2016-07-28 22:05:49 UTC (rev 203845)
+++ trunk/Source/WebCore/ChangeLog	2016-07-28 22:17:49 UTC (rev 203846)
@@ -1,5 +1,22 @@
 2016-07-28  Chris Dumez  <[email protected]>
 
+        2 first parameters to window.postMessage() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160319
+
+        Reviewed by Darin Adler.
+
+        2 first parameters to window.postMessage() should be mandatory:
+        - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object
+
+        Firefox and Chrome agree with the specification.
+
+        No new tests, rebaselined existing test.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::handlePostMessage):
+
+2016-07-28  Chris Dumez  <[email protected]>
+
         First parameter to canvas.getContext() / probablySupportsContext() should be mandatory
         https://bugs.webkit.org/show_bug.cgi?id=160312
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (203845 => 203846)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-07-28 22:05:49 UTC (rev 203845)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2016-07-28 22:17:49 UTC (rev 203846)
@@ -518,6 +518,9 @@
 
 static JSValue handlePostMessage(DOMWindow& impl, ExecState& state)
 {
+    if (UNLIKELY(state.argumentCount() < 2))
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
     MessagePortArray messagePorts;
     ArrayBufferArray arrayBuffers;
 
@@ -530,7 +533,7 @@
     int targetOriginArgIndex = 1;
     if (state.argumentCount() > 2) {
         int transferablesArgIndex = 2;
-        if (state.argument(2).isString()) {
+        if (state.uncheckedArgument(2).isString()) {
             targetOriginArgIndex = 2;
             transferablesArgIndex = 1;
         }
@@ -539,12 +542,12 @@
     if (state.hadException())
         return jsUndefined();
 
-    auto message = SerializedScriptValue::create(&state, state.argument(0), &messagePorts, &arrayBuffers);
+    auto message = SerializedScriptValue::create(&state, state.uncheckedArgument(0), &messagePorts, &arrayBuffers);
 
     if (state.hadException())
         return jsUndefined();
 
-    String targetOrigin = valueToStringWithUndefinedOrNullCheck(&state, state.argument(targetOriginArgIndex));
+    String targetOrigin = valueToStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(targetOriginArgIndex));
     if (state.hadException())
         return jsUndefined();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to