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 85047432b18a241eece8970955421cedeb2f4bd0..d5f53676d2166ff35b680af47b94f8cb43fe89eb 100644 |
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp |
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp |
@@ -36,7 +36,9 @@ |
#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/WebSecurityOrigin.h" |
#include "public/platform/WebString.h" |
#include "public/platform/modules/serviceworker/WebServiceWorkerState.h" |
@@ -49,6 +51,12 @@ const AtomicString& ServiceWorker::interfaceName() const |
void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionState) |
{ |
+ ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(getExecutionContext()); |
+ 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 +71,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, WebSecurityOrigin(getExecutionContext()->getSecurityOrigin()), webChannels.leakPtr()); |
} |
void ServiceWorker::internalsTerminate() |