Title: [102722] trunk
Revision
102722
Author
[email protected]
Date
2011-12-13 17:17:41 -0800 (Tue, 13 Dec 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=73691
[JSC] Implement correct order of window.postMessage arguments.
This change supports a new signature of windowPostMessage:
  postMessage(message, targetOrigin[, transferrables])
as well as the legacy webkit-proprietary:
  postMessage(message, [transferrables,] targetOrigin)
The latter is only supported for cases when targetOrigin is a String.

Reviewed by David Levin.

Source/WebCore:

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

LayoutTests:

* fast/dom/Window/window-postmessage-args-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102721 => 102722)


--- trunk/LayoutTests/ChangeLog	2011-12-14 01:03:01 UTC (rev 102721)
+++ trunk/LayoutTests/ChangeLog	2011-12-14 01:17:41 UTC (rev 102722)
@@ -1,3 +1,17 @@
+2011-12-13  Dmitry Lomov  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=73691
+        [JSC] Implement correct order of window.postMessage arguments.
+        This change supports a new signature of windowPostMessage:
+          postMessage(message, targetOrigin[, transferrables])
+        as well as the legacy webkit-proprietary:
+          postMessage(message, [transferrables,] targetOrigin)
+        The latter is only supported for cases when targetOrigin is a String.
+
+        Reviewed by David Levin.
+
+        * fast/dom/Window/window-postmessage-args-expected.txt:
+
 2011-12-13  Tony Chang  <[email protected]>
 
         Rolling out r102461, a change to a layout test to try to remove flakiness on Chromium.

Modified: trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt (102721 => 102722)


--- trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-14 01:03:01 UTC (rev 102721)
+++ trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-14 01:17:41 UTC (rev 102722)
@@ -6,34 +6,41 @@
 PASS: Posting message ('2', c): threw exception TypeError: Type error
 PASS: Posting message ('3', [object Object]): threw exception TypeError: Type error
 PASS: Posting message ('3', [object Object]): threw exception TypeError: Type error
-FAIL: Posting message ('4', [object DOMWindow]): threw exception TypeError: Type error
-FAIL: Posting message ('4', [object DOMWindow]): threw exception TypeError: Type error
+PASS: Posting message ('4', [object DOMWindow]) did not throw an exception
+PASS: Posting message ('4', [object DOMWindow]) did not throw an exception
 PASS: Posting message ('4a', *) did not throw an exception
 PASS: Posting message ('4a', *) did not throw an exception
 PASS: Posting message ('5', null) did not throw an exception
 PASS: Posting message ('5', null) did not throw an exception
 PASS: Posting message ('6', undefined) did not throw an exception
 PASS: Posting message ('6', undefined) did not throw an exception
-FAIL: Posting message ('7', [object MessagePort],[object MessagePort]): threw exception TypeError: Type error
+PASS: Posting message ('7', [object MessagePort],[object MessagePort]) did not throw an exception
 PASS: Posting message ('7a', *) did not throw an exception
-FAIL: Posting message ('7', [object MessagePort],[object MessagePort]): threw exception TypeError: Type error
+PASS: Posting message ('7', [object MessagePort],[object MessagePort]) did not throw an exception
 PASS: Posting message ('2147483648', null) did not throw an exception
 PASS: Posting message ('2147483648', null) did not throw an exception
-FAIL: Posting message ('[object MessagePort]', [object MessagePort],[object MessagePort]): threw exception TypeError: Type error
-FAIL: Posting message ('[object MessagePort]', [object MessagePort],[object MessagePort]): threw exception TypeError: Type error
-FAIL: Posting message ('[object MessagePort],[object MessagePort]', [object MessagePort],[object MessagePort]): threw exception TypeError: Type error
+PASS: Posting message ('[object MessagePort]', [object MessagePort],[object MessagePort]) did not throw an exception
+PASS: Posting message ('[object MessagePort]', [object MessagePort],[object MessagePort]) did not throw an exception
+PASS: Posting message ('[object MessagePort],[object MessagePort]', [object MessagePort],[object MessagePort]) did not throw an exception
 FAIL: Posting message ('[object ArrayBuffer]', [object ArrayBuffer]): threw exception TypeError: Type error
 FAIL: arrayBuffer not neutered; byteLength = 30
 FAIL: view was not neutered; length = 10
 PASS: Posting message ('done', undefined) did not throw an exception
+Received message '4' with 0 ports.
+Received message '4' with 0 ports.
 Received message '4a' with 0 ports.
 Received message '4a' with 0 ports.
 Received message '5' with 0 ports.
 Received message '5' with 0 ports.
 Received message '6' with 0 ports.
 Received message '6' with 0 ports.
+Received message '7' with 2 ports.
 Received message '7a' with 2 ports.
+Received message '7' with 2 ports.
 Received message '2147483648' with 0 ports.
 Received message '2147483648' with 0 ports.
+Received message '[object Object]' with 2 ports.
+Received message '[object MessagePort]' with 2 ports.
+Received message '[object MessagePort],[object MessagePort]' with 2 ports.
 Received message 'done' with 0 ports.
 

Modified: trunk/Source/WebCore/ChangeLog (102721 => 102722)


--- trunk/Source/WebCore/ChangeLog	2011-12-14 01:03:01 UTC (rev 102721)
+++ trunk/Source/WebCore/ChangeLog	2011-12-14 01:17:41 UTC (rev 102722)
@@ -1,3 +1,19 @@
+2011-12-13  Dmitry Lomov  <[email protected]>
+
+        https://bugs.webkit.org/show_bug.cgi?id=73691
+        [JSC] Implement correct order of window.postMessage arguments.
+        This change supports a new signature of windowPostMessage:
+          postMessage(message, targetOrigin[, transferrables])
+        as well as the legacy webkit-proprietary:
+          postMessage(message, [transferrables,] targetOrigin)
+        The latter is only supported for cases when targetOrigin is a String.
+
+        Reviewed by David Levin.
+
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::handlePostMessage):
+        * page/DOMWindow.idl:
+
 2011-12-13  Rafael Weinstein  <[email protected]>
 
         [MutationObservers] Avoid allocations if no observers are present

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (102721 => 102722)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2011-12-14 01:03:01 UTC (rev 102721)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp	2011-12-14 01:17:41 UTC (rev 102722)
@@ -705,8 +705,22 @@
 static JSValue handlePostMessage(DOMWindow* impl, ExecState* exec, bool doTransfer)
 {
     MessagePortArray messagePorts;
-    if (exec->argumentCount() > 2)
-        fillMessagePortArray(exec, exec->argument(1), messagePorts);
+
+    // This function has variable arguments and can be:
+    // Per current spec:
+    //   postMessage(message, targetOrigin)
+    //   postMessage(message, targetOrigin, {sequence of transferrables})
+    // Legacy non-standard implementations in webkit allowed:
+    //   postMessage(message, {sequence of transferrables}, targetOrigin);
+    int targetOriginArgIndex = 1;
+    if (exec->argumentCount() > 2) {
+        int transferablesArgIndex = 2;
+        if (exec->argument(2).isString()) {
+            targetOriginArgIndex = 2;
+            transferablesArgIndex = 1;
+        }
+        fillMessagePortArray(exec, exec->argument(transferablesArgIndex), messagePorts);
+    }
     if (exec->hadException())
         return jsUndefined();
 
@@ -716,7 +730,7 @@
     if (exec->hadException())
         return jsUndefined();
 
-    String targetOrigin = valueToStringWithUndefinedOrNullCheck(exec, exec->argument((exec->argumentCount() == 2) ? 1 : 2));
+    String targetOrigin = valueToStringWithUndefinedOrNullCheck(exec, exec->argument(targetOriginArgIndex));
     if (exec->hadException())
         return jsUndefined();
 

Modified: trunk/Source/WebCore/page/DOMWindow.idl (102721 => 102722)


--- trunk/Source/WebCore/page/DOMWindow.idl	2011-12-14 01:03:01 UTC (rev 102721)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2011-12-14 01:17:41 UTC (rev 102722)
@@ -212,12 +212,12 @@
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
         [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in DOMString targetOrigin)
             raises(DOMException);
-        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in Array messagePorts, in DOMString targetOrigin)
+        [DoNotCheckDomainSecurity, Custom] void postMessage(in SerializedScriptValue message, in DOMString targetOrigin, in Array messagePorts)
             raises(DOMException);
 
         [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in DOMString targetOrigin)
             raises(DOMException);
-        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in Array transferList, in DOMString targetOrigin)
+        [DoNotCheckDomainSecurity, Custom] void webkitPostMessage(in SerializedScriptValue message, in DOMString targetOrigin, in Array transferList)
             raises(DOMException);
 #else
         // There's no good way to expose an array via the ObjC bindings, so for now just allow passing in a single port.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to