Bug 1418162 Use a build constant to determine update channel, and update ESR equation for 60 r=froydnj,Gijs
authorTom Ritter <tom@mozilla.com>
Mon, 19 Feb 2018 09:43:27 -0600
changeset 469253 ac0b202721dcfa1e57be7e004565996d47348cfa
parent 469252 669b85a6cab8c99a0bd0afe53a02149a2da77577
child 469254 04465c06888b1375502e4d33c2c7792e09ec6a49
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, Gijs
bugs1418162
milestone61.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 1418162 Use a build constant to determine update channel, and update ESR equation for 60 r=froydnj,Gijs 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
@@ -685,36 +685,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