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

ServiceWorker: Show a warning when ServiceWorker(Client) attempts to send a...

ServiceWorker: Show a warning when ServiceWorker(Client) attempts to send a transferable ArrayBuffer

In the current implementation, ServiceWorker and ServiceWorkerClient do not
support sending an ArrayBuffer as a transferable object yet and unexpectedly
lose the buffer without any warning.

BUG=511119

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

git-svn-id: svn://svn.chromium.org/blink/trunk@200883 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7cf01454
......@@ -35,6 +35,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/MessagePort.h"
#include "core/events/Event.h"
#include "core/inspector/ConsoleMessage.h"
#include "modules/EventTargetModules.h"
#include "public/platform/WebMessagePortChannel.h"
#include "public/platform/WebString.h"
......@@ -58,6 +59,9 @@ void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<Serialized
return;
}
if (message->containsTransferableArrayBuffer())
context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "ServiceWorker cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/511119"));
WebString messageString = message->toWireString();
OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release());
m_outerWorker->postMessage(messageString, webChannels.leakPtr());
......
......@@ -8,6 +8,7 @@
#include "bindings/core/v8/CallbackPromiseAdapter.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/SerializedScriptValue.h"
#include "core/inspector/ConsoleMessage.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
#include "public/platform/WebString.h"
#include "wtf/RefPtr.h"
......@@ -54,6 +55,9 @@ void ServiceWorkerClient::postMessage(ExecutionContext* context, PassRefPtr<Seri
if (exceptionState.hadException())
return;
if (message->containsTransferableArrayBuffer())
context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "ServiceWorkerClient cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/511119"));
WebString messageString = message->toWireString();
OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release());
ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_uuid, messageString, webChannels.release());
......
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