@@ -205,13 +205,21 @@ void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::JSGlobal
205
205
206
206
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)
207
207
{
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);
209
214
InspectorRuntimeAgent::evaluate (errorString, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, executionContextId, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
210
215
}
211
216
212
217
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)
213
218
{
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);
215
223
InspectorRuntimeAgent::callFunctionOn (errorString, objectId, expression, optionalArguments, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, emulateUserGesture, result, wasThrown);
216
224
}
217
225
0 commit comments