Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Set origin of ServiceWorkerMessageEvent to that of Service Worker to …
Browse files Browse the repository at this point in the history
…match spec.

Spec discussion: w3c/ServiceWorker#669

BUG=508796

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

git-svn-id: svn://svn.chromium.org/blink/trunk@198938 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
fatlotus committed Jul 15, 2015
1 parent 456eedf commit c52c580
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
2 changes: 1 addition & 1 deletion Source/modules/serviceworkers/ServiceWorkerContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void ServiceWorkerContainer::dispatchMessageEvent(WebServiceWorker* serviceWorke
MessagePortArray* ports = MessagePort::toMessagePortArray(executionContext(), webChannels);
RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance().createFromWire(message);
RefPtrWillBeRawPtr<ServiceWorker> 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
Expand Down
4 changes: 2 additions & 2 deletions Source/modules/serviceworkers/ServiceWorkerMessageEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class MODULES_EXPORT ServiceWorkerMessageEvent final : public Event {
return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(type, initializer));
}

static PassRefPtrWillBeRawPtr<ServiceWorkerMessageEvent> create(MessagePortArray* ports, PassRefPtr<SerializedScriptValue> data, PassRefPtrWillBeRawPtr<ServiceWorker> source)
static PassRefPtrWillBeRawPtr<ServiceWorkerMessageEvent> create(MessagePortArray* ports, PassRefPtr<SerializedScriptValue> data, PassRefPtrWillBeRawPtr<ServiceWorker> source, const String& origin)
{
return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(data, String(), String(), source, ports));
return adoptRefWillBeNoop(new ServiceWorkerMessageEvent(data, origin, String(), source, ports));
}

~ServiceWorkerMessageEvent() override;
Expand Down

0 comments on commit c52c580

Please sign in to comment.