Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Unified Diff: Source/core/dom/MessageEvent.cpp

Issue 23319002: Set MessageEvent.source to the newly created port for shared workers' connect events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test and assertions Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/MessageEvent.cpp
diff --git a/Source/core/dom/MessageEvent.cpp b/Source/core/dom/MessageEvent.cpp
index ce6e8fa0deb0aebb1d68207d4170dc359e2aaa01..bfbc96760418b9b76d5bb6c35e9661e7f014114f 100644
--- a/Source/core/dom/MessageEvent.cpp
+++ b/Source/core/dom/MessageEvent.cpp
@@ -33,6 +33,11 @@
namespace WebCore {
+static inline bool isValidSource(EventTarget* source)
+{
+ return !source || source->toDOMWindow() || source->toMessagePort();
+}
+
MessageEventInit::MessageEventInit()
{
}
@@ -52,9 +57,10 @@ MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& ini
, m_ports(adoptPtr(new MessagePortArray(initializer.ports)))
{
ScriptWrappable::init(this);
+ ASSERT(isValidSource(m_source.get()));
}
-MessageEvent::MessageEvent(const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray> ports)
+MessageEvent::MessageEvent(const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports)
: Event(eventNames().messageEvent, false, false)
, m_dataType(DataTypeScriptValue)
, m_origin(origin)
@@ -63,9 +69,10 @@ MessageEvent::MessageEvent(const String& origin, const String& lastEventId, Pass
, m_ports(ports)
{
ScriptWrappable::init(this);
+ ASSERT(isValidSource(m_source.get()));
}
-MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray> ports)
+MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports)
: Event(eventNames().messageEvent, false, false)
, m_dataType(DataTypeSerializedScriptValue)
, m_dataAsSerializedScriptValue(data)
@@ -77,6 +84,7 @@ MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String&
ScriptWrappable::init(this);
if (m_dataAsSerializedScriptValue)
m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptContext();
+ ASSERT(isValidSource(m_source.get()));
}
MessageEvent::MessageEvent(const String& data, const String& origin)

Powered by Google App Engine
This is Rietveld 408576698