Web Inspector: Debugger: support emulateUserGesture parameter in Debugger.evaluateOnC...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Aug 2019 05:19:27 +0000 (05:19 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Aug 2019 05:19:27 +0000 (05:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200272

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

When paused, evaluating in the console should still respect the "Emulate User Gesture" checkbox.

* inspector/protocol/Debugger.json:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):

Source/WebCore:

When paused, evaluating in the console should still respect the "Emulate User Gesture" checkbox.

Tests: inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html
       inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html

* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::evaluateOnCallFrame): Added.

Source/WebInspectorUI:

When paused, evaluating in the console should still respect the "Emulate User Gesture" checkbox.

* UserInterface/Controllers/RuntimeManager.js:
(WI.RuntimeManager.prototype.evaluateInInspectedWindow):

* UserInterface/Protocol/Legacy/13.0/InspectorBackendCommands.js:
* Versions/Inspector-iOS-13.0.json:

LayoutTests:

* inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html: Added.
* inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt: Added.
* inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html: Added.
* inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt: Added.
* TestExpectations:
* platform/wk2/TestExpectations:

* inspector/runtime/evaluate-emulateUserGesture.html: Added.
* inspector/runtime/evaluate-emulateUserGesture-expected.txt: Added.
* inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html: Added.
* inspector/runtime/evaluate-emulateUserGesture-userIsInteracting-expected.txt: Added.
* inspector/runtime/evaluate-userGestureEmulation.html: Deleted.
* inspector/runtime/evaluate-userGestureEmulation-expected.txt: Deleted.
* inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html: Deleted.
* inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt: Deleted.
Rename tests from "userGestureEmulation" to "emulateUserGesture" to match the parameter.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248097 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html [new file with mode: 0644]
LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html [new file with mode: 0644]
LayoutTests/inspector/runtime/evaluate-emulateUserGesture-expected.txt [moved from LayoutTests/inspector/runtime/evaluate-userGestureEmulation-expected.txt with 76% similarity]
LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting-expected.txt [moved from LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt with 75% similarity]
LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html [moved from LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html with 97% similarity]
LayoutTests/inspector/runtime/evaluate-emulateUserGesture.html [moved from LayoutTests/inspector/runtime/evaluate-userGestureEmulation.html with 98% similarity]
LayoutTests/platform/wk2/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
Source/JavaScriptCore/inspector/protocol/Debugger.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp
Source/WebCore/inspector/agents/page/PageDebuggerAgent.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js
Source/WebInspectorUI/UserInterface/Protocol/Legacy/13.0/InspectorBackendCommands.js
Source/WebInspectorUI/Versions/Inspector-iOS-13.0.json

index 9180a46..aab27b3 100644 (file)
@@ -1,3 +1,27 @@
+2019-07-31  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Debugger: support emulateUserGesture parameter in Debugger.evaluateOnCallFrame
+        https://bugs.webkit.org/show_bug.cgi?id=200272
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html: Added.
+        * inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt: Added.
+        * inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html: Added.
+        * inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt: Added.
+        * TestExpectations:
+        * platform/wk2/TestExpectations:
+
+        * inspector/runtime/evaluate-emulateUserGesture.html: Added.
+        * inspector/runtime/evaluate-emulateUserGesture-expected.txt: Added.
+        * inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html: Added.
+        * inspector/runtime/evaluate-emulateUserGesture-userIsInteracting-expected.txt: Added.
+        * inspector/runtime/evaluate-userGestureEmulation.html: Deleted.
+        * inspector/runtime/evaluate-userGestureEmulation-expected.txt: Deleted.
+        * inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html: Deleted.
+        * inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt: Deleted.
+        Rename tests from "userGestureEmulation" to "emulateUserGesture" to match the parameter.
+
 2019-07-31  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] twitch.tv video controls do not always respond to taps in fullscreen
index 156ee5a..d7faaf3 100644 (file)
@@ -744,7 +744,8 @@ webkit.org/b/134982 inspector/debugger/setBreakpoint-dfg-and-modify-local.html [
 webkit.org/b/161951 [ Debug ] inspector/debugger/paused-scopes.html [ Skip ]
 
 # User interaction is a WK2 concept.
-inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html [ Skip ]
+inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html [ Skip ]
+inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html [ Skip ]
 
 # These conformance tests are no longer in sync with the latest specification
 # and expect compareDocumentPosition() to return:
diff --git a/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt b/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt
new file mode 100644 (file)
index 0000000..7248d06
--- /dev/null
@@ -0,0 +1,13 @@
+Tests for Debugger.evaluateOnCallFrame emulateUserGesture option.
+
+
+== Running test suite: Debugger.evaluateOnCallFrame.emulateUserGesture
+-- Running test case: EvaluateWithoutEmulatingUserGesture
+Before debugger
+Not in User Gesture
+After debugger
+-- Running test case: EvaluateWithEmulatingUserGesture
+Before debugger
+In User Gesture
+After debugger
+
diff --git a/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt b/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt
new file mode 100644 (file)
index 0000000..5a7c6a1
--- /dev/null
@@ -0,0 +1,13 @@
+Tests for Debugger.evaluateOnCallFrame emulateUserGesture option.
+
+
+== Running test suite: Debugger.evaluateOnCallFrame.emulateUserGesture.userIsInteracting
+-- Running test case: EvaluateWithoutEmulatingUserGesture
+Before debugger
+User is NOT Interacting
+After debugger
+-- Running test case: EvaluateWithEmulatingUserGesture
+Before debugger
+User is Interacting
+After debugger
+
diff --git a/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html b/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html
new file mode 100644 (file)
index 0000000..d706ac7
--- /dev/null
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function triggerPause() {
+    TestPage.addResult("Before debugger");
+    debugger;
+    TestPage.addResult("After debugger");
+}
+
+function testProcessingUserGesture() {
+    if (window.internals)
+        TestPage.addResult(window.internals.userIsInteracting() ? "User is Interacting" : "User is NOT Interacting");
+}
+
+function test()
+{
+    const expression = `testProcessingUserGesture()`;
+    const objectGroup = "test";
+
+    let suite = InspectorTest.createAsyncSuite("Debugger.evaluateOnCallFrame.emulateUserGesture.userIsInteracting");
+
+    suite.addTestCase({
+        name: "EvaluateWithoutEmulatingUserGesture",
+        description: "Evalute with the emulateUserGesture option set to false.",
+        async test() {
+            InspectorTest.assert(!WI.debuggerManager.paused, "Should not be paused.");
+
+            let pausedPromise = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
+            InspectorTest.evaluateInPage("triggerPause()");
+            await pausedPromise;
+
+            InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Should have active call frame.");
+
+            DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, emulateUserGesture: false}, (error, resultValue, wasThrown) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+            });
+
+            await Promise.all([
+                WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed),
+                WI.debuggerManager.resume(),
+            ]);
+        }
+    });
+
+    suite.addTestCase({
+        name: "EvaluateWithEmulatingUserGesture",
+        description: "Evalute with the emulateUserGesture option set to true.",
+        async test() {
+            InspectorTest.assert(!WI.debuggerManager.paused, "Should not be paused.");
+
+            let pausedPromise = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
+            InspectorTest.evaluateInPage("triggerPause()");
+            await pausedPromise;
+
+            InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Should have active call frame.");
+
+            DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, emulateUserGesture: true}, (error, resultValue, wasThrown) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+            });
+
+            await Promise.all([
+                WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed),
+                WI.debuggerManager.resume(),
+            ]);
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for Debugger.evaluateOnCallFrame emulateUserGesture option.</p>
+</body>
+</html>
diff --git a/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html b/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html
new file mode 100644 (file)
index 0000000..83d0bde
--- /dev/null
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function triggerPause() {
+    TestPage.addResult("Before debugger");
+    debugger;
+    TestPage.addResult("After debugger");
+}
+
+function testProcessingUserGesture() {
+    if (window.internals)
+        TestPage.addResult(window.internals.isProcessingUserGesture() ? "In User Gesture" : "Not in User Gesture");
+}
+
+function test()
+{
+    const expression = `testProcessingUserGesture()`;
+    const objectGroup = "test";
+
+    let suite = InspectorTest.createAsyncSuite("Debugger.evaluateOnCallFrame.emulateUserGesture");
+
+    suite.addTestCase({
+        name: "EvaluateWithoutEmulatingUserGesture",
+        description: "Evalute with the emulateUserGesture option set to false.",
+        async test() {
+            InspectorTest.assert(!WI.debuggerManager.paused, "Should not be paused.");
+
+            let pausedPromise = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
+            InspectorTest.evaluateInPage("triggerPause()");
+            await pausedPromise;
+
+            InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Should have active call frame.");
+
+            DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, emulateUserGesture: false}, (error, resultValue, wasThrown) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+            });
+
+            await Promise.all([
+                WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed),
+                WI.debuggerManager.resume(),
+            ]);
+        }
+    });
+
+    suite.addTestCase({
+        name: "EvaluateWithEmulatingUserGesture",
+        description: "Evalute with the emulateUserGesture option set to true.",
+        async test() {
+            InspectorTest.assert(!WI.debuggerManager.paused, "Should not be paused.");
+
+            let pausedPromise = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
+            InspectorTest.evaluateInPage("triggerPause()");
+            await pausedPromise;
+
+            InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Should have active call frame.");
+
+            DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, emulateUserGesture: true}, (error, resultValue, wasThrown) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+            });
+
+            await Promise.all([
+                WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed),
+                WI.debuggerManager.resume(),
+            ]);
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for Debugger.evaluateOnCallFrame emulateUserGesture option.</p>
+</body>
+</html>
@@ -1,7 +1,7 @@
 Tests for Runtime emulateUserGesture option.
 
 
-== Running test suite: Runtime.evaluateUserGestureEmulation
+== Running test suite: Runtime.evaluate.emulateUserGesture
 -- Running test case: EvaluateWithoutEmulatingUserGesture
 Not in User Gesture
 -- Running test case: EvaluateWithEmulatingUserGesture
@@ -1,7 +1,7 @@
 Tests for Runtime emulateUserGesture option.
 
 
-== Running test suite: Runtime.evaluateUserGestureEmulation.userIsInteracting
+== Running test suite: Runtime.evaluate.emulateUserGesture.userIsInteracting
 -- Running test case: EvaluateWithoutEmulatingUserGesture.userIsInteracting
 User is NOT Interacting
 -- Running test case: EvaluateWithEmulatingUserGesture.userIsInteracting
@@ -17,7 +17,7 @@ function load() {
 
 function test()
 {
-    let suite = InspectorTest.createAsyncSuite("Runtime.evaluateUserGestureEmulation.userIsInteracting");
+    let suite = InspectorTest.createAsyncSuite("Runtime.evaluate.emulateUserGesture.userIsInteracting");
 
     suite.addTestCase({
         name: "EvaluateWithoutEmulatingUserGesture.userIsInteracting",
@@ -5,7 +5,7 @@
 <script>
 function test()
 {
-    let suite = InspectorTest.createAsyncSuite("Runtime.evaluateUserGestureEmulation");
+    let suite = InspectorTest.createAsyncSuite("Runtime.evaluate.emulateUserGesture");
 
     suite.addTestCase({
         name: "EvaluateWithoutEmulatingUserGesture",
index 13e6f03..768abc7 100644 (file)
@@ -499,7 +499,8 @@ http/tests/security/feed-urls-from-remote.html
 fast/preloader/document-write-2.html [ Pass Failure ]
 
 # User interaction is a WK2 concept.
-inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html [ Skip ]
+inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html [ Skip ]
+inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html [ Skip ]
 
 ### END OF (3) Unclassified failures
 ########################################
index 27bc829..4df32e4 100644 (file)
@@ -1,3 +1,17 @@
+2019-07-31  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Debugger: support emulateUserGesture parameter in Debugger.evaluateOnCallFrame
+        https://bugs.webkit.org/show_bug.cgi?id=200272
+
+        Reviewed by Joseph Pecoraro.
+
+        When paused, evaluating in the console should still respect the "Emulate User Gesture" checkbox.
+
+        * inspector/protocol/Debugger.json:
+        * inspector/agents/InspectorDebuggerAgent.h:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::evaluateOnCallFrame):
+
 2019-07-31  Alex Christensen  <achristensen@webkit.org>
 
         Split testb3 into multiple files
index 7e3dc65..e5f2482 100644 (file)
@@ -826,7 +826,7 @@ void InspectorDebuggerAgent::setPauseOnAssertions(ErrorString&, bool enabled)
     m_pauseOnAssertionFailures = enabled;
 }
 
-void InspectorDebuggerAgent::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, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex)
+void InspectorDebuggerAgent::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)
 {
     if (!m_currentCallStack) {
         errorString = "Not paused"_s;
index 1311c4f..042168b 100644 (file)
@@ -60,6 +60,7 @@ public:
     void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) final;
     void willDestroyFrontendAndBackend(DisconnectReason) final;
 
+    // DebuggerBackendDispatcherHandler
     void enable(ErrorString&) final;
     void disable(ErrorString&) final;
     void setPauseForInternalScripts(ErrorString&, bool shouldPause) final;
@@ -80,7 +81,7 @@ public:
     void stepOut(ErrorString&) final;
     void setPauseOnExceptions(ErrorString&, const String& pauseState) final;
     void setPauseOnAssertions(ErrorString&, bool enabled) final;
-    void evaluateOnCallFrame(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, RefPtr<Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex) final;
+    void evaluateOnCallFrame(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) override;
 
     bool isPaused() const;
     bool breakpointsActive() const;
index a5495ca..61b57cd 100644 (file)
                 { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state." },
                 { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." },
                 { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." },
-                { "name": "saveResult", "type": "boolean", "optional": true, "description": "Whether the resulting value should be considered for saving in the $n history." }
+                { "name": "saveResult", "type": "boolean", "optional": true, "description": "Whether the resulting value should be considered for saving in the $n history." },
+                { "name": "emulateUserGesture", "type": "boolean", "optional": true, "description": "Whether the expression should be considered to be in a user gesture or not." }
             ],
             "returns": [
                 { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." },
index 402a142..3fbbccc 100644 (file)
@@ -1,3 +1,19 @@
+2019-07-31  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Debugger: support emulateUserGesture parameter in Debugger.evaluateOnCallFrame
+        https://bugs.webkit.org/show_bug.cgi?id=200272
+
+        Reviewed by Joseph Pecoraro.
+
+        When paused, evaluating in the console should still respect the "Emulate User Gesture" checkbox.
+
+        Tests: inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html
+               inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html
+
+        * inspector/agents/page/PageDebuggerAgent.h:
+        * inspector/agents/page/PageDebuggerAgent.cpp:
+        (WebCore::PageDebuggerAgent::evaluateOnCallFrame): Added.
+
 2019-07-31  Saam Barati  <sbarati@apple.com>
 
         [WHLSL] Replace memsetZero function with inline "= { }" code
index 4f44322..b3885fb 100644 (file)
@@ -33,6 +33,8 @@
 #include "PageDebuggerAgent.h"
 
 #include "CachedResource.h"
+#include "Chrome.h"
+#include "ChromeClient.h"
 #include "Document.h"
 #include "EventListener.h"
 #include "EventTarget.h"
 #include "ScriptExecutionContext.h"
 #include "ScriptState.h"
 #include "Timer.h"
+#include "UserGestureIndicator.h"
 #include <JavaScriptCore/InjectedScript.h>
 #include <JavaScriptCore/InjectedScriptManager.h>
 #include <JavaScriptCore/ScriptCallStack.h>
 #include <JavaScriptCore/ScriptCallStackFactory.h>
 #include <wtf/NeverDestroyed.h>
-
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -62,6 +65,28 @@ PageDebuggerAgent::PageDebuggerAgent(PageAgentContext& context)
 {
 }
 
+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)
+{
+    auto& pageChromeClient = m_inspectedPage.chrome().client();
+
+    auto shouldEmulateUserGesture = emulateUserGesture && *emulateUserGesture;
+
+    Optional<ProcessingUserGestureState> userGestureState = shouldEmulateUserGesture ? Optional<ProcessingUserGestureState>(ProcessingUserGesture) : WTF::nullopt;
+    UserGestureIndicator gestureIndicator(userGestureState);
+
+    bool userWasInteracting = false;
+    if (shouldEmulateUserGesture) {
+        userWasInteracting = pageChromeClient.userIsInteracting();
+        if (!userWasInteracting)
+            pageChromeClient.setUserIsInteracting(true);
+    }
+
+    WebDebuggerAgent::evaluateOnCallFrame(errorString, callFrameId, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult, emulateUserGesture, result, wasThrown, savedResultIndex);
+
+    if (shouldEmulateUserGesture && !userWasInteracting && pageChromeClient.userIsInteracting())
+        pageChromeClient.setUserIsInteracting(false);
+}
+
 void PageDebuggerAgent::enable()
 {
     WebDebuggerAgent::enable();
index 085de07..db5d4cd 100644 (file)
@@ -49,20 +49,20 @@ public:
     PageDebuggerAgent(PageAgentContext&);
     virtual ~PageDebuggerAgent() = default;
 
-    void didClearMainFrameWindowObject();
+    // DebuggerBackendDispatcherHandler
+    void evaluateOnCallFrame(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<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex) final;
 
+    // InspectorInstrumentation
+    void didClearMainFrameWindowObject();
     void mainFrameStartedLoading();
     void mainFrameStoppedLoading();
     void mainFrameNavigated();
-
     void didRequestAnimationFrame(int callbackId, Document&);
     void willFireAnimationFrame(int callbackId);
     void didCancelAnimationFrame(int callbackId);
-
     void didAddEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
     void willRemoveEventListener(EventTarget&, const AtomString& eventType, EventListener&, bool capture);
     void willHandleEvent(const RegisteredEventListener&);
-
     void didPostMessage(const TimerBase&, JSC::ExecState&);
     void didFailPostMessage(const TimerBase&);
     void willDispatchPostMessage(const TimerBase&);
index 5cce5a8..a44d998 100644 (file)
@@ -1,5 +1,20 @@
 2019-07-31  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Debugger: support emulateUserGesture parameter in Debugger.evaluateOnCallFrame
+        https://bugs.webkit.org/show_bug.cgi?id=200272
+
+        Reviewed by Joseph Pecoraro.
+
+        When paused, evaluating in the console should still respect the "Emulate User Gesture" checkbox.
+
+        * UserInterface/Controllers/RuntimeManager.js:
+        (WI.RuntimeManager.prototype.evaluateInInspectedWindow):
+
+        * UserInterface/Protocol/Legacy/13.0/InspectorBackendCommands.js:
+        * Versions/Inspector-iOS-13.0.json:
+
+2019-07-31  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Uncaught Exception: TypeError: null is not an object (evaluating 'issueMessage.sourceCodeLocation.sourceCode')
         https://bugs.webkit.org/show_bug.cgi?id=200296
 
index be5f3de..1c51d77 100644 (file)
@@ -133,7 +133,8 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object
 
         if (WI.debuggerManager.activeCallFrame) {
             // COMPATIBILITY (iOS 8): "saveResult" did not exist.
-            target.DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult}, evalCallback.bind(this), target.DebuggerAgent);
+            // COMPATIBILITY (iOS 13): "emulateUserGesture" did not exist.
+            target.DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, saveResult, emulateUserGesture}, evalCallback.bind(this), target.DebuggerAgent);
             return;
         }
 
index 92f6efb..20e6799 100644 (file)
@@ -268,7 +268,7 @@ InspectorBackend.registerCommand("Debugger.getFunctionDetails", [{"name": "funct
 InspectorBackend.registerCommand("Debugger.setPauseOnExceptions", [{"name": "state", "type": "string", "optional": false}], []);
 InspectorBackend.registerCommand("Debugger.setPauseOnAssertions", [{"name": "enabled", "type": "boolean", "optional": false}], []);
 InspectorBackend.registerCommand("Debugger.setPauseForInternalScripts", [{"name": "shouldPause", "type": "boolean", "optional": false}], []);
-InspectorBackend.registerCommand("Debugger.evaluateOnCallFrame", [{"name": "callFrameId", "type": "string", "optional": false}, {"name": "expression", "type": "string", "optional": false}, {"name": "objectGroup", "type": "string", "optional": true}, {"name": "includeCommandLineAPI", "type": "boolean", "optional": true}, {"name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true}, {"name": "returnByValue", "type": "boolean", "optional": true}, {"name": "generatePreview", "type": "boolean", "optional": true}, {"name": "saveResult", "type": "boolean", "optional": true}], ["result", "wasThrown", "savedResultIndex"]);
+InspectorBackend.registerCommand("Debugger.evaluateOnCallFrame", [{"name": "callFrameId", "type": "string", "optional": false}, {"name": "expression", "type": "string", "optional": false}, {"name": "objectGroup", "type": "string", "optional": true}, {"name": "includeCommandLineAPI", "type": "boolean", "optional": true}, {"name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true}, {"name": "returnByValue", "type": "boolean", "optional": true}, {"name": "generatePreview", "type": "boolean", "optional": true}, {"name": "saveResult", "type": "boolean", "optional": true}, {"name": "emulateUserGesture", "type": "boolean", "optional": true}], ["result", "wasThrown", "savedResultIndex"]);
 InspectorBackend.activateDomain("Debugger");
 
 // Heap.
index d337934..5e2dfa6 100644 (file)
                 { "name": "doNotPauseOnExceptionsAndMuteConsole", "type": "boolean", "optional": true, "description": "Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state." },
                 { "name": "returnByValue", "type": "boolean", "optional": true, "description": "Whether the result is expected to be a JSON object that should be sent by value." },
                 { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for the result." },
-                { "name": "saveResult", "type": "boolean", "optional": true, "description": "Whether the resulting value should be considered for saving in the $n history." }
+                { "name": "saveResult", "type": "boolean", "optional": true, "description": "Whether the resulting value should be considered for saving in the $n history." },
+                { "name": "emulateUserGesture", "type": "boolean", "optional": true, "description": "Whether the expression should be considered to be in a user gesture or not." }
             ],
             "returns": [
                 { "name": "result", "$ref": "Runtime.RemoteObject", "description": "Object wrapper for the evaluation result." },