Bug 1418672 In Resist Fingerprinting mode, correct the version of Firefox to spoof in 59 r?baku
Version 59 is confused, because it thought it was supposed to be an ESR.
Bug 1418162 will update the equation to use our new ESR schedule, but
that leaves 59 to be corrected.
Rather than try to write some complicated equation, and an assertion to
make sure we're future-proof, just hardcode the version we're supposed
to spoof to: 52.
In
Bug 1418162 we'll correct the function for real and that will be used
into the future for 60.
MozReview-Commit-ID: IHmeDeqFtER
--- a/browser/components/resistfingerprinting/test/browser/browser_navigator.js
+++ b/browser/components/resistfingerprinting/test/browser/browser_navigator.js
@@ -113,18 +113,17 @@ async function testWorkerNavigator() {
await BrowserTestUtils.removeTab(tab);
}
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({"set":
[["privacy.resistFingerprinting", true]]
});
- let appVersion = parseInt(Services.appinfo.version);
- let spoofedVersion = appVersion - ((appVersion - 3) % 7);
+ let spoofedVersion = 52;
spoofedUserAgent = `Mozilla/5.0 (${SPOOFED_UA_OS[AppConstants.platform]}; rv:${spoofedVersion}.0) Gecko/20100101 Firefox/${spoofedVersion}.0`;
});
add_task(async function runNavigatorTest() {
await testNavigator();
});
add_task(async function runWorkerNavigatorTest() {
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -242,56 +242,22 @@ nsRFPService::GetSpoofedUserAgent(nsACSt
{
// This function generates the spoofed value of User Agent.
// We spoof the values of the platform and Firefox version, which could be
// used as fingerprinting sources to identify individuals.
// Reference of the format of User Agent:
// https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/userAgent
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
- nsresult rv;
- nsCOMPtr<nsIXULAppInfo> appInfo =
- do_GetService("@mozilla.org/xre/app-info;1", &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsAutoCString appVersion;
- rv = appInfo->GetVersion(appVersion);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // The browser version will be spoofed as the last ESR version.
- // By doing so, the anonymity group will cover more versions instead of one
- // version.
- uint32_t firefoxVersion = appVersion.ToInteger(&rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // Starting from Firefox 10, Firefox ESR was released once every seven
- // Firefox releases, e.g. Firefox 10, 17, 24, 31, and so on.
- // We infer the last and closest ESR version based on this rule.
- nsCOMPtr<nsIXULRuntime> runtime =
- do_GetService("@mozilla.org/xre/runtime;1", &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsAutoCString updateChannel;
- rv = runtime->GetDefaultUpdateChannel(updateChannel);
- NS_ENSURE_SUCCESS(rv, rv);
-
- // If we are running in Firefox ESR, determine whether the formula of ESR
- // version has changed. Once changed, we must update the formula in this
- // function.
- if (updateChannel.EqualsLiteral("esr")) {
- MOZ_ASSERT(((firefoxVersion % 7) == 3),
- "Please udpate ESR version formula in nsRFPService.cpp");
- }
-
- uint32_t spoofedVersion = firefoxVersion - ((firefoxVersion - 3) % 7);
+ uint32_t spoofedVersion = 52;
userAgent.Assign(nsPrintfCString(
"Mozilla/5.0 (%s; rv:%d.0) Gecko/%s Firefox/%d.0",
SPOOFED_UA_OS, spoofedVersion, LEGACY_BUILD_ID, spoofedVersion));
- return rv;
+ return NS_OK;
}
nsresult
nsRFPService::Init()
{
MOZ_ASSERT(NS_IsMainThread());
nsresult rv;