Title: [160309] trunk
Revision
160309
Author
[email protected]
Date
2013-12-09 04:42:54 -0800 (Mon, 09 Dec 2013)

Log Message

Source/WebCore: DataCloneError exception is not thrown when postMessage's second parameter is the source
port or the target port.

https://bugs.webkit.org/show_bug.cgi?id=124708

Patch by Michal Poteralski <[email protected]> on 2013-12-09
Reviewed by Alexey Proskuryakov.

According to specification:
http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#dom-window-postmessage

If the method was invoked with a second argument transfer then if any of the objects in the
transfer are either the source port or the target port (if any), then a DataCloneError
exception should be thrown. Currently an InvalidStateError exception is thrown what is an
incorrect behaviour.

The proposed solution is change to the correct the exception value.

Tests: fast/dom/Window/postMessage-clone-port-error.html

* dom/MessagePort.cpp:
(WebCore::MessagePort::postMessage): Improve exception value

LayoutTests: DataCloneError exception is not thrown when postMessage's second parameter
is the source port or the target port.

https://bugs.webkit.org/show_bug.cgi?id=124708

Patch by Michal Poteralski <[email protected]> on 2013-12-09
Reviewed by Alexey Proskuryakov.

Added layout test to check correctness of value thrown by postMessage:

* fast/dom/Window/postMessage-clone-port-error-expected.txt: Added.
* fast/dom/Window/postMessage-clone-port-error.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (160308 => 160309)


--- trunk/LayoutTests/ChangeLog	2013-12-09 12:28:44 UTC (rev 160308)
+++ trunk/LayoutTests/ChangeLog	2013-12-09 12:42:54 UTC (rev 160309)
@@ -1,3 +1,17 @@
+2013-12-09  Michal Poteralski  <[email protected]>
+
+        DataCloneError exception is not thrown when postMessage's second parameter
+        is the source port or the target port.
+
+        https://bugs.webkit.org/show_bug.cgi?id=124708
+
+        Reviewed by Alexey Proskuryakov.
+
+        Added layout test to check correctness of value thrown by postMessage:
+
+        * fast/dom/Window/postMessage-clone-port-error-expected.txt: Added.
+        * fast/dom/Window/postMessage-clone-port-error.html: Added.
+
 2013-12-09  Gustavo Noronha Silva  <[email protected]>
 
         accessibility/press-targets-center-point.html should not depend on font layout

Added: trunk/LayoutTests/fast/dom/Window/postMessage-clone-port-error-expected.txt (0 => 160309)


--- trunk/LayoutTests/fast/dom/Window/postMessage-clone-port-error-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/postMessage-clone-port-error-expected.txt	2013-12-09 12:42:54 UTC (rev 160309)
@@ -0,0 +1,5 @@
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS exName is "DataCloneError"
+

Added: trunk/LayoutTests/fast/dom/Window/postMessage-clone-port-error.html (0 => 160309)


--- trunk/LayoutTests/fast/dom/Window/postMessage-clone-port-error.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Window/postMessage-clone-port-error.html	2013-12-09 12:42:54 UTC (rev 160309)
@@ -0,0 +1,21 @@
+<body _onload_="test();"></body>
+<script src=""
+<script>
+var exName;
+function test() {
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    var channel = new MessageChannel();
+    channel.port1.start();
+
+    try {
+        channel.port1.postMessage("ports", [channel.port1]);
+    } catch(ex) {
+        exName = ex.name
+        shouldBeEqualToString("exName", "DataCloneError");
+    }
+}
+</script>
+<script src=""
+</body>

Modified: trunk/LayoutTests/fast/events/message-port-clone-expected.txt (160308 => 160309)


--- trunk/LayoutTests/fast/events/message-port-clone-expected.txt	2013-12-09 12:28:44 UTC (rev 160308)
+++ trunk/LayoutTests/fast/events/message-port-clone-expected.txt	2013-12-09 12:42:54 UTC (rev 160309)
@@ -2,8 +2,8 @@
 
 Should be a series of SUCCESS messages, followed with DONE.
 
-SUCCESS: Posting port to itself: Error: InvalidStateError: DOM Exception 11
-SUCCESS: Posting entangled port: Error: InvalidStateError: DOM Exception 11
+SUCCESS: Posting port to itself: Error: DataCloneError: DOM Exception 25
+SUCCESS: Posting entangled port: Error: DataCloneError: DOM Exception 25
 SUCCESS: Posting cloned port.
 SUCCESS: Posted messages to cloned port.
 SUCCESS: Cloned both endpoints of a channel.

Modified: trunk/LayoutTests/fast/events/message-port-multi-expected.txt (160308 => 160309)


--- trunk/LayoutTests/fast/events/message-port-multi-expected.txt	2013-12-09 12:28:44 UTC (rev 160308)
+++ trunk/LayoutTests/fast/events/message-port-multi-expected.txt	2013-12-09 12:42:54 UTC (rev 160309)
@@ -3,8 +3,8 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS channel.port1.postMessage("same port", [channel.port1]) threw exception Error: InvalidStateError: DOM Exception 11.
-PASS channel.port1.postMessage("entangled port", [channel.port2]) threw exception Error: InvalidStateError: DOM Exception 11.
+PASS channel.port1.postMessage("same port", [channel.port1]) threw exception Error: DataCloneError: DOM Exception 25.
+PASS channel.port1.postMessage("entangled port", [channel.port2]) threw exception Error: DataCloneError: DOM Exception 25.
 PASS channel.port1.postMessage("null port", [channel3.port1, null, channel3.port2]) threw exception Error: InvalidStateError: DOM Exception 11.
 PASS channel.port1.postMessage("notAPort", [channel3.port1, {}, channel3.port2]) threw exception TypeError: Type error.
 PASS channel.port1.postMessage("duplicate port", [channel3.port1, channel3.port1]) threw exception Error: InvalidStateError: DOM Exception 11.

Modified: trunk/Source/WebCore/ChangeLog (160308 => 160309)


--- trunk/Source/WebCore/ChangeLog	2013-12-09 12:28:44 UTC (rev 160308)
+++ trunk/Source/WebCore/ChangeLog	2013-12-09 12:42:54 UTC (rev 160309)
@@ -1,3 +1,27 @@
+2013-12-09  Michal Poteralski  <[email protected]>
+
+        DataCloneError exception is not thrown when postMessage's second parameter is the source
+        port or the target port.
+
+        https://bugs.webkit.org/show_bug.cgi?id=124708
+
+        Reviewed by Alexey Proskuryakov.
+
+        According to specification:
+        http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#dom-window-postmessage
+
+        If the method was invoked with a second argument transfer then if any of the objects in the
+        transfer are either the source port or the target port (if any), then a DataCloneError
+        exception should be thrown. Currently an InvalidStateError exception is thrown what is an
+        incorrect behaviour.
+
+        The proposed solution is change to the correct the exception value.
+
+        Tests: fast/dom/Window/postMessage-clone-port-error.html
+
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::postMessage): Improve exception value
+
 2013-12-09  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Fix the GTK+ build with NetworkProcess enabled.

Modified: trunk/Source/WebCore/dom/MessagePort.cpp (160308 => 160309)


--- trunk/Source/WebCore/dom/MessagePort.cpp	2013-12-09 12:28:44 UTC (rev 160308)
+++ trunk/Source/WebCore/dom/MessagePort.cpp	2013-12-09 12:42:54 UTC (rev 160309)
@@ -72,7 +72,7 @@
         for (unsigned int i = 0; i < ports->size(); ++i) {
             MessagePort* dataPort = (*ports)[i].get();
             if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort)) {
-                ec = INVALID_STATE_ERR;
+                ec = DATA_CLONE_ERR;
                 return;
             }
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to