| Index: third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
|
| diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
|
| index 16d287892bc8d21b2b1d550f3473cf21fe7da29f..a3a1933757e7a17869aca70df7193e50d7abe781 100644
|
| --- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
|
| +++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
|
| @@ -36,6 +36,7 @@
|
| #include "core/events/Event.h"
|
| #include "core/inspector/ConsoleMessage.h"
|
| #include "modules/EventTargetModules.h"
|
| +#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
|
| #include "public/platform/WebMessagePortChannel.h"
|
| #include "public/platform/WebString.h"
|
| #include "public/platform/modules/serviceworker/WebServiceWorkerState.h"
|
| @@ -49,6 +50,12 @@ const AtomicString& ServiceWorker::interfaceName() const
|
|
|
| void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionState)
|
| {
|
| + ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(executionContext());
|
| + if (!client || !client->provider()) {
|
| + exceptionState.throwDOMException(InvalidStateError, "Failed to post a message: No associated provider is available.");
|
| + return;
|
| + }
|
| +
|
| // Disentangle the port in preparation for sending it to the remote context.
|
| OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(context, ports, exceptionState);
|
| if (exceptionState.hadException())
|
| @@ -63,7 +70,7 @@ void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<Serialized
|
|
|
| WebString messageString = message->toWireString();
|
| OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release());
|
| - m_handle->serviceWorker()->postMessage(messageString, webChannels.leakPtr());
|
| + m_handle->serviceWorker()->postMessage(client->provider(), messageString, webChannels.leakPtr());
|
| }
|
|
|
| void ServiceWorker::internalsTerminate()
|
|
|