WebKit Bugzilla
Attachment 342800 Details for
Bug 186593
: User gesture context is not passed via MessageChannel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
186593.patch (text/plain), 8.74 KB, created by
Frédéric Wang (:fredw)
on 2018-06-15 03:14:14 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Frédéric Wang (:fredw)
Created:
2018-06-15 03:14:14 PDT
Size:
8.74 KB
patch
obsolete
>diff --git a/Source/WebCore/dom/MessagePort.cpp b/Source/WebCore/dom/MessagePort.cpp >index 6f7fd36be3..d23af2825c 100644 >--- a/Source/WebCore/dom/MessagePort.cpp >+++ b/Source/WebCore/dom/MessagePort.cpp >@@ -33,6 +33,7 @@ > #include "MessageEvent.h" > #include "MessagePortChannelProvider.h" > #include "MessageWithMessagePorts.h" >+#include "UserGestureIndicator.h" > #include "WorkerGlobalScope.h" > #include "WorkerThread.h" > >@@ -157,7 +158,7 @@ ExceptionOr<void> MessagePort::postMessage(JSC::ExecState& state, JSC::JSValue m > transferredPorts = disentangleResult.releaseReturnValue(); > } > >- MessageWithMessagePorts message { messageData.releaseReturnValue(), WTFMove(transferredPorts) }; >+ MessageWithMessagePorts message { messageData.releaseReturnValue(), WTFMove(transferredPorts), UserGestureIndicator::currentUserGesture() }; > > LOG(MessagePorts, "Actually posting message to port %s (to be received by port %s)", m_identifier.logString().utf8().data(), m_remoteIdentifier.logString().utf8().data()); > >@@ -272,6 +273,7 @@ void MessagePort::dispatchMessages() > // close() in Worker onmessage handler should prevent next message from dispatching. > if (contextIsWorker && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).isClosing()) > return; >+ UserGestureIndicator gestureIndicator(ProcessingUserGesture); > auto ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(message.transferredPorts)); > dispatchEvent(MessageEvent::create(WTFMove(ports), message.message.releaseNonNull())); > } >diff --git a/Source/WebCore/dom/messageports/MessageWithMessagePorts.h b/Source/WebCore/dom/messageports/MessageWithMessagePorts.h >index 8dedf4ed88..ea1ae7453d 100644 >--- a/Source/WebCore/dom/messageports/MessageWithMessagePorts.h >+++ b/Source/WebCore/dom/messageports/MessageWithMessagePorts.h >@@ -27,6 +27,7 @@ > > #include "MessagePortIdentifier.h" > #include "SerializedScriptValue.h" >+#include "UserGestureIndicator.h" > #include <wtf/RefPtr.h> > > namespace WebCore { >@@ -38,6 +39,7 @@ typedef Vector<std::pair<WebCore::MessagePortIdentifier, WebCore::MessagePortIde > struct MessageWithMessagePorts { > RefPtr<SerializedScriptValue> message; > TransferredMessagePortArray transferredPorts; >+ RefPtr<UserGestureToken> m_userGestureToForward; > > template<class Encoder> void encode(Encoder&) const; > template<class Decoder> static std::optional<MessageWithMessagePorts> decode(Decoder&); >diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp >index ffb07b8232..554633af96 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -156,7 +156,6 @@ public: > , m_source(source) > , m_targetOrigin(WTFMove(targetOrigin)) > , m_stackTrace(stackTrace) >- , m_userGestureToForward(UserGestureIndicator::currentUserGesture()) > { > } > >@@ -174,7 +173,7 @@ private: > // This object gets deleted when std::unique_ptr falls out of scope.. > std::unique_ptr<PostMessageTimer> timer(this); > >- UserGestureIndicator userGestureIndicator(m_userGestureToForward); >+ UserGestureIndicator userGestureIndicator(m_message.m_userGestureToForward); > m_window->postMessageTimerFired(*timer); > } > >@@ -184,7 +183,6 @@ private: > RefPtr<WindowProxy> m_source; > RefPtr<SecurityOrigin> m_targetOrigin; > RefPtr<ScriptCallStack> m_stackTrace; >- RefPtr<UserGestureToken> m_userGestureToForward; > }; > > typedef HashCountedSet<DOMWindow*> DOMWindowSet; >@@ -958,7 +956,7 @@ ExceptionOr<void> DOMWindow::postMessage(JSC::ExecState& state, DOMWindow& incum > if (InspectorInstrumentation::consoleAgentEnabled(sourceDocument)) > stackTrace = createScriptCallStack(JSMainThreadExecState::currentState()); > >- MessageWithMessagePorts message { messageData.releaseReturnValue(), disentangledPorts.releaseReturnValue() }; >+ MessageWithMessagePorts message { messageData.releaseReturnValue(), disentangledPorts.releaseReturnValue(), UserGestureIndicator::currentUserGesture() }; > > // Schedule the message. > RefPtr<WindowProxy> incumbentWindowProxy = incumbentWindow.frame() ? &incumbentWindow.frame()->windowProxy() : nullptr; >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >index 21ddedb3d0..8289627609 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >@@ -37,6 +37,7 @@ > #include "DedicatedWorkerThread.h" > #include "MessageEvent.h" > #include "SecurityOrigin.h" >+#include "UserGestureIndicator.h" > #include "WorkerObjectProxy.h" > > namespace WebCore { >@@ -73,7 +74,7 @@ ExceptionOr<void> DedicatedWorkerGlobalScope::postMessage(JSC::ExecState& state, > if (channels.hasException()) > return channels.releaseException(); > >- thread().workerObjectProxy().postMessageToWorkerObject({ message.releaseReturnValue(), channels.releaseReturnValue() }); >+ thread().workerObjectProxy().postMessageToWorkerObject({ message.releaseReturnValue(), channels.releaseReturnValue(), UserGestureIndicator::currentUserGesture() }); > return { }; > } > >diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp >index 382447493a..bebb93781a 100644 >--- a/Source/WebCore/workers/Worker.cpp >+++ b/Source/WebCore/workers/Worker.cpp >@@ -35,6 +35,7 @@ > #include "PlatformStrategies.h" > #include "ResourceResponse.h" > #include "SecurityOrigin.h" >+#include "UserGestureIndicator.h" > #include "WorkerGlobalScopeProxy.h" > #include "WorkerScriptLoader.h" > #include "WorkerThread.h" >@@ -132,7 +133,7 @@ ExceptionOr<void> Worker::postMessage(JSC::ExecState& state, JSC::JSValue messag > if (channels.hasException()) > return channels.releaseException(); > >- m_contextProxy.postMessageToWorkerGlobalScope({ message.releaseReturnValue(), channels.releaseReturnValue() }); >+ m_contextProxy.postMessageToWorkerGlobalScope({ message.releaseReturnValue(), channels.releaseReturnValue(), UserGestureIndicator::currentUserGesture() }); > return { }; > } > >diff --git a/Source/WebCore/workers/service/ServiceWorker.cpp b/Source/WebCore/workers/service/ServiceWorker.cpp >index 2d9decedd0..8cb568fba8 100644 >--- a/Source/WebCore/workers/service/ServiceWorker.cpp >+++ b/Source/WebCore/workers/service/ServiceWorker.cpp >@@ -38,6 +38,7 @@ > #include "ServiceWorkerClientData.h" > #include "ServiceWorkerGlobalScope.h" > #include "ServiceWorkerProvider.h" >+#include "UserGestureIndicator.h" > #include <JavaScriptCore/JSCJSValueInlines.h> > #include <wtf/NeverDestroyed.h> > >@@ -124,7 +125,7 @@ ExceptionOr<void> ServiceWorker::postMessage(ScriptExecutionContext& context, JS > sourceIdentifier = ServiceWorkerClientIdentifier { connection.serverConnectionIdentifier(), downcast<Document>(context).identifier() }; > } > >- MessageWithMessagePorts message = { messageData.releaseReturnValue(), portsOrException.releaseReturnValue() }; >+ MessageWithMessagePorts message = { messageData.releaseReturnValue(), portsOrException.releaseReturnValue(), UserGestureIndicator::currentUserGesture() }; > callOnMainThread([sessionID = context.sessionID(), destinationIdentifier = identifier(), message = WTFMove(message), sourceIdentifier = WTFMove(sourceIdentifier)]() mutable { > auto& connection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(sessionID); > connection.postMessageToServiceWorker(destinationIdentifier, WTFMove(message), sourceIdentifier); >diff --git a/Source/WebCore/workers/service/ServiceWorkerClient.cpp b/Source/WebCore/workers/service/ServiceWorkerClient.cpp >index 7391c4c21a..91ba4e774a 100644 >--- a/Source/WebCore/workers/service/ServiceWorkerClient.cpp >+++ b/Source/WebCore/workers/service/ServiceWorkerClient.cpp >@@ -35,6 +35,7 @@ > #include "ServiceWorkerGlobalScope.h" > #include "ServiceWorkerThread.h" > #include "ServiceWorkerWindowClient.h" >+#include "UserGestureIndicator.h" > > namespace WebCore { > >@@ -97,7 +98,7 @@ ExceptionOr<void> ServiceWorkerClient::postMessage(ScriptExecutionContext& conte > if (portsOrException.hasException()) > return portsOrException.releaseException(); > >- MessageWithMessagePorts message = { messageData.releaseReturnValue(), portsOrException.releaseReturnValue() }; >+ MessageWithMessagePorts message = { messageData.releaseReturnValue(), portsOrException.releaseReturnValue(), UserGestureIndicator::currentUserGesture() }; > auto sourceIdentifier = downcast<ServiceWorkerGlobalScope>(context).thread().identifier(); > callOnMainThread([message = WTFMove(message), destinationIdentifier = identifier(), sourceIdentifier, sourceOrigin = context.origin().isolatedCopy()] () mutable { > if (auto* connection = SWContextManager::singleton().connection())
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186593
:
342800
|
342918
|
343234
|
354837
|
363084
|
369470
|
369478