Title: [102386] branches/chromium/963
Revision
102386
Author
dslo...@google.com
Date
2011-12-08 14:38:12 -0800 (Thu, 08 Dec 2011)

Log Message

Merge 102317 - 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:


TBR=ca...@chromium.org
ISSUE=http://code.google.com/p/chromium/issues/detail?id=106797
Review URL: http://codereview.chromium.org/8883032

Modified Paths

Diff

Modified: branches/chromium/963/LayoutTests/ChangeLog (102385 => 102386)


--- branches/chromium/963/LayoutTests/ChangeLog	2011-12-08 22:29:39 UTC (rev 102385)
+++ branches/chromium/963/LayoutTests/ChangeLog	2011-12-08 22:38:12 UTC (rev 102386)
@@ -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-02  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r101731.

Modified: branches/chromium/963/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt (102385 => 102386)


--- branches/chromium/963/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 22:29:39 UTC (rev 102385)
+++ branches/chromium/963/LayoutTests/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 22:38:12 UTC (rev 102386)
@@ -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: branches/chromium/963/LayoutTests/fast/dom/Window/window-postmessage-args.html (102385 => 102386)


--- branches/chromium/963/LayoutTests/fast/dom/Window/window-postmessage-args.html	2011-12-08 22:29:39 UTC (rev 102385)
+++ branches/chromium/963/LayoutTests/fast/dom/Window/window-postmessage-args.html	2011-12-08 22:38:12 UTC (rev 102386)
@@ -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: branches/chromium/963/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt (102385 => 102386)


--- branches/chromium/963/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 22:29:39 UTC (rev 102385)
+++ branches/chromium/963/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-08 22:38:12 UTC (rev 102386)
@@ -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: branches/chromium/963/Source/WebCore/ChangeLog (102385 => 102386)


--- branches/chromium/963/Source/WebCore/ChangeLog	2011-12-08 22:29:39 UTC (rev 102385)
+++ branches/chromium/963/Source/WebCore/ChangeLog	2011-12-08 22:38:12 UTC (rev 102386)
@@ -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-06  Adrienne Walker  <e...@google.com>
 
         [chromium] Don't crash if tile upload happens without painting first

Modified: branches/chromium/963/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp (102385 => 102386)


--- branches/chromium/963/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2011-12-08 22:29:39 UTC (rev 102385)
+++ branches/chromium/963/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2011-12-08 22:38:12 UTC (rev 102386)
@@ -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