Title: [101831] trunk
Revision
101831
Author
dslo...@google.com
Date
2011-12-02 11:00:27 -0800 (Fri, 02 Dec 2011)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=73589
[V8][Chromium] Adjust postMessage to the latest "implementation-ready" spec.
- postMessage should support transfer of MessagePorts
- the order of arguments to Window::postMessage and Window::webkitPostMessage should be (msg, targetOrigin [, transfer])

Reviewed by David Levin.

Source/WebCore:

* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::handlePostMessageCallback):
* bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp:
(WebCore::handlePostMessageCallback):
* bindings/v8/custom/V8MessagePortCustom.cpp:
(WebCore::handlePostMessageCallback):
* bindings/v8/custom/V8WorkerCustom.cpp:
(WebCore::handlePostMessageCallback):

LayoutTests:

* fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js:
(wrapSend):
(wrapFailSend):
* fast/dom/Window/window-postmessage-args.html:
* platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (101830 => 101831)


--- trunk/LayoutTests/ChangeLog	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/LayoutTests/ChangeLog	2011-12-02 19:00:27 UTC (rev 101831)
@@ -1,3 +1,18 @@
+2011-12-01  Dmitry Lomov  <dslo...@google.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=73589
+        [V8][Chromium] Adjust postMessage to the latest "implementation-ready" spec.
+        - postMessage should support transfer of MessagePorts
+        - the order of arguments to Window::postMessage and Window::webkitPostMessage should be (msg, targetOrigin [, transfer])
+
+        Reviewed by David Levin.
+
+        * fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js:
+        (wrapSend):
+        (wrapFailSend):
+        * fast/dom/Window/window-postmessage-args.html:
+        * platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt:
+
 2011-12-02  Tom Sepez  <tse...@chromium.org>
 
         Content-security-policy script-src not enforced on workers.

Modified: trunk/LayoutTests/fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js (101830 => 101831)


--- trunk/LayoutTests/fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/LayoutTests/fast/canvas/webgl/script-tests/arraybuffer-transfer-of-control.js	2011-12-02 19:00:27 UTC (rev 101831)
@@ -241,7 +241,7 @@
 function wrapSend(testName, message, xfer)
 {
     try {
-        window.webkitPostMessage(message, xfer, '*');
+        window.webkitPostMessage(message, '*', xfer);
     } catch (e) {
         testFailed(testName + ": could not webkitPostMessage: " + e);
         doneTest();
@@ -253,7 +253,7 @@
 function wrapFailSend(testName, message, xfer)
 {
     try {
-        window.webkitPostMessage(message, xfer, '*');
+        window.webkitPostMessage(message, '*', xfer);
     } catch (e) {
         return true;
     }

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


--- trunk/LayoutTests/fast/dom/Window/window-postmessage-args.html	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/LayoutTests/fast/dom/Window/window-postmessage-args.html	2011-12-02 19:00:27 UTC (rev 101831)
@@ -29,9 +29,9 @@
             postMessageFunction(first, second);
         else
             postMessageFunction(first, second, third);
-        console.innerHTML += (shouldFail ? "FAIL" : "PASS") + ": Posting message ('" + first + "', " + second + ") did not throw an exception<br>";
+        console.innerHTML += (shouldFail ? "FAIL" : "PASS") + ": Posting message ('" + first + "', " + third + ") did not throw an exception<br>";
    } catch (e) {
-        console.innerHTML += (shouldFail ? "PASS" : "FAIL") + ": Posting message ('" + first + "', " + second + "): threw exception " + e + "<br>";
+        console.innerHTML += (shouldFail ? "PASS" : "FAIL") + ": Posting message ('" + first + "', " + third + "): threw exception " + e + "<br>";
    }
 }
 
@@ -42,27 +42,27 @@
 
 document.getElementById("description").innerHTML = "Test that the second argument of window.postMessage is ignored or triggers an error if it is not a message port. You should see PASS message '1' through '7', followed by 'done', with messages 4-7 received below.<br><br>";
 
-tryPostMessage('1', 1, '*', true);
-tryPostMessage('2', "", '*', 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('5', null, '*');
-tryPostMessage('6', void 0, '*');
+tryPostMessage('1', '*', 1, true);
+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('5', '*', null);
+tryPostMessage('6', '*', void 0);
 var channel1 = new MessageChannel;
-tryPostMessageFunction(window.postMessage, '7', [channel1.port1, channel1.port2], '*');
+tryPostMessageFunction(window.postMessage, '7', '*', [channel1.port1, channel1.port2]);
 var channel2 = new MessageChannel;
-tryPostMessageFunction(window.webkitPostMessage, '7', [channel2.port1, channel2.port2], '*');
+tryPostMessageFunction(window.webkitPostMessage, '7', '*', [channel2.port1, channel2.port2]);
 var channel3 = new MessageChannel;
-tryPostMessage(2147483648, null, '*');
-tryPostMessageFunction(window.postMessage, channel3.port1, [channel3.port1, channel3.port2], '*', true);
+tryPostMessage(2147483648, '*', null);
+tryPostMessageFunction(window.postMessage, channel3.port1, '*', [channel3.port1, channel3.port2]);
 var channel4 = new MessageChannel;
-tryPostMessageFunction(window.webkitPostMessage, channel4.port1, [channel4.port1, channel4.port2], '*');
+tryPostMessageFunction(window.webkitPostMessage, channel4.port1, '*', [channel4.port1, channel4.port2]);
 var channel5 = new MessageChannel;
-tryPostMessageFunction(window.webkitPostMessage, [channel5.port1, channel5.port2], [channel5.port1, channel5.port2], '*');
+tryPostMessageFunction(window.webkitPostMessage, [channel5.port1, channel5.port2], '*', [channel5.port1, channel5.port2]);
 
 var arrayBuffer = new ArrayBuffer(30);
 var int8View = new Int8Array(arrayBuffer, 2, 10);
-tryPostMessageFunction(window.webkitPostMessage, arrayBuffer, [arrayBuffer], '*');
+tryPostMessageFunction(window.webkitPostMessage, arrayBuffer, '*', [arrayBuffer]);
 if (!(arrayBuffer.byteLength === 0)) {
     console.innerHTML += "FAIL: arrayBuffer not neutered; byteLength = " + arrayBuffer.byteLength + "<br>";
 }

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


--- trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/LayoutTests/platform/chromium/fast/dom/Window/window-postmessage-args-expected.txt	2011-12-02 19:00:27 UTC (rev 101831)
@@ -2,8 +2,8 @@
 
 PASS: Posting message ('1', 1): threw exception TypeError: TransferArray argument must be an object
 PASS: Posting message ('1', 1): threw exception TypeError: TransferArray argument must be an object
-PASS: Posting message ('2', ): threw exception TypeError: TransferArray argument must be an object
-PASS: Posting message ('2', ): threw exception TypeError: TransferArray argument must be an object
+PASS: Posting message ('2', c): threw exception TypeError: TransferArray argument must be an object
+PASS: Posting message ('2', c): threw exception TypeError: TransferArray argument must be an object
 PASS: Posting message ('3', [object Object]): threw exception TypeError: TransferArray argument has no length attribute
 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
@@ -16,13 +16,13 @@
 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
-PASS: Posting message ('[object MessagePort]', [object MessagePort],[object MessagePort]): threw exception Error: DATA_CLONE_ERR: DOM Exception 25
 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
 PASS: Posting message ('[object ArrayBuffer]', [object ArrayBuffer]) did not throw an exception
 PASS: arrayBuffer neutered
 PASS: view neutered
-PASS: Posting message ('done', *) did not throw an exception
+PASS: Posting message ('done', undefined) did not throw an exception
 Received message '4' with 0 ports.
 Received message '4' with 0 ports.
 Received message '5' with 0 ports.
@@ -34,6 +34,7 @@
 Received message '2147483648' with 0 ports.
 Received message '2147483648' with 0 ports.
 Received message '[object MessagePort]' with 2 ports.
+Received message '[object MessagePort]' with 2 ports.
 Received message '[object MessagePort],[object MessagePort]' with 2 ports.
 Received message '[object ArrayBuffer]' with 0 ports.
 Received message 'done' with 0 ports.

Modified: trunk/Source/WebCore/ChangeLog (101830 => 101831)


--- trunk/Source/WebCore/ChangeLog	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/Source/WebCore/ChangeLog	2011-12-02 19:00:27 UTC (rev 101831)
@@ -1,3 +1,21 @@
+2011-12-01  Dmitry Lomov  <dslo...@google.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=73589
+        [V8][Chromium] Adjust postMessage to the latest "implementation-ready" spec.
+        - postMessage should support transfer of MessagePorts
+        - the order of arguments to Window::postMessage and Window::webkitPostMessage should be (msg, targetOrigin [, transfer])
+
+        Reviewed by David Levin.
+
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::handlePostMessageCallback):
+        * bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp:
+        (WebCore::handlePostMessageCallback):
+        * bindings/v8/custom/V8MessagePortCustom.cpp:
+        (WebCore::handlePostMessageCallback):
+        * bindings/v8/custom/V8WorkerCustom.cpp:
+        (WebCore::handlePostMessageCallback):
+
 2011-12-02  Enrica Casucci  <enr...@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=73497

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


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2011-12-02 19:00:27 UTC (rev 101831)
@@ -286,7 +286,7 @@
     return v8::Undefined();
 }
 
-static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool doTransfer)
+static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool extendedTransfer)
 {
     DOMWindow* window = V8DOMWindow::toNative(args.Holder());
 
@@ -303,11 +303,10 @@
     {
         v8::TryCatch tryCatch;
         if (args.Length() > 2) {
-            if (!extractTransferables(args[1], portArray, arrayBufferArray))
+            if (!extractTransferables(args[2], portArray, arrayBufferArray))
                 return v8::Undefined();
-            targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[2]);
-        } else
-            targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[1]);
+        } 
+        targetOrigin = toWebCoreStringWithNullOrUndefinedCheck(args[1]);
 
         if (tryCatch.HasCaught())
             return v8::Undefined();
@@ -317,8 +316,8 @@
     bool didThrow = false;
     RefPtr<SerializedScriptValue> message =
         SerializedScriptValue::create(args[0],
-                                      doTransfer ? &portArray : 0,
-                                      doTransfer ? &arrayBufferArray : 0,
+                                      &portArray,
+                                      extendedTransfer ? &arrayBufferArray : 0,
                                       didThrow);
     if (didThrow)
         return v8::Undefined();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp (101830 => 101831)


--- trunk/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DedicatedWorkerContextCustom.cpp	2011-12-02 19:00:27 UTC (rev 101831)
@@ -43,7 +43,7 @@
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool doTransfer)
+static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool extendedTransfer)
 {
     DedicatedWorkerContext* workerContext = V8DedicatedWorkerContext::toNative(args.Holder());
     MessagePortArray ports;
@@ -55,8 +55,8 @@
     bool didThrow = false;
     RefPtr<SerializedScriptValue> message =
         SerializedScriptValue::create(args[0],
-                                      doTransfer ? &ports : 0,
-                                      doTransfer ? &arrayBuffers : 0,
+                                      &ports,
+                                      extendedTransfer ? &arrayBuffers : 0,
                                       didThrow);
     if (didThrow)
         return v8::Undefined();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp (101830 => 101831)


--- trunk/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/Source/WebCore/bindings/v8/custom/V8MessagePortCustom.cpp	2011-12-02 19:00:27 UTC (rev 101831)
@@ -42,7 +42,7 @@
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool doTransfer)
+static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool extendedTransfer)
 {
     MessagePort* messagePort = V8MessagePort::toNative(args.Holder());
     MessagePortArray portArray;
@@ -54,8 +54,8 @@
     bool didThrow = false;
     RefPtr<SerializedScriptValue> message =
         SerializedScriptValue::create(args[0],
-                                      doTransfer ? &portArray : 0,
-                                      doTransfer ? &arrayBufferArray : 0,
+                                      &portArray,
+                                      extendedTransfer ? &arrayBufferArray : 0,
                                       didThrow);
     if (didThrow)
         return v8::Undefined();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp (101830 => 101831)


--- trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp	2011-12-02 18:57:09 UTC (rev 101830)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WorkerCustom.cpp	2011-12-02 19:00:27 UTC (rev 101831)
@@ -47,7 +47,7 @@
 
 namespace WebCore {
 
-static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool doTransfer)
+static v8::Handle<v8::Value> handlePostMessageCallback(const v8::Arguments& args, bool extendedTransfer)
 {
     INC_STATS("DOM.Worker.postMessage");
     Worker* worker = V8Worker::toNative(args.Holder());
@@ -60,8 +60,8 @@
     bool didThrow = false;
     RefPtr<SerializedScriptValue> message =
         SerializedScriptValue::create(args[0],
-                                      doTransfer ? &ports : 0,
-                                      doTransfer ? &arrayBuffers : 0,
+                                      &ports,
+                                      extendedTransfer ? &arrayBuffers : 0,
                                       didThrow);
     if (didThrow)
         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