Bug 1363508 - Part 2: Suppressing the pointer events that have isPrimary as false for fingerprinting resistance r=arthuredelstein,masayuki
authorTim Huang <tihuang@mozilla.com>
Tue, 09 Oct 2018 11:50:01 +0000
changeset 498971 24afd8e04316ca29c5906c3119a94cfec2cc2292
parent 498970 3e9933f36e458a44212e316b554fbaaaacbfd72b
child 498972 d56cf859abf7a9c638c7b436a6872a724574905f
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarthuredelstein, masayuki
bugs1363508
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363508 - Part 2: Suppressing the pointer events that have isPrimary as false for fingerprinting resistance r=arthuredelstein,masayuki Because of that the isPrimary of mouse pointer events will always be true. So, we suppress other events that have isPrimary as false when fingerprinting resistance is enabled. Depends on D6003 Differential Revision: https://phabricator.services.mozilla.com/D6004
widget/WidgetEventImpl.cpp
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -498,29 +498,41 @@ WidgetEvent::IsAllowedToDispatchInSystem
   // if we do, prevent default on mouse events can't prevent default behaviors
   // anymore.
   return mClass != ePointerEventClass;
 }
 
 bool
 WidgetEvent::IsBlockedForFingerprintingResistance() const
 {
-  if (mClass == eKeyboardEventClass &&
-      nsContentUtils::ShouldResistFingerprinting()) {
-    const WidgetKeyboardEvent* keyboardEvent = AsKeyboardEvent();
-
-    if (keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Alt     ||
-        keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Shift   ||
-        keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Control ||
-        keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_AltGraph) {
-      return true;
-    }
+  if (!nsContentUtils::ShouldResistFingerprinting()) {
+    return false;
   }
 
-  return false;
+  switch (mClass) {
+    case eKeyboardEventClass: {
+      const WidgetKeyboardEvent* keyboardEvent = AsKeyboardEvent();
+
+      return (keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Alt     ||
+              keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Shift   ||
+              keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Control ||
+              keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_AltGraph);
+    }
+    case ePointerEventClass: {
+      const WidgetPointerEvent* pointerEvent = AsPointerEvent();
+
+      // We suppress the pointer events if it is not primary for fingerprinting
+      // resistance. It is because of that we want to spoof any pointer event
+      // into a mouse pointer event and the mouse pointer event only has
+      // isPrimary as true.
+      return !pointerEvent->mIsPrimary;
+    }
+    default:
+      return false;
+  }
 }
 
 /******************************************************************************
  * mozilla::WidgetEvent
  *
  * Misc methods.
  ******************************************************************************/