window.postMessage() / MessagePort.postMessage() throw wrong exception for invalid...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 10:37:10 +0000 (10:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Aug 2012 10:37:10 +0000 (10:37 +0000)
commit333cb3ceecd43aad855eafff249a3e1f462cdf2f
tree9c99df10fd30a60583863d267989f8bf0a069e04
parent2ef66895d0726131a506a1561f43eb9c129aebef
window.postMessage() / MessagePort.postMessage() throw wrong exception for invalid ports argument
https://bugs.webkit.org/show_bug.cgi?id=94581

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-08-22
Reviewed by Kentaro Hara.

Source/WebCore:

Update JSC and V8 implementations of window.postMessage() and
MessagePort.postMessage() in order to throw an
INVALID_STATE_ERR instead of a DATA_CLONE_ERR when values
in the "ports" argument are invalid. Additionally, we now
check for duplicate ports and throw an exception for this
case as well.

This change was made to comply with the latest HTML5
specification at:
http://www.w3.org/TR/html5/comms.html

No new tests, already tested by:
fast/events/constructors/message-event-constructor.html
fast/events/message-port-clone.html
fast/events/message-port-multi.html
fast/workers/worker-context-multi-port.html
fast/workers/worker-multi-port.html

* bindings/js/JSMessagePortCustom.cpp:
(WebCore::fillMessagePortArray):
* bindings/v8/V8Utilities.cpp:
(WebCore::extractTransferables):
* dom/MessagePort.cpp:
(WebCore::MessagePort::postMessage):

LayoutTests:

Update several tests and their expected results now that an
INVALID_STATE_ERR is thrown instead of a DATA_CLONE_ERROR
when window.postMessage() / MessagePort.postMessage() are
called with invalid values in their 'ports' argument.

* fast/events/constructors/message-event-constructor-expected.txt:
* fast/events/constructors/message-event-constructor.html: Stop using duplicate
ports in the test since it throws an exception now.
* fast/events/message-port-clone-expected.txt:
* fast/events/message-port-multi-expected.txt:
* fast/events/resources/message-port-multi.js: Add check for duplicate port case.
* fast/workers/worker-context-multi-port-expected.txt:
* fast/workers/worker-multi-port-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126286 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/constructors/message-event-constructor-expected.txt
LayoutTests/fast/events/constructors/message-event-constructor.html
LayoutTests/fast/events/message-port-clone-expected.txt
LayoutTests/fast/events/message-port-multi-expected.txt
LayoutTests/fast/events/resources/message-port-multi.js
LayoutTests/fast/workers/worker-context-multi-port-expected.txt
LayoutTests/fast/workers/worker-multi-port-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSMessagePortCustom.cpp
Source/WebCore/bindings/v8/V8Utilities.cpp
Source/WebCore/dom/MessagePort.cpp