Title: [223732] trunk/Source/WebCore
Revision
223732
Author
cdu...@apple.com
Date
2017-10-19 18:34:03 -0700 (Thu, 19 Oct 2017)

Log Message

SerializedScriptValue passed to postMessage() cannot be null
https://bugs.webkit.org/show_bug.cgi?id=178550

Reviewed by Youenn Fablet.

SerializedScriptValue passed to postMessage() cannot be null. Therefore, we
should use Ref<> type, not RefPtr<>.

* dom/MessagePortChannel.h:
* dom/default/PlatformMessagePortChannel.cpp:
(WebCore::MessagePortChannel::postMessageToRemote):
* workers/WorkerGlobalScopeProxy.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postMessageToWorkerObject):
(WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
* workers/WorkerMessagingProxy.h:
* workers/WorkerObjectProxy.h:
* workers/service/context/ServiceWorkerThread.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (223731 => 223732)


--- trunk/Source/WebCore/ChangeLog	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/ChangeLog	2017-10-20 01:34:03 UTC (rev 223732)
@@ -1,3 +1,24 @@
+2017-10-19  Chris Dumez  <cdu...@apple.com>
+
+        SerializedScriptValue passed to postMessage() cannot be null
+        https://bugs.webkit.org/show_bug.cgi?id=178550
+
+        Reviewed by Youenn Fablet.
+
+        SerializedScriptValue passed to postMessage() cannot be null. Therefore, we
+        should use Ref<> type, not RefPtr<>.
+
+        * dom/MessagePortChannel.h:
+        * dom/default/PlatformMessagePortChannel.cpp:
+        (WebCore::MessagePortChannel::postMessageToRemote):
+        * workers/WorkerGlobalScopeProxy.h:
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::postMessageToWorkerObject):
+        (WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
+        * workers/WorkerMessagingProxy.h:
+        * workers/WorkerObjectProxy.h:
+        * workers/service/context/ServiceWorkerThread.cpp:
+
 2017-10-19  Daniel Bates  <daba...@apple.com>
 
         Use "= default" to denote default constructor or destructor

Modified: trunk/Source/WebCore/dom/MessagePortChannel.h (223731 => 223732)


--- trunk/Source/WebCore/dom/MessagePortChannel.h	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/dom/MessagePortChannel.h	2017-10-20 01:34:03 UTC (rev 223732)
@@ -82,7 +82,7 @@
         bool hasPendingActivity();
 
         // Sends a message and optional cloned port to the remote port.
-        void postMessageToRemote(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>);
+        void postMessageToRemote(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&);
 
         // Extracts a message from the message queue for this port.
         std::unique_ptr<EventData> takeMessageFromRemote();

Modified: trunk/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp (223731 => 223732)


--- trunk/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp	2017-10-20 01:34:03 UTC (rev 223732)
@@ -80,7 +80,7 @@
         remote->setRemotePort(nullptr);
 }
 
-void MessagePortChannel::postMessageToRemote(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray> channels)
+void MessagePortChannel::postMessageToRemote(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels)
 {
     LockHolder lock(m_channel->m_mutex);
     if (!m_channel->m_outgoingQueue)

Modified: trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h (223731 => 223732)


--- trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h	2017-10-20 01:34:03 UTC (rev 223732)
@@ -52,7 +52,7 @@
 
     virtual void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) = 0;
     virtual void terminateWorkerGlobalScope() = 0;
-    virtual void postMessageToWorkerGlobalScope(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) = 0;
+    virtual void postMessageToWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&) = 0;
     virtual bool hasPendingActivity() const = 0;
     virtual void workerObjectDestroyed() = 0;
     virtual void notifyNetworkStateChange(bool isOnline) = 0;

Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp (223731 => 223732)


--- trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp	2017-10-20 01:34:03 UTC (rev 223732)
@@ -94,7 +94,7 @@
     m_inspectorProxy->workerStarted(m_scriptExecutionContext.get(), thread.ptr(), scriptURL);
 }
 
-void WorkerMessagingProxy::postMessageToWorkerObject(RefPtr<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray> channels)
+void WorkerMessagingProxy::postMessageToWorkerObject(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels)
 {
     m_scriptExecutionContext->postTask([this, channels = WTFMove(channels), message = WTFMove(message)] (ScriptExecutionContext& context) mutable {
         Worker* workerObject = this->workerObject();
@@ -106,7 +106,7 @@
     });
 }
 
-void WorkerMessagingProxy::postMessageToWorkerGlobalScope(RefPtr<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray> channels)
+void WorkerMessagingProxy::postMessageToWorkerGlobalScope(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels)
 {
     if (m_askedToTerminate)
         return;

Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.h (223731 => 223732)


--- trunk/Source/WebCore/workers/WorkerMessagingProxy.h	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.h	2017-10-20 01:34:03 UTC (rev 223732)
@@ -47,7 +47,7 @@
     // (Only use these functions in the worker object thread.)
     void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final;
     void terminateWorkerGlobalScope() final;
-    void postMessageToWorkerGlobalScope(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) final;
+    void postMessageToWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&) final;
     bool hasPendingActivity() const final;
     void workerObjectDestroyed() final;
     void notifyNetworkStateChange(bool isOnline) final;
@@ -54,7 +54,7 @@
 
     // Implementations of WorkerObjectProxy.
     // (Only use these functions in the worker context thread.)
-    void postMessageToWorkerObject(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) final;
+    void postMessageToWorkerObject(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&) final;
     void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) final;
     void postMessageToPageInspector(const String&) final;
     void confirmMessageFromWorkerObject(bool hasPendingActivity) final;

Modified: trunk/Source/WebCore/workers/WorkerObjectProxy.h (223731 => 223732)


--- trunk/Source/WebCore/workers/WorkerObjectProxy.h	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/workers/WorkerObjectProxy.h	2017-10-20 01:34:03 UTC (rev 223732)
@@ -41,7 +41,7 @@
     // A proxy to talk to the worker object.
     class WorkerObjectProxy : public WorkerReportingProxy {
     public:
-        virtual void postMessageToWorkerObject(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) = 0;
+        virtual void postMessageToWorkerObject(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&) = 0;
 
         virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
         virtual void reportPendingActivity(bool hasPendingActivity) = 0;

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (223731 => 223732)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2017-10-20 00:47:04 UTC (rev 223731)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2017-10-20 01:34:03 UTC (rev 223732)
@@ -55,7 +55,7 @@
     void postExceptionToWorkerObject(const String&, int, int, const String&) final { };
     void postMessageToPageInspector(const String&) final { };
     void workerGlobalScopeDestroyed() final { };
-    void postMessageToWorkerObject(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) final { };
+    void postMessageToWorkerObject(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&) final { };
     void confirmMessageFromWorkerObject(bool) final { };
     void reportPendingActivity(bool) final { };
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to