Let MessageEvent.data hold SerializedScriptValue or String selectively
authoryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2011 09:25:16 +0000 (09:25 +0000)
committeryutak@chromium.org <yutak@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2011 09:25:16 +0000 (09:25 +0000)
commitf888a40ed902508ec1ba69afacf1c8aa96ae9fef
tree1333b4d4a127e76300ab807b0122ce8b3e8a89b1
parent9a066618e4cffa84f1345289a9c7ada61c469c88
Let MessageEvent.data hold SerializedScriptValue or String selectively
https://bugs.webkit.org/show_bug.cgi?id=66841

Reviewed by Adam Barth.

MessageEvent from WebSocket contains a String in its "data" attribute, but it does not have
to be serialized.

No new tests are added, because this is refactoring and the behavior should not change.

* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::data):
To call putAnonymousValue(), "this" needs to be converted to non-const using const_cast<>.
(WebCore::JSMessageEvent::initMessageEvent):
Update the cache value as well.
* bindings/v8/custom/V8MessageEventCustom.cpp:
(WebCore::V8MessageEvent::dataAccessorGetter):
ForceSet() is used to cache a value. This is the same as what the code generated by
CodeGeneratorV8 does.
(WebCore::V8MessageEvent::initMessageEventCallback):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::MessageEvent):
(WebCore::MessageEvent::initMessageEvent):
(WebCore::MessageEvent::data):
This is only used within the Objective-C bindings (JSC and V8 have the custom functions).
Since Objective-C code generator does not support [CustomGetter] IDL attribute, there is
no good way to return a variant value for Objective-C bindings.
* dom/MessageEvent.h:
(WebCore::MessageEvent::create):
(WebCore::MessageEvent::dataType):
(WebCore::MessageEvent::dataAsSerializedScriptValue):
(WebCore::MessageEvent::dataAsString):
* dom/MessageEvent.idl:
* websockets/WebSocket.cpp:
(WebCore::WebSocket::didReceiveMessage):
Construct a MessageEvent without serializing the received message.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93766 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/fast/dom/Window/script-tests/postmessage-test.js
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSMessageEventCustom.cpp
Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
Source/WebCore/dom/MessageEvent.cpp
Source/WebCore/dom/MessageEvent.h
Source/WebCore/dom/MessageEvent.idl
Source/WebCore/websockets/WebSocket.cpp