Commit d74afe4b authored by nhiroki@chromium.org's avatar nhiroki@chromium.org

WebMessaging: Show a warning when MessagePort attempts to send a transferable ArrayBuffer

In the current implementation, MessagePort does not support sending an
ArrayBuffer as a transferable object yet and unexpectedly loses the buffer
without any warning.

BUG=334408

Review URL: https://codereview.chromium.org/1301953002

git-svn-id: svn://svn.chromium.org/blink/trunk@200832 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 61244dcd
CONSOLE WARNING: MessagePort cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/334408
CONSOLE WARNING: MessagePort cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/334408
Tests various use cases when cloning MessagePorts. Tests various use cases when cloning MessagePorts.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
...@@ -238,6 +238,11 @@ void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() ...@@ -238,6 +238,11 @@ void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext()
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory); v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory);
} }
bool SerializedScriptValue::containsTransferableArrayBuffer() const
{
return m_arrayBufferContentsArray && !m_arrayBufferContentsArray->isEmpty();
}
SerializedScriptValue::~SerializedScriptValue() SerializedScriptValue::~SerializedScriptValue()
{ {
// If the allocated memory was not registered before, then this class is likely // If the allocated memory was not registered before, then this class is likely
......
...@@ -97,6 +97,9 @@ public: ...@@ -97,6 +97,9 @@ public:
// The memory registration is revoked automatically in destructor. // The memory registration is revoked automatically in destructor.
void registerMemoryAllocatedWithCurrentScriptContext(); void registerMemoryAllocatedWithCurrentScriptContext();
// Returns true if the value contains a transferable ArrayBuffer.
bool containsTransferableArrayBuffer() const;
private: private:
// The followings are private, but used by SerializedScriptValueFactory. // The followings are private, but used by SerializedScriptValueFactory.
enum StringDataMode { enum StringDataMode {
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "core/dom/ExecutionContext.h" #include "core/dom/ExecutionContext.h"
#include "core/events/MessageEvent.h" #include "core/events/MessageEvent.h"
#include "core/frame/LocalDOMWindow.h" #include "core/frame/LocalDOMWindow.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/workers/WorkerGlobalScope.h" #include "core/workers/WorkerGlobalScope.h"
#include "public/platform/WebString.h" #include "public/platform/WebString.h"
#include "wtf/Functional.h" #include "wtf/Functional.h"
...@@ -87,6 +88,9 @@ void MessagePort::postMessage(ExecutionContext* context, PassRefPtr<SerializedSc ...@@ -87,6 +88,9 @@ void MessagePort::postMessage(ExecutionContext* context, PassRefPtr<SerializedSc
return; return;
} }
if (message->containsTransferableArrayBuffer())
executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "MessagePort cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/334408"));
WebString messageString = message->toWireString(); WebString messageString = message->toWireString();
OwnPtr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(channels.release()); OwnPtr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(channels.release());
m_entangledChannel->postMessage(messageString, webChannels.leakPtr()); m_entangledChannel->postMessage(messageString, webChannels.leakPtr());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment