Bug 1441295 - Reverted the changes in bug 1372069 and modified test; r=baku
authorYuan Lyu <lyyuan92@gmail.com>
Fri, 15 Jun 2018 23:23:40 -0400
changeset 423527 efe2c890d372
parent 423526 52e86ed85e54
child 423528 70e89e89a340
push id65488
push userapavel@mozilla.com
push dateMon, 25 Jun 2018 14:06:35 +0000
treeherderautoland@efe2c890d372 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1441295, 1372069
milestone62.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 1441295 - Reverted the changes in bug 1372069 and modified test; r=baku MozReview-Commit-ID: KG0H9UPa6Di
browser/components/resistfingerprinting/test/mochitest/test_geolocation.html
dom/geolocation/nsGeolocation.cpp
--- a/browser/components/resistfingerprinting/test/mochitest/test_geolocation.html
+++ b/browser/components/resistfingerprinting/test/mochitest/test_geolocation.html
@@ -8,16 +8,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 1372069</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript">
 
   const BASE_GEO_URL = "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs";
 
   /** Test for Bug 1372069 **/
+  /** Modified for Bug 1441295 **/
   SimpleTest.waitForExplicitFinish();
   window.onload = () => {
     SimpleTest.waitForFocus(() => {
       SpecialPowers.pushPrefEnv({"set":
         [
           ["privacy.resistFingerprinting", true],
           ["geo.prompt.testing",           true],
           ["geo.prompt.testing.allow",     true],
@@ -25,37 +26,35 @@ https://bugzilla.mozilla.org/show_bug.cg
         ]
       }, doTest_getCurrentPosition);
     }, window);
   };
 
   function doTest_getCurrentPosition() {
     navigator.geolocation.getCurrentPosition(
       (position) => {
-        ok(false, "Success callback is not expected to be called");
+        ok(true, "Success callback is expected to be called");
         doTest_watchPosition();
       },
       (error) => {
-        ok(true, "Check for the error callback to be called for fingerprinting resistance");
-        is(error.code, error.PERMISSION_DENIED, "Check error code for fingerprinting resistance");
+        ok(false, "Should be able to call success callback, Got error. code = " + error.code);
         doTest_watchPosition();
       }
     );
   }
 
   function doTest_watchPosition() {
     let wid = navigator.geolocation.watchPosition(
       (position) => {
-        ok(false, "Success callback is not expected to be called");
+        ok(true, "Success callback is expected to be called");
         navigator.geolocation.clearWatch(wid);
         SimpleTest.finish();
       },
       (error) => {
-        ok(true, "Check for the error callback to be called for fingerprinting resistance");
-        is(error.code, error.PERMISSION_DENIED, "Check error code for fingerprinting resistance");
+        ok(false, "Should be able to call success callback, Got error. code = " + error.code);
         navigator.geolocation.clearWatch(wid);
         SimpleTest.finish();
       }
     );
   }
   </script>
 </head>
 <body>
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -1216,18 +1216,17 @@ Geolocation::GetCurrentPosition(GeoPosit
                         static_cast<uint8_t>(mProtocolType));
 
   nsIEventTarget* target = MainThreadTarget(this);
   RefPtr<nsGeolocationRequest> request =
     new nsGeolocationRequest(this, std::move(callback), std::move(errorCallback),
                              std::move(options), static_cast<uint8_t>(mProtocolType), target,
                              false, EventStateManager::IsHandlingUserInput());
 
-  if (!sGeoEnabled || ShouldBlockInsecureRequests() ||
-      nsContentUtils::ResistFingerprinting(aCallerType)) {
+  if (!sGeoEnabled || ShouldBlockInsecureRequests()) {
     nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request);
     target->Dispatch(ev.forget());
     return NS_OK;
   }
 
   if (!mOwner && aCallerType != CallerType::System) {
     return NS_ERROR_FAILURE;
   }
@@ -1300,18 +1299,17 @@ Geolocation::WatchPosition(GeoPositionCa
 
   nsIEventTarget* target = MainThreadTarget(this);
   RefPtr<nsGeolocationRequest> request =
     new nsGeolocationRequest(this, std::move(aCallback), std::move(aErrorCallback),
                              std::move(aOptions),
                              static_cast<uint8_t>(mProtocolType), target, true,
                              EventStateManager::IsHandlingUserInput(), watchId);
 
-  if (!sGeoEnabled || ShouldBlockInsecureRequests() ||
-      nsContentUtils::ResistFingerprinting(aCallerType)) {
+  if (!sGeoEnabled || ShouldBlockInsecureRequests()) {
     nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(false, request);
     target->Dispatch(ev.forget());
     return watchId;
   }
 
   if (!mOwner && aCallerType != CallerType::System) {
     aRv.Throw(NS_ERROR_FAILURE);
     return -1;