Bug 1363508 - Part 3: Spoofing navigator.maxTouchPoints into 0 if fingerprinting resistance is enabled r=arthuredelstein,masayuki,smaug
authorTim Huang <tihuang@mozilla.com>
Tue, 09 Oct 2018 11:50:03 +0000
changeset 498972 d56cf859abf7a9c638c7b436a6872a724574905f
parent 498971 24afd8e04316ca29c5906c3119a94cfec2cc2292
child 498973 7741c70c8bce8b4ec0309e70e5faa491ffeb8845
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, smaug
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 3: Spoofing navigator.maxTouchPoints into 0 if fingerprinting resistance is enabled r=arthuredelstein,masayuki,smaug The maxTouchPoints is going to review the detail of users' hardware. So, we will spoof it into 0 if fingerprinting resistance is on. Depends on D6004 Differential Revision: https://phabricator.services.mozilla.com/D6005
dom/base/Navigator.cpp
dom/base/Navigator.h
dom/webidl/Navigator.webidl
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -875,18 +875,25 @@ Navigator::Vibrate(const nsTArray<uint32
   return true;
 }
 
 //*****************************************************************************
 //  Pointer Events interface
 //*****************************************************************************
 
 uint32_t
-Navigator::MaxTouchPoints()
+Navigator::MaxTouchPoints(CallerType aCallerType)
 {
+  // The maxTouchPoints is going to reveal the detail of users' hardware. So,
+  // we will spoof it into 0 if fingerprinting resistance is on.
+  if (aCallerType != CallerType::System &&
+      nsContentUtils::ShouldResistFingerprinting()) {
+    return 0;
+  }
+
   nsCOMPtr<nsIWidget> widget = widget::WidgetUtils::DOMWindowToWidget(mWindow->GetOuterWindow());
 
   NS_ENSURE_TRUE(widget, 0);
   return widget->GetMaxTouchPoints();
 }
 
 //*****************************************************************************
 //    Navigator::nsIDOMClientInformation
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -145,17 +145,17 @@ public:
 
   // Clears the user agent cache by calling:
   // Navigator_Binding::ClearCachedUserAgentValue(this);
   void ClearUserAgentCache();
 
   bool Vibrate(uint32_t aDuration);
   bool Vibrate(const nsTArray<uint32_t>& aDuration);
   void SetVibrationPermission(bool aPermitted, bool aPersistent);
-  uint32_t MaxTouchPoints();
+  uint32_t MaxTouchPoints(CallerType aCallerType);
   void GetAppCodeName(nsAString& aAppCodeName, ErrorResult& aRv);
   void GetOscpu(nsAString& aOscpu, CallerType aCallerType,
                 ErrorResult& aRv) const;
   void GetVendorSub(nsAString& aVendorSub);
   void GetVendor(nsAString& aVendor);
   void GetProductSub(nsAString& aProductSub);
   bool CookieEnabled();
   void GetBuildID(nsAString& aBuildID, CallerType aCallerType,
--- a/dom/webidl/Navigator.webidl
+++ b/dom/webidl/Navigator.webidl
@@ -142,17 +142,17 @@ partial interface Navigator {
     // We don't support sequences in unions yet
     //boolean vibrate ((unsigned long or sequence<unsigned long>) pattern);
     boolean vibrate(unsigned long duration);
     boolean vibrate(sequence<unsigned long> pattern);
 };
 
 // http://www.w3.org/TR/pointerevents/#extensions-to-the-navigator-interface
 partial interface Navigator {
-    [Pref="dom.w3c_pointer_events.enabled"]
+    [Pref="dom.w3c_pointer_events.enabled", NeedsCallerType]
     readonly attribute long maxTouchPoints;
 };
 
 // https://wicg.github.io/media-capabilities/#idl-index
 [Exposed=Window]
 partial interface Navigator {
   [SameObject, Func="mozilla::dom::MediaCapabilities::Enabled"]
   readonly attribute MediaCapabilities mediaCapabilities;