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 488882 d56cf859abf7a9c638c7b436a6872a724574905f
parent 488881 24afd8e04316ca29c5906c3119a94cfec2cc2292
child 488883 7741c70c8bce8b4ec0309e70e5faa491ffeb8845
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersarthuredelstein, masayuki, smaug
bugs1363508
milestone64.0a1
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;