Bug 1418672 In Resist Fingerprinting mode, correct the version of Firefox to spoof in 59 r=baku a=lizzard CLOSED TREE
authorTom Ritter <tom@mozilla.com>
Wed, 21 Feb 2018 01:33:49 -0600
changeset 455060 5e884033774ed5b9447e823091ce33a63b5cc1c4
parent 455059 8f710379c2794c018c452aa386f9e7ffdffedfe3
child 455061 ef2ed1192d9bda8e9507d2b3eb9c7818e50d98b5
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, lizzard
bugs1418672, 1418162
milestone59.0
Bug 1418672 In Resist Fingerprinting mode, correct the version of Firefox to spoof in 59 r=baku a=lizzard CLOSED TREE 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
browser/components/resistfingerprinting/test/browser/browser_navigator.js
toolkit/components/resistfingerprinting/nsRFPService.cpp
--- 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;