diff --git a/LayoutTests/http/tests/serviceworker/postmessage-to-client.html b/LayoutTests/http/tests/serviceworker/postmessage-to-client.html index 499bedd0c92..397b41970df 100644 --- a/LayoutTests/http/tests/serviceworker/postmessage-to-client.html +++ b/LayoutTests/http/tests/serviceworker/postmessage-to-client.html @@ -25,6 +25,10 @@ function onMessage(e) { var message = e.data; + assert_equals(e.origin, location.origin, + 'origin of message should be origin of Service Worker'); + assert_equals(e.lastEventId, '', + 'lastEventId should be an empty string'); if (message === 'quit') { assert_array_equals(result, expected, 'Worker should post back expected messages.'); diff --git a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp index 0e5676b1eee..cbb117f1608 100644 --- a/Source/modules/serviceworkers/ServiceWorkerContainer.cpp +++ b/Source/modules/serviceworkers/ServiceWorkerContainer.cpp @@ -373,7 +373,7 @@ void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorke MessagePortArray* ports = MessagePort::toMessagePortArray(executionContext(), webChannels); RefPtr value = SerializedScriptValueFactory::instance().createFromWire(message); RefPtrWillBeRawPtr source = ServiceWorker::from(executionContext(), serviceWorker); - dispatchEvent(ServiceWorkerMessageEvent::create(ports, value, source)); + dispatchEvent(ServiceWorkerMessageEvent::create(ports, value, source, executionContext()->securityOrigin()->toString())); } const AtomicString& ServiceWorkerContainer::interfaceName() const diff --git a/Source/modules/serviceworkers/ServiceWorkerMessageEvent.h b/Source/modules/serviceworkers/ServiceWorkerMessageEvent.h index 832e66b2abd..37aa4de7bf1 100644 --- a/Source/modules/serviceworkers/ServiceWorkerMessageEvent.h +++ b/Source/modules/serviceworkers/ServiceWorkerMessageEvent.h @@ -26,9 +26,9 @@ class MODULES_EXPORT ServiceWorkerMessageEvent final : public Event { return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(type, initializer)); } - static PassRefPtrWillBeRawPtr create(MessagePortArray* ports, PassRefPtr data, PassRefPtrWillBeRawPtr source) + static PassRefPtrWillBeRawPtr create(MessagePortArray* ports, PassRefPtr data, PassRefPtrWillBeRawPtr source, const String& origin) { - return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(data, String(), String(), source, ports)); + return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(data, origin, String(), source, ports)); } ~ServiceWorkerMessageEvent() override;