Bug 1372069 - Part 1: Disable Geolocation when 'privacy.resistFingerprinting' is true. r?smaug, arthuredelstein draft
authorTim Huang <tihuang@mozilla.com>
Thu, 13 Jul 2017 14:11:08 +0800
changeset 608213 88d3523fa14520190e19d0c9ef91f3061d2bc0eb
parent 607967 30ea2905130e85f9e1d8d56fa3097901eec6514b
child 608214 7af98e34b69cd497c55bba0b827af2e8d47ea17e
child 608383 296f7d8a7b91b614817b946f49b38878b15c4cde
push id68204
push userbmo:tihuang@mozilla.com
push dateThu, 13 Jul 2017 08:47:45 +0000
reviewerssmaug, arthuredelstein
bugs1372069
milestone56.0a1
Bug 1372069 - Part 1: Disable Geolocation when 'privacy.resistFingerprinting' is true. r?smaug, arthuredelstein This patch disables Geolocation API when fingerprinting resistance is enabled. The way we disable it is the same as how we disable this API for non-secure origins that we will reject the request from this API and still keep this API around. MozReview-Commit-ID: 5D7Bf6Rplm8
dom/geolocation/nsGeolocation.cpp
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -1245,17 +1245,18 @@ Geolocation::GetCurrentPosition(GeoPosit
   Telemetry::Accumulate(Telemetry::GEOLOCATION_GETCURRENTPOSITION_SECURE_ORIGIN,
                         static_cast<uint8_t>(mProtocolType));
 
   RefPtr<nsGeolocationRequest> request =
     new nsGeolocationRequest(this, Move(callback), Move(errorCallback),
                              Move(options), static_cast<uint8_t>(mProtocolType),
                              false);
 
-  if (!sGeoEnabled || ShouldBlockInsecureRequests()) {
+  if (!sGeoEnabled || ShouldBlockInsecureRequests() ||
+      nsContentUtils::ResistFingerprinting(aCallerType)) {
     nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request);
     NS_DispatchToMainThread(ev);
     return NS_OK;
   }
 
   if (!mOwner && aCallerType != CallerType::System) {
     return NS_ERROR_FAILURE;
   }
@@ -1331,17 +1332,18 @@ Geolocation::WatchPosition(GeoPositionCa
   // The watch ID:
   *aRv = mLastWatchId++;
 
   RefPtr<nsGeolocationRequest> request =
     new nsGeolocationRequest(this, Move(aCallback), Move(aErrorCallback),
                              Move(aOptions),
                              static_cast<uint8_t>(mProtocolType), true, *aRv);
 
-  if (!sGeoEnabled || ShouldBlockInsecureRequests()) {
+  if (!sGeoEnabled || ShouldBlockInsecureRequests() ||
+      nsContentUtils::ResistFingerprinting(aCallerType)) {
     nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request);
     NS_DispatchToMainThread(ev);
     return NS_OK;
   }
 
   if (!mOwner && aCallerType != CallerType::System) {
     return NS_ERROR_FAILURE;
   }