Title: [102317] trunk
Revision
102317
Author
dslo...@google.com
Date
2011-12-07 22:59:10 -0800 (Wed, 07 Dec 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=74038
[V8][Chromium] Support legacy argument order in window.postMessage/window.webkitPostMessage.

Reviewed by David Levin.

Source/WebCore:

* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::isLegacyTargetOriginDesignation):
(WebCore::handlePostMessageCallback):

LayoutTests:

* fast/dom/Window/window-postmessage-args-expected.txt:
* fast/dom/Window/window-postmessage-args.html: New tests for legacy argument order.
* platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102316 => 102317)


--- trunk/LayoutTests/ChangeLog	2011-12-08 06:50:01 UTC (rev 102316)
+++ trunk/LayoutTests/ChangeLog	2011-12-08 06:59:10 UTC (rev 102317)
@@ -1,3 +1,14 @@
+2011-12-07  Dmitry Lomov  <dslo...@google.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=74038
+        [V8][Chromium] Support legacy argument order in window.postMessage/window.webkitPostMessage.
+
+        Reviewed by David Levin.
+
+        * fast/dom/Window/window-postmessage-args-expected.txt:
+        * fast/dom/Window/window-postmessage-args.html: New tests for legacy argument order.
+        * platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:
+
 2011-12-07  Kenichi Ishibashi  <ba...@chromium.org>
 
         Unreviewed, rebaseline media/controls-layout-direction.html

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


--- trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 06:50:01 UTC (rev 102316)
+++ trunk/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 06:59:10 UTC (rev 102317)
@@ -8,11 +8,14 @@
 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 ('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 ('7a', *) did not throw an exception
 FAIL: Posting message ('7', [object MessagePort],[object MessagePort]): threw exception TypeError: Type error
 PASS: Posting message ('2147483648', null) did not throw an exception
 PASS: Posting message ('2147483648', null) did not throw an exception
@@ -23,10 +26,13 @@
 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 '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 '7a' with 2 ports.
 Received message '2147483648' with 0 ports.
 Received message '2147483648' with 0 ports.
 Received message 'done' with 0 ports.

Modified: trunk/LayoutTests/fast/dom/Window/window-postmessage-args.html (102316 => 102317)


--- trunk/LayoutTests/fast/dom/Window/window-postmessage-args.html	2011-12-08 06:50:01 UTC (rev 102316)
+++ trunk/LayoutTests/fast/dom/Window/window-postmessage-args.html	2011-12-08 06:59:10 UTC (rev 102317)
@@ -46,10 +46,13 @@
 tryPostMessage('2', '*', 'c', true);
 tryPostMessage('3', '*', { x: 1 }, true);
 tryPostMessage('4', '*', window);  // Passes because window has a "length" attribute of value '0', so it looks like an array
+tryPostMessage('4a', window, '*'); // Legacy argument order.
 tryPostMessage('5', '*', null);
 tryPostMessage('6', '*', void 0);
 var channel1 = new MessageChannel;
 tryPostMessageFunction(window.postMessage, '7', '*', [channel1.port1, channel1.port2]);
+var channel1a = new MessageChannel;
+tryPostMessageFunction(window.postMessage, '7a', [channel1a.port1, channel1a.port2], '*');
 var channel2 = new MessageChannel;
 tryPostMessageFunction(window.webkitPostMessage, '7', '*', [channel2.port1, channel2.port2]);
 var channel3 = new MessageChannel;

Modified: trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt (102316 => 102317)


--- trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 06:50:01 UTC (rev 102316)
+++ trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 06:59:10 UTC (rev 102317)
@@ -8,11 +8,14 @@
 PASS: Posting message ('3', [object Object]): threw exception TypeError: TransferArray argument has no length attribute
 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
 PASS: Posting message ('7', [object MessagePort],[object MessagePort]) did not throw an exception
+PASS: Posting message ('7a', *) did not throw an exception
 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
@@ -25,11 +28,14 @@
 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.

Modified: trunk/Source/WebCore/ChangeLog (102316 => 102317)


--- trunk/Source/WebCore/ChangeLog	2011-12-08 06:50:01 UTC (rev 102316)
+++ trunk/Source/WebCore/ChangeLog	2011-12-08 06:59:10 UTC (rev 102317)
@@ -1,3 +1,14 @@
+2011-12-07  Dmitry Lomov  <dslo...@google.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=74038
+        [V8][Chromium] Support legacy argument order in window.postMessage/window.webkitPostMessage.
+
+        Reviewed by David Levin.
+
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::isLegacyTargetOriginDesignation):
+        (WebCore::handlePostMessageCallback):
+
 2011-12-07  Mary Wu  <mary...@torchmobile.com.cn>
 
         Upstream 4 files into WebCore/platform/blackberry

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp (102316 => 102317)


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2011-12-08 06:50:01 UTC (rev 102316)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2011-12-08 06:59:10 UTC (rev 102317)
@@ -286,6 +286,14 @@
     return v8::Undefined();
 }
 
+static bool isLegacyTargetOriginDesignation(v8::Handle<v8::Value> value)
+{
+    if (value->IsString() || value->IsStringObject())
+        return true;
+    return false;
+}
+
+
 static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool extendedTransfer)
 {
     DOMWindow* window = V8DOMWindow::toNative(args.Holder());
@@ -293,20 +301,28 @@
     DOMWindow* source = V8Proxy::retrieveFrameForCallingContext()->domWindow();
     ASSERT(source->frame());
 
-    // This function has variable arguments and can either be:
-    //   postMessage(message, port, targetOrigin);
-    // or
-    //   postMessage(message, targetOrigin);
+    // 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);
     MessagePortArray portArray;
     ArrayBufferArray arrayBufferArray;
     String targetOrigin;
     {
         v8::TryCatch tryCatch;
+        int targetOriginArgIndex = 1;
         if (args.Length() > 2) {
-            if (!extractTransferables(args[2], portArray, arrayBufferArray))
+            int transferablesArgIndex = 2;
+            if (isLegacyTargetOriginDesignation(args[2])) {
+                targetOriginArgIndex = 2;
+                transferablesArgIndex = 1;
+            }
+            if (!extractTransferables(args[transferablesArgIndex], portArray, arrayBufferArray))
                 return v8::Undefined();
         } 
-        targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[1]);
+        targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[targetOriginArgIndex]);
 
         if (tryCatch.HasCaught())
             return v8::Undefined();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to