Title: [248097] trunk
Revision
248097
Author
[email protected]
Date
2019-07-31 22:19:27 -0700 (Wed, 31 Jul 2019)

Log Message

Web Inspector: Debugger: support emulateUserGesture parameter in Debugger.evaluateOnCallFrame
https://bugs.webkit.org/show_bug.cgi?id=200272

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

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.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (248096 => 248097)


--- trunk/LayoutTests/ChangeLog	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/ChangeLog	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,3 +1,27 @@
+2019-07-31  Devin Rousso  <[email protected]>
+
+        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  <[email protected]>
 
         [ContentChangeObserver] twitch.tv video controls do not always respond to taps in fullscreen

Modified: trunk/LayoutTests/TestExpectations (248096 => 248097)


--- trunk/LayoutTests/TestExpectations	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/TestExpectations	2019-08-01 05:19:27 UTC (rev 248097)
@@ -744,7 +744,8 @@
 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:

Added: trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt (0 => 248097)


--- trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-expected.txt	2019-08-01 05:19:27 UTC (rev 248097)
@@ -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
+

Added: trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt (0 => 248097)


--- trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting-expected.txt	2019-08-01 05:19:27 UTC (rev 248097)
@@ -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
+

Added: trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html (0 => 248097)


--- trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture-userIsInteracting.html	2019-08-01 05:19:27 UTC (rev 248097)
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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>

Added: trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html (0 => 248097)


--- trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/evaluateOnCallFrame-emulateUserGesture.html	2019-08-01 05:19:27 UTC (rev 248097)
@@ -0,0 +1,77 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<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>

Copied: trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-expected.txt (from rev 248096, trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-expected.txt) (0 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-expected.txt	2019-08-01 05:19:27 UTC (rev 248097)
@@ -0,0 +1,9 @@
+Tests for Runtime emulateUserGesture option.
+
+
+== Running test suite: Runtime.evaluate.emulateUserGesture
+-- Running test case: EvaluateWithoutEmulatingUserGesture
+Not in User Gesture
+-- Running test case: EvaluateWithEmulatingUserGesture
+In User Gesture
+

Copied: trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting-expected.txt (from rev 248096, trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt) (0 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting-expected.txt	2019-08-01 05:19:27 UTC (rev 248097)
@@ -0,0 +1,9 @@
+Tests for Runtime emulateUserGesture option.
+
+
+== Running test suite: Runtime.evaluate.emulateUserGesture.userIsInteracting
+-- Running test case: EvaluateWithoutEmulatingUserGesture.userIsInteracting
+User is NOT Interacting
+-- Running test case: EvaluateWithEmulatingUserGesture.userIsInteracting
+User is Interacting
+

Copied: trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html (from rev 248096, trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html) (0 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture-userIsInteracting.html	2019-08-01 05:19:27 UTC (rev 248097)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+
+function load() {
+    document.getElementById("test").addEventListener("click", (event) => {
+        if (!window.internals)
+            return;
+
+        TestPage.addResult(window.internals.userIsInteracting() ? "User is Interacting" : "User is NOT Interacting");
+    });
+
+    runTest();
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Runtime.evaluate.emulateUserGesture.userIsInteracting");
+
+    suite.addTestCase({
+        name: "EvaluateWithoutEmulatingUserGesture.userIsInteracting",
+        description: "Check that the evaluation is not considered a user interaction when emulateUserGesture is false.",
+        async test() {
+            await RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("test").click()`, emulateUserGesture: false});
+        },
+    });
+
+    suite.addTestCase({
+        name: "EvaluateWithEmulatingUserGesture.userIsInteracting",
+        description: "Check that the evaluation is considered a user interaction when emulateUserGesture is true.",
+        async test() {
+            await RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("test").click()`, emulateUserGesture: true});
+        },
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="load()">
+    <p>Tests for Runtime emulateUserGesture option.</p>
+    <a id="test"></a>
+</body>
+</html>

Copied: trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture.html (from rev 248096, trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation.html) (0 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/runtime/evaluate-emulateUserGesture.html	2019-08-01 05:19:27 UTC (rev 248097)
@@ -0,0 +1,48 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Runtime.evaluate.emulateUserGesture");
+
+    suite.addTestCase({
+        name: "EvaluateWithoutEmulatingUserGesture",
+        description: "Evalute with the emulateUserGesture option set to false.",
+        async test() {
+            RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("foo").click()`, objectGroup: "test", emulateUserGesture: false}, (error) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: "EvaluateWithEmulatingUserGesture",
+        description: "Evalute with the emulateUserGesture option set to true.",
+        async test() {
+            RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("foo").click()`, objectGroup: "test", emulateUserGesture: true}, (error) => {
+                InspectorTest.assert(!error, "Should not be a protocol error.");
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+
+function handleClick(event) {
+    if (window.internals)
+        TestPage.addResult(window.internals.isProcessingUserGesture() ? "In User Gesture" : "Not in User Gesture");
+}
+
+window.addEventListener("load", function () {
+    document.getElementById("foo").addEventListener("click", handleClick);
+    runTest();
+}, false);
+</script>
+</head>
+<body>
+<a id="foo"></a>
+<p>Tests for Runtime emulateUserGesture option.</p>
+</body>
+</html>

Deleted: trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-expected.txt (248096 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-expected.txt	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-expected.txt	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,9 +0,0 @@
-Tests for Runtime emulateUserGesture option.
-
-
-== Running test suite: Runtime.evaluateUserGestureEmulation
--- Running test case: EvaluateWithoutEmulatingUserGesture
-Not in User Gesture
--- Running test case: EvaluateWithEmulatingUserGesture
-In User Gesture
-

Deleted: trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt (248096 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting-expected.txt	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,9 +0,0 @@
-Tests for Runtime emulateUserGesture option.
-
-
-== Running test suite: Runtime.evaluateUserGestureEmulation.userIsInteracting
--- Running test case: EvaluateWithoutEmulatingUserGesture.userIsInteracting
-User is NOT Interacting
--- Running test case: EvaluateWithEmulatingUserGesture.userIsInteracting
-User is Interacting
-

Deleted: trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html (248096 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation-userIsInteracting.html	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<script src=""
-<script>
-
-function load() {
-    document.getElementById("test").addEventListener("click", (event) => {
-        if (!window.internals)
-            return;
-
-        TestPage.addResult(window.internals.userIsInteracting() ? "User is Interacting" : "User is NOT Interacting");
-    });
-
-    runTest();
-}
-
-function test()
-{
-    let suite = InspectorTest.createAsyncSuite("Runtime.evaluateUserGestureEmulation.userIsInteracting");
-
-    suite.addTestCase({
-        name: "EvaluateWithoutEmulatingUserGesture.userIsInteracting",
-        description: "Check that the evaluation is not considered a user interaction when emulateUserGesture is false.",
-        async test() {
-            await RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("test").click()`, emulateUserGesture: false});
-        },
-    });
-
-    suite.addTestCase({
-        name: "EvaluateWithEmulatingUserGesture.userIsInteracting",
-        description: "Check that the evaluation is considered a user interaction when emulateUserGesture is true.",
-        async test() {
-            await RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("test").click()`, emulateUserGesture: true});
-        },
-    });
-
-    suite.runTestCasesAndFinish();
-}
-</script>
-</head>
-<body _onload_="load()">
-    <p>Tests for Runtime emulateUserGesture option.</p>
-    <a id="test"></a>
-</body>
-</html>

Deleted: trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation.html (248096 => 248097)


--- trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation.html	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/inspector/runtime/evaluate-userGestureEmulation.html	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,48 +0,0 @@
-<!doctype html>
-<html>
-<head>
-<script src=""
-<script>
-function test()
-{
-    let suite = InspectorTest.createAsyncSuite("Runtime.evaluateUserGestureEmulation");
-
-    suite.addTestCase({
-        name: "EvaluateWithoutEmulatingUserGesture",
-        description: "Evalute with the emulateUserGesture option set to false.",
-        async test() {
-            RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("foo").click()`, objectGroup: "test", emulateUserGesture: false}, (error) => {
-                InspectorTest.assert(!error, "Should not be a protocol error.");
-            });
-        }
-    });
-
-    suite.addTestCase({
-        name: "EvaluateWithEmulatingUserGesture",
-        description: "Evalute with the emulateUserGesture option set to true.",
-        async test() {
-            RuntimeAgent.evaluate.invoke({_expression_: `document.getElementById("foo").click()`, objectGroup: "test", emulateUserGesture: true}, (error) => {
-                InspectorTest.assert(!error, "Should not be a protocol error.");
-            });
-        }
-    });
-
-    suite.runTestCasesAndFinish();
-}
-
-function handleClick(event) {
-    if (window.internals)
-        TestPage.addResult(window.internals.isProcessingUserGesture() ? "In User Gesture" : "Not in User Gesture");
-}
-
-window.addEventListener("load", function () {
-    document.getElementById("foo").addEventListener("click", handleClick);
-    runTest();
-}, false);
-</script>
-</head>
-<body>
-<a id="foo"></a>
-<p>Tests for Runtime emulateUserGesture option.</p>
-</body>
-</html>

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (248096 => 248097)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2019-08-01 05:19:27 UTC (rev 248097)
@@ -499,7 +499,8 @@
 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
 ########################################

Modified: trunk/Source/_javascript_Core/ChangeLog (248096 => 248097)


--- trunk/Source/_javascript_Core/ChangeLog	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,3 +1,17 @@
+2019-07-31  Devin Rousso  <[email protected]>
+
+        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  <[email protected]>
 
         Split testb3 into multiple files

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (248096 => 248097)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2019-08-01 05:19:27 UTC (rev 248097)
@@ -826,7 +826,7 @@
     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;

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h (248096 => 248097)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.h	2019-08-01 05:19:27 UTC (rev 248097)
@@ -60,6 +60,7 @@
     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 @@
     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;

Modified: trunk/Source/_javascript_Core/inspector/protocol/Debugger.json (248096 => 248097)


--- trunk/Source/_javascript_Core/inspector/protocol/Debugger.json	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/_javascript_Core/inspector/protocol/Debugger.json	2019-08-01 05:19:27 UTC (rev 248097)
@@ -279,7 +279,8 @@
                 { "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." },

Modified: trunk/Source/WebCore/ChangeLog (248096 => 248097)


--- trunk/Source/WebCore/ChangeLog	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebCore/ChangeLog	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,3 +1,19 @@
+2019-07-31  Devin Rousso  <[email protected]>
+
+        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  <[email protected]>
 
         [WHLSL] Replace memsetZero function with inline "= { }" code

Modified: trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp (248096 => 248097)


--- trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.cpp	2019-08-01 05:19:27 UTC (rev 248097)
@@ -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"
@@ -45,13 +47,14 @@
 #include "ScriptExecutionContext.h"
 #include "ScriptState.h"
 #include "Timer.h"
+#include "UserGestureIndicator.h"
 #include <_javascript_Core/InjectedScript.h>
 #include <_javascript_Core/InjectedScriptManager.h>
 #include <_javascript_Core/ScriptCallStack.h>
 #include <_javascript_Core/ScriptCallStackFactory.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/Optional.h>
 
-
 namespace WebCore {
 
 using namespace Inspector;
@@ -62,6 +65,28 @@
 {
 }
 
+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();

Modified: trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h (248096 => 248097)


--- trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebCore/inspector/agents/page/PageDebuggerAgent.h	2019-08-01 05:19:27 UTC (rev 248097)
@@ -49,20 +49,20 @@
     PageDebuggerAgent(PageAgentContext&);
     virtual ~PageDebuggerAgent() = default;
 
+    // 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&);

Modified: trunk/Source/WebInspectorUI/ChangeLog (248096 => 248097)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-08-01 05:19:27 UTC (rev 248097)
@@ -1,5 +1,20 @@
 2019-07-31  Devin Rousso  <[email protected]>
 
+        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  <[email protected]>
+
         Web Inspector: Uncaught Exception: TypeError: null is not an object (evaluating 'issueMessage.sourceCodeLocation.sourceCode')
         https://bugs.webkit.org/show_bug.cgi?id=200296
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js (248096 => 248097)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js	2019-08-01 05:19:27 UTC (rev 248097)
@@ -133,7 +133,8 @@
 
         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;
         }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/13.0/InspectorBackendCommands.js (248096 => 248097)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/13.0/InspectorBackendCommands.js	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/Legacy/13.0/InspectorBackendCommands.js	2019-08-01 05:19:27 UTC (rev 248097)
@@ -268,7 +268,7 @@
 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", &quo
 t;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.

Modified: trunk/Source/WebInspectorUI/Versions/Inspector-iOS-13.0.json (248096 => 248097)


--- trunk/Source/WebInspectorUI/Versions/Inspector-iOS-13.0.json	2019-08-01 05:17:42 UTC (rev 248096)
+++ trunk/Source/WebInspectorUI/Versions/Inspector-iOS-13.0.json	2019-08-01 05:19:27 UTC (rev 248097)
@@ -2154,7 +2154,8 @@
                 { "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." },
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to