Bug 1441295 - Reverted the changes in
bug 1372069 and modified test; r?tjr
MozReview-Commit-ID: KG0H9UPa6Di
--- 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;