Bug 1418162 Use a build constant to determine update channel, and update ESR equation for 60 r=froydnj,Gijs a=jcristau FIREFOX_60b_RELBRANCH
authorTom Ritter <tom@mozilla.com>
Mon, 19 Feb 2018 09:43:27 -0600
branchFIREFOX_60b_RELBRANCH
changeset 469801 eee5fa942701d2e4673df7c74b5ca86a122dcfd5
parent 469800 b28d01fdafa5e2c0d39dc389574bd7d6e4a0ffac
child 469802 853522d049846ca4e6e5793db73903f6c09a329f
push id9175
push userarchaeopteryx@coole-files.de
push dateMon, 30 Apr 2018 17:10:23 +0000
treeherdermozilla-beta@c7889ba50e12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, Gijs, jcristau
bugs1418162
milestone60.0
Bug 1418162 Use a build constant to determine update channel, and update ESR equation for 60 r=froydnj,Gijs a=jcristau Previously we used Services.appinfo.defaultUpdateChannel to determine if we were on ESR and if so, we would assert to make sure the ESR equation hadn't changed. But that method is a footgun. We could use UpdateUtils.getUpdateChannel, but for our purposes here, the compile-time constant will work just as well. If it's set correctly, for Mozilla, we will perform our assert check. If it's not set to esr (e.g. for Tor), they'll skip the assert. They probably want to control their user agent themselves anyway. MozReview-Commit-ID: DLnWSEpCVJ6
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
@@ -114,17 +114,17 @@ async function testWorkerNavigator() {
 }
 
 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 = appVersion - ((appVersion - 4) % 7);
   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
@@ -684,36 +684,29 @@ nsRFPService::GetSpoofedUserAgent(nsACSt
   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),
+  if (!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "esr")) {
+    MOZ_ASSERT(((firefoxVersion % 7) == 4),
       "Please udpate ESR version formula in nsRFPService.cpp");
   }
 
-  uint32_t spoofedVersion = firefoxVersion - ((firefoxVersion - 3) % 7);
+  // Starting from Firefox 10, Firefox ESR was released once every seven
+  // Firefox releases, e.g. Firefox 10, 17, 24, 31, and so on.
+  // Except we used 60 as an ESR instead of 59.
+  // We infer the last and closest ESR version based on this rule.
+  uint32_t spoofedVersion = firefoxVersion - ((firefoxVersion - 4) % 7);
   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;
 }
 
 nsresult