[go: up one dir, main page]

Propagate from_devtools_debugger in gestures.

(cherry picked from commit 39baf6a25f3035f2de59af22a554493516a086d5)

Bug: 1117173
Change-Id: I1f093a97aec0bb898afca66d27404af79670f1ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3259636
Commit-Queue: Danil Somsikov <dsv@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Keren Zhu <kerenzhu@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#940000}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3329863
Cr-Commit-Position: refs/branch-heads/4664@{#1301}
Cr-Branched-From: 24dc4ee75e01a29d390d43c9c264372a169273a7-refs/heads/main@{#929512}
diff --git a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
index e949c9c..e884b699 100644
--- a/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
+++ b/content/browser/renderer_host/input/synthetic_gesture_controller_unittest.cc
@@ -159,7 +159,11 @@
   ~MockSyntheticGestureTarget() override {}
 
   // SyntheticGestureTarget:
-  void DispatchInputEventToPlatform(const WebInputEvent& event) override {}
+  void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    if (!(event.GetModifiers() & blink::WebInputEvent::kFromDebugger)) {
+      all_from_debugger_ = false;
+    }
+  }
 
   content::mojom::GestureSourceType GetDefaultSyntheticGestureSourceType()
       const override {
@@ -196,10 +200,13 @@
     std::move(callback).Run();
   }
 
+  bool all_from_debugger() { return all_from_debugger_; }
+
  private:
   bool flush_requested_;
 
   int pointer_assumed_stopped_time_ms_;
+  bool all_from_debugger_ = true;
 };
 
 class MockMoveGestureTarget : public MockSyntheticGestureTarget {
@@ -230,6 +237,7 @@
   ~MockScrollMouseTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_EQ(event.GetType(), WebInputEvent::Type::kMouseWheel);
     const WebMouseWheelEvent& mouse_wheel_event =
         static_cast<const WebMouseWheelEvent&>(event);
@@ -246,6 +254,7 @@
   ~MockMoveTouchTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_TRUE(WebInputEvent::IsTouchEventType(event.GetType()));
     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
     ASSERT_EQ(touch_event.touches_length, 1U);
@@ -282,6 +291,7 @@
   ~MockFlingGestureTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     if (event.GetType() == WebInputEvent::Type::kGestureFlingStart) {
       const blink::WebGestureEvent& gesture_event =
           static_cast<const blink::WebGestureEvent&>(event);
@@ -304,6 +314,7 @@
   ~MockDragMouseTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_TRUE(WebInputEvent::IsMouseEventType(event.GetType()));
     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
     if (!started_) {
@@ -348,6 +359,7 @@
   ~MockSyntheticTouchscreenPinchTouchTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_TRUE(WebInputEvent::IsTouchEventType(event.GetType()));
     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
     ASSERT_EQ(touch_event.touches_length, 2U);
@@ -439,6 +451,7 @@
   ~MockSyntheticTouchpadPinchTouchTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     EXPECT_TRUE(WebInputEvent::IsGestureEventType(event.GetType()));
     const blink::WebGestureEvent& gesture_event =
         static_cast<const blink::WebGestureEvent&>(event);
@@ -517,6 +530,7 @@
   ~MockSyntheticTapTouchTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_TRUE(WebInputEvent::IsTouchEventType(event.GetType()));
     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
     ASSERT_EQ(touch_event.touches_length, 1U);
@@ -548,6 +562,7 @@
   ~MockSyntheticTapMouseTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_TRUE(WebInputEvent::IsMouseEventType(event.GetType()));
     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
 
@@ -600,6 +615,7 @@
   ~MockSyntheticPointerTouchActionTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     DCHECK(WebInputEvent::IsTouchEventType(event.GetType()));
     const WebTouchEvent& touch_event = static_cast<const WebTouchEvent&>(event);
     type_ = touch_event.GetType();
@@ -674,6 +690,7 @@
   ~MockSyntheticPointerMouseActionTarget() override {}
 
   void DispatchInputEventToPlatform(const WebInputEvent& event) override {
+    MockSyntheticGestureTarget::DispatchInputEventToPlatform(event);
     ASSERT_TRUE(WebInputEvent::IsMouseEventType(event.GetType()));
     const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
     type_ = mouse_event.GetType();
@@ -1146,6 +1163,29 @@
   EXPECT_EQ(gfx::Vector2dF(0, 0), scroll_target->start_to_end_distance());
 }
 
+TEST_P(SyntheticGestureControllerTestWithParam,
+       SingleScrollGestureTouchFromDebugger) {
+  CreateControllerAndTarget<MockMoveTouchTarget>();
+
+  SyntheticSmoothMoveGestureParams params;
+  params.from_devtools_debugger = true;
+  params.input_type = SyntheticSmoothMoveGestureParams::TOUCH_INPUT;
+  if (GetParam() == TOUCH_DRAG) {
+    params.add_slop = false;
+  }
+  params.start_point.SetPoint(89, 32);
+  params.distances.push_back(gfx::Vector2d(0, 123));
+
+  std::unique_ptr<SyntheticSmoothMoveGesture> gesture(
+      new SyntheticSmoothMoveGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
 TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseVertical) {
   CreateControllerAndTarget<MockScrollMouseTarget>();
 
@@ -1320,6 +1360,25 @@
   EXPECT_EQ(params.granularity, scroll_target->granularity());
 }
 
+TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseFromDebugger) {
+  CreateControllerAndTarget<MockScrollMouseTarget>();
+
+  SyntheticSmoothMoveGestureParams params;
+  params.from_devtools_debugger = true;
+  params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
+  params.start_point.SetPoint(432, 89);
+  params.distances.push_back(gfx::Vector2d(0, -234));
+
+  std::unique_ptr<SyntheticSmoothMoveGesture> gesture(
+      new SyntheticSmoothMoveGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
 void CheckIsWithinRangeMulti(float scroll_distance,
                              int target_distance,
                              SyntheticGestureTarget* target) {
@@ -1484,6 +1543,23 @@
 }
 
 TEST_F(SyntheticGestureControllerTest,
+       SyntheticSmoothDragTestUsingSingleMouseDragFromDebugger) {
+  CreateControllerAndTarget<MockDragMouseTarget>();
+
+  SyntheticSmoothDragGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kMouseInput;
+  params.distances.push_back(gfx::Vector2d(234, 133));
+  params.speed_in_pixels_s = 800;
+
+  std::unique_ptr<SyntheticSmoothDragGesture> gesture(
+      new SyntheticSmoothDragGesture(params));
+  const base::TimeTicks timestamp;
+  gesture->ForwardInputEvents(timestamp, target_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
+TEST_F(SyntheticGestureControllerTest,
        SyntheticSmoothDragTestUsingSingleTouchDrag) {
   CreateControllerAndTarget<MockMoveTouchTarget>();
 
@@ -1500,6 +1576,24 @@
 }
 
 TEST_F(SyntheticGestureControllerTest,
+       SyntheticSmoothDragTestUsingSingleTouchDragFromDebugger) {
+  CreateControllerAndTarget<MockMoveTouchTarget>();
+
+  SyntheticSmoothDragGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kTouchInput;
+  params.start_point.SetPoint(89, 32);
+  params.distances.push_back(gfx::Vector2d(0, 123));
+  params.speed_in_pixels_s = 800;
+
+  std::unique_ptr<SyntheticSmoothDragGesture> gesture(
+      new SyntheticSmoothDragGesture(params));
+  const base::TimeTicks timestamp;
+  gesture->ForwardInputEvents(timestamp, target_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
+TEST_F(SyntheticGestureControllerTest,
        SyntheticSmoothScrollTestUsingSingleTouchScroll) {
   CreateControllerAndTarget<MockMoveTouchTarget>();
 
@@ -1513,6 +1607,26 @@
 }
 
 TEST_F(SyntheticGestureControllerTest,
+       SyntheticSmoothScrollTestUsingSingleTouchScrollFromDebugger) {
+  CreateControllerAndTarget<MockMoveTouchTarget>();
+
+  SyntheticSmoothScrollGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kTouchInput;
+  params.anchor.SetPoint(432, 89);
+  params.distances.push_back(gfx::Vector2d(0, -234));
+  params.speed_in_pixels_s = 800;
+
+  std::unique_ptr<SyntheticSmoothScrollGesture> gesture(
+      new SyntheticSmoothScrollGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
+TEST_F(SyntheticGestureControllerTest,
        SyntheticSmoothScrollTestUsingSingleMouseScroll) {
   CreateControllerAndTarget<MockScrollMouseTarget>();
 
@@ -1529,6 +1643,26 @@
 }
 
 TEST_F(SyntheticGestureControllerTest,
+       SyntheticSmoothScrollTestUsingSingleMouseScrollFromDebugger) {
+  CreateControllerAndTarget<MockScrollMouseTarget>();
+
+  SyntheticSmoothScrollGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kMouseInput;
+  params.anchor.SetPoint(432, 89);
+  params.distances.push_back(gfx::Vector2d(0, -234));
+  params.speed_in_pixels_s = 800;
+
+  std::unique_ptr<SyntheticSmoothScrollGesture> gesture(
+      new SyntheticSmoothScrollGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
+TEST_F(SyntheticGestureControllerTest,
        TouchscreenTouchpadPinchGestureTouchZoomIn) {
   CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
 
@@ -1596,6 +1730,26 @@
   EXPECT_EQ(params.scale_factor, pinch_target->ComputeScaleFactor());
 }
 
+TEST_F(SyntheticGestureControllerTest,
+       TouchscreenTouchpadPinchGestureTouchFromDebugger) {
+  CreateControllerAndTarget<MockSyntheticTouchscreenPinchTouchTarget>();
+
+  SyntheticPinchGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kTouchInput;
+  params.scale_factor = 2.3f;
+  params.anchor.SetPoint(54, 89);
+
+  std::unique_ptr<SyntheticTouchscreenPinchGesture> gesture(
+      new SyntheticTouchscreenPinchGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
 TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomIn) {
   CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
 
@@ -1661,6 +1815,25 @@
   EXPECT_EQ(params.scale_factor, pinch_target->scale_factor());
 }
 
+TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchFromDebugger) {
+  CreateControllerAndTarget<MockSyntheticTouchpadPinchTouchTarget>();
+
+  SyntheticPinchGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kMouseInput;
+  params.scale_factor = 2.3f;
+  params.anchor.SetPoint(54, 89);
+
+  std::unique_ptr<SyntheticTouchpadPinchGesture> gesture(
+      new SyntheticTouchpadPinchGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
 // Ensure that if SyntheticPinchGesture is instantiated with TOUCH_INPUT it
 // correctly creates a touchscreen gesture.
 TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitTouch) {
@@ -1759,6 +1932,24 @@
   EXPECT_GE(GetTotalTime(), base::Milliseconds(params.duration_ms));
 }
 
+TEST_F(SyntheticGestureControllerTest, TapGestureTouchFromDebugger) {
+  CreateControllerAndTarget<MockSyntheticTapTouchTarget>();
+
+  SyntheticTapGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kTouchInput;
+  params.duration_ms = 123;
+  params.position.SetPoint(87, -124);
+
+  std::unique_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
 TEST_F(SyntheticGestureControllerTest, TapGestureMouse) {
   CreateControllerAndTarget<MockSyntheticTapMouseTarget>();
 
@@ -1781,6 +1972,24 @@
   EXPECT_GE(GetTotalTime(), base::Milliseconds(params.duration_ms));
 }
 
+TEST_F(SyntheticGestureControllerTest, TapGestureMouseFromDebugger) {
+  CreateControllerAndTarget<MockSyntheticTapMouseTarget>();
+
+  SyntheticTapGestureParams params;
+  params.from_devtools_debugger = true;
+  params.gesture_source_type = content::mojom::GestureSourceType::kMouseInput;
+  params.duration_ms = 79;
+  params.position.SetPoint(98, 123);
+
+  std::unique_ptr<SyntheticTapGesture> gesture(new SyntheticTapGesture(params));
+  QueueSyntheticGesture(std::move(gesture));
+  FlushInputUntilComplete();
+
+  EXPECT_EQ(1, num_success_);
+  EXPECT_EQ(0, num_failure_);
+  EXPECT_TRUE(target_->all_from_debugger());
+}
+
 TEST_F(SyntheticGestureControllerTest, PointerTouchAction) {
   CreateControllerAndTarget<MockSyntheticPointerTouchActionTarget>();
 
diff --git a/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.cc b/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.cc
index 1841b77e..8d4b289 100644
--- a/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_smooth_drag_gesture.cc
@@ -57,6 +57,7 @@
     move_params.prevent_fling = true;
     move_params.input_type = GetInputSourceType(gesture_type);
     move_params.add_slop = false;
+    move_params.from_devtools_debugger = params_.from_devtools_debugger;
     move_gesture_ = std::make_unique<SyntheticSmoothMoveGesture>(move_params);
     return true;
   }
diff --git a/content/browser/renderer_host/input/synthetic_smooth_move_gesture.cc b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.cc
index 86985b0..64faf5d 100644
--- a/content/browser/renderer_host/input/synthetic_smooth_move_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.cc
@@ -67,13 +67,15 @@
     case SyntheticSmoothMoveGestureParams::TOUCH_INPUT:
       if (!synthetic_pointer_driver_)
         synthetic_pointer_driver_ = SyntheticPointerDriver::Create(
-            content::mojom::GestureSourceType::kTouchInput);
+            content::mojom::GestureSourceType::kTouchInput,
+            params_.from_devtools_debugger);
       ForwardTouchInputEvents(timestamp, target);
       break;
     case SyntheticSmoothMoveGestureParams::MOUSE_DRAG_INPUT:
       if (!synthetic_pointer_driver_)
         synthetic_pointer_driver_ = SyntheticPointerDriver::Create(
-            content::mojom::GestureSourceType::kMouseInput);
+            content::mojom::GestureSourceType::kMouseInput,
+            params_.from_devtools_debugger);
       ForwardMouseClickInputEvents(timestamp, target);
       break;
     case SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT:
@@ -258,6 +260,9 @@
     const blink::WebMouseWheelEvent::Phase phase,
     const base::TimeTicks& timestamp,
     int modifiers) const {
+  if (params_.from_devtools_debugger) {
+    modifiers |= blink::WebInputEvent::kFromDebugger;
+  }
   blink::WebMouseWheelEvent mouse_wheel_event =
       blink::SyntheticWebMouseWheelEventBuilder::Build(
           0, 0, delta.x(), delta.y(), modifiers, params_.granularity);
diff --git a/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
index f85e5e7..c7e0278 100644
--- a/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
+++ b/content/browser/renderer_host/input/synthetic_smooth_move_gesture.h
@@ -43,6 +43,7 @@
   ui::ScrollGranularity granularity = ui::ScrollGranularity::kScrollByPixel;
   // A bitfield of values from blink::WebInputEvent::Modifiers.
   int modifiers = 0;
+  bool from_devtools_debugger = false;
 };
 
 // This class is used as helper class for simulation of scroll and drag.
diff --git a/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.cc b/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.cc
index be0099a..79a0580 100644
--- a/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.cc
@@ -58,6 +58,7 @@
     move_params.add_slop = true;
     move_params.granularity = params_.granularity;
     move_params.modifiers = params_.modifiers;
+    move_params.from_devtools_debugger = params_.from_devtools_debugger;
     move_gesture_ = std::make_unique<SyntheticSmoothMoveGesture>(move_params);
     return true;
   }
diff --git a/content/browser/renderer_host/input/synthetic_tap_gesture.cc b/content/browser/renderer_host/input/synthetic_tap_gesture.cc
index 1cd58ac..399f017 100644
--- a/content/browser/renderer_host/input/synthetic_tap_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_tap_gesture.cc
@@ -40,8 +40,8 @@
             content::mojom::GestureSourceType::kDefaultInput);
 
   if (!synthetic_pointer_driver_)
-    synthetic_pointer_driver_ =
-        SyntheticPointerDriver::Create(gesture_source_type_);
+    synthetic_pointer_driver_ = SyntheticPointerDriver::Create(
+        gesture_source_type_, params_.from_devtools_debugger);
 
   if (gesture_source_type_ == content::mojom::GestureSourceType::kTouchInput ||
       gesture_source_type_ == content::mojom::GestureSourceType::kMouseInput)
diff --git a/content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.cc b/content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.cc
index 0faed79..a26bb98 100644
--- a/content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_touchpad_pinch_gesture.cc
@@ -86,7 +86,10 @@
       target->DispatchInputEventToPlatform(
           blink::SyntheticWebGestureEventBuilder::Build(
               blink::WebGestureEvent::Type::kGesturePinchBegin,
-              blink::WebGestureDevice::kTouchpad));
+              blink::WebGestureDevice::kTouchpad,
+              params_.from_devtools_debugger
+                  ? blink::WebInputEvent::kFromDebugger
+                  : blink::WebInputEvent::kNoModifiers));
       state_ = IN_PROGRESS;
       break;
     case IN_PROGRESS: {
@@ -100,13 +103,19 @@
       target->DispatchInputEventToPlatform(
           blink::SyntheticWebGestureEventBuilder::BuildPinchUpdate(
               incremental_scale, params_.anchor.x(), params_.anchor.y(),
-              0 /* modifierFlags */, blink::WebGestureDevice::kTouchpad));
+              params_.from_devtools_debugger
+                  ? blink::WebInputEvent::kFromDebugger
+                  : blink::WebInputEvent::kNoModifiers,
+              blink::WebGestureDevice::kTouchpad));
 
       if (HasReachedTarget(event_timestamp)) {
         target->DispatchInputEventToPlatform(
             blink::SyntheticWebGestureEventBuilder::Build(
                 blink::WebGestureEvent::Type::kGesturePinchEnd,
-                blink::WebGestureDevice::kTouchpad));
+                blink::WebGestureDevice::kTouchpad,
+                params_.from_devtools_debugger
+                    ? blink::WebInputEvent::kFromDebugger
+                    : blink::WebInputEvent::kNoModifiers));
         state_ = DONE;
       }
       break;
diff --git a/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
index c440c59..f997628 100644
--- a/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc
@@ -51,8 +51,8 @@
             content::mojom::GestureSourceType::kDefaultInput);
 
   if (!synthetic_pointer_driver_)
-    synthetic_pointer_driver_ =
-        SyntheticPointerDriver::Create(gesture_source_type_);
+    synthetic_pointer_driver_ = SyntheticPointerDriver::Create(
+        gesture_source_type_, params_.from_devtools_debugger);
 
   if (gesture_source_type_ == content::mojom::GestureSourceType::kTouchInput) {
     ForwardTouchInputEvents(timestamp, target);