[tbb-commits] [tor-browser] 56/311: Bug 1751124 - Disable SwipeTracker on Windows. r=tnikkel, a=RyanVM

gitolite role git at cupani.torproject.org
Tue Apr 26 15:27:36 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch geckoview-99.0.1-11.0-1
in repository tor-browser.

commit 163e7c3cec3395fa52bf95b1fabeaf8f2a1c60c6
Author: Hiroyuki Ikezoe <hikezoe.birchill at mozilla.com>
AuthorDate: Wed Feb 2 02:12:55 2022 +0000

    Bug 1751124 - Disable SwipeTracker on Windows. r=tnikkel, a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D137576
---
 modules/libpref/init/StaticPrefList.yaml           |  9 +++++++++
 widget/SwipeTracker.cpp                            |  5 +++++
 widget/tests/browser/browser_test_swipe_gesture.js | 19 ++++++++++++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
index 9d052d42bf55c..a9f8e6318fbff 100644
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -12553,6 +12553,15 @@
   mirror: always
 #endif
 
+# Whether to disable SwipeTracker (e.g. swipe-to-nav).
+- name: widget.disable-swipe-tracker
+  type: bool
+#ifdef XP_WIN
+  value: true
+#else
+  value: false
+#endif
+  mirror: always
 
 #---------------------------------------------------------------------------
 # Prefs starting with "xul."
diff --git a/widget/SwipeTracker.cpp b/widget/SwipeTracker.cpp
index dd1cba0512133..80abf95304e96 100644
--- a/widget/SwipeTracker.cpp
+++ b/widget/SwipeTracker.cpp
@@ -9,6 +9,7 @@
 #include "InputData.h"
 #include "mozilla/FlushType.h"
 #include "mozilla/PresShell.h"
+#include "mozilla/StaticPrefs_widget.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/dom/SimpleGestureEventBinding.h"
@@ -216,6 +217,10 @@ bool SwipeTracker::SendSwipeEvent(EventMessage aMsg, uint32_t aDirection,
 
 // static
 bool SwipeTracker::CanTriggerSwipe(const PanGestureInput& aPanInput) {
+  if (StaticPrefs::widget_disable_swipe_tracker()) {
+    return false;
+  }
+
   if (aPanInput.mType != PanGestureInput::PANGESTURE_START) {
     return false;
   }
diff --git a/widget/tests/browser/browser_test_swipe_gesture.js b/widget/tests/browser/browser_test_swipe_gesture.js
index 6c13c3f1c1152..5e917c3630dd8 100644
--- a/widget/tests/browser/browser_test_swipe_gesture.js
+++ b/widget/tests/browser/browser_test_swipe_gesture.js
@@ -127,6 +127,7 @@ add_task(async () => {
     set: [
       ["browser.gesture.swipe.left", "Browser:BackOrBackDuplicate"],
       ["browser.gesture.swipe.eight", "Browser:ForwardOrForwardDuplicate"],
+      ["widget.disable-swipe-tracker", false],
     ],
   });
 
@@ -201,9 +202,25 @@ add_task(async () => {
   // Now try to navigate backward again but with preventDefault-ed event
   // handler.
   wheelEventCount = 0;
-  tab.linkedBrowser.addEventListener("wheel", event => {
+  let wheelEventListener = event => {
     event.preventDefault();
+  };
+  tab.linkedBrowser.addEventListener("wheel", wheelEventListener);
+  await panLeftToRight(tab.linkedBrowser, 100, 100);
+  is(wheelEventCount, 3, "Received all wheel events");
+
+  await waitForWhile();
+  // Make sure any navigation didn't happen.
+  is(tab.linkedBrowser.currentURI.spec, secondPage);
+
+  // Now drop the event handler and disable the swipe tracker and try to swipe
+  // again.
+  wheelEventCount = 0;
+  tab.linkedBrowser.removeEventListener("wheel", wheelEventListener);
+  await SpecialPowers.pushPrefEnv({
+    set: [["widget.disable-swipe-tracker", true]],
   });
+
   await panLeftToRight(tab.linkedBrowser, 100, 100);
   is(wheelEventCount, 3, "Received all wheel events");
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list