Skip to content

Commit 7e8fdc3

Browse files
committed
fix(inspector): mark user gesture in frames
1 parent ba80369 commit 7e8fdc3

5 files changed

+20
-8
lines changed

Source/WebCore/dom/UserGestureIndicator.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ UserGestureIndicator::UserGestureIndicator(Optional<ProcessingUserGestureState>
5656

5757
if (state)
5858
currentToken() = UserGestureToken::create(state.value(), gestureType);
59-
60-
if (document && currentToken()->processingUserGesture() && state) {
59+
if (document && currentToken() && currentToken()->processingUserGesture() && state) {
6160
document->updateLastHandledUserGestureTimestamp(currentToken()->startTime());
6261
if (processInteractionStyle == ProcessInteractionStyle::Immediate)
6362
ResourceLoadObserver::shared().logUserInteractionWithReducedTimeResolution(document->topDocument());

Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "Frame.h"
3939
#include "InspectorPageAgent.h"
4040
#include "InstrumentingAgents.h"
41+
#include "JSDOMWindowBase.h"
4142
#include "Page.h"
4243
#include "PageConsoleClient.h"
4344
#include "PageScriptDebugServer.h"
@@ -70,8 +71,11 @@ bool PageDebuggerAgent::enabled() const
7071

7172
void PageDebuggerAgent::evaluateOnCallFrame(ErrorString& errorString, const String& callFrameId, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
7273
{
74+
InjectedScript injectedScript = injectedScriptManager().injectedScriptForObjectId(callFrameId);
75+
JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
76+
Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
7377
auto shouldEmulateUserGesture = emulateUserGesture && *emulateUserGesture;
74-
UserGestureEmulationScope userGestureScope(m_inspectedPage, shouldEmulateUserGesture);
78+
UserGestureEmulationScope userGestureScope(m_inspectedPage, shouldEmulateUserGesture, document);
7579

7680
WebDebuggerAgent::evaluateOnCallFrame(errorString, callFrameId, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
7781
}

Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,21 @@ void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobal
205205

206206
void PageRuntimeAgent::evaluate(ErrorString& errorString, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
207207
{
208-
UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture));
208+
InjectedScript injectedScript = injectedScriptForEval(errorString, executionContextId);
209+
if (!errorString.isEmpty())
210+
return;
211+
JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
212+
Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
213+
UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture), document);
209214
InspectorRuntimeAgent::evaluate(errorString, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, executionContextId, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
210215
}
211216

212217
void PageRuntimeAgent::callFunctionOn(ErrorString& errorString, const String& objectId, const String& expression, const JSON::Array* optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown)
213218
{
214-
UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture));
219+
InjectedScript injectedScript = injectedScriptManager().injectedScriptForObjectId(objectId);
220+
JSC::JSGlobalObject* globalObject = injectedScript.globalObject();
221+
Document* document = globalObject ? activeDOMWindow(*globalObject).document() : nullptr;
222+
UserGestureEmulationScope userGestureScope(m_inspectedPage, asBool(emulateUserGesture), document);
215223
InspectorRuntimeAgent::callFunctionOn(errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);
216224
}
217225

Source/WebCore/inspector/agents/page/UserGestureEmulationScope.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939

4040
namespace WebCore {
4141

42-
UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture)
42+
UserGestureEmulationScope::UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document)
4343
: m_pageChromeClient(inspectedPage.chrome().client())
44-
, m_gestureIndicator(emulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt)
44+
, m_gestureIndicator(emulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt, document)
4545
, m_emulateUserGesture(emulateUserGesture)
4646
, m_userWasInteracting(false)
4747
{

Source/WebCore/inspector/agents/page/UserGestureEmulationScope.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ namespace WebCore {
3838

3939
class ChromeClient;
4040
class Page;
41+
class Document;
4142

4243
class UserGestureEmulationScope {
4344
WTF_MAKE_NONCOPYABLE(UserGestureEmulationScope);
4445
public:
45-
UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture);
46+
UserGestureEmulationScope(Page& inspectedPage, bool emulateUserGesture, Document* document);
4647
~UserGestureEmulationScope();
4748

4849
private:

0 commit comments

Comments
 (0)