Bug 1599188 - Update ESR version spoofing calculation to assume a new ESR is released every June. r=ethan,timhuang

The old ESR version calculation assumed six-week release cycles, but Firefox has moved to four-week release cycles and Release Management shifted some of the ESR dates.

I plan to remove the special case for Firefox version < 78 once the 78 Nightly development cycle starts.

Differential Revision: https://phabricator.services.mozilla.com/D69155

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chris Peterson 2020-04-03 17:29:47 +00:00
parent ddc86c2048
commit 3755578948
2 changed files with 32 additions and 6 deletions

View File

@ -250,7 +250,15 @@ add_task(async function setup() {
});
let appVersion = parseInt(Services.appinfo.version);
let spoofedVersion = appVersion - ((appVersion - 4) % 8);
let spoofedVersion;
if (appVersion < 78) {
// 68 is the last ESR version from the old six-week release cadence. After
// 78 we can assume the four-week new release cadence.
spoofedVersion = 68;
} else {
spoofedVersion = appVersion - ((appVersion - 78) % 13);
}
spoofedUserAgentNavigator = `Mozilla/5.0 (${
SPOOFED_UA_NAVIGATOR_OS[AppConstants.platform]
}; rv:${spoofedVersion}.0) Gecko/20100101 Firefox/${spoofedVersion}.0`;

View File

@ -650,7 +650,7 @@ uint32_t nsRFPService::GetSpoofedPresentedFrames(double aTime, uint32_t aWidth,
static uint32_t GetSpoofedVersion() {
// If we can't get the current Firefox version, use a hard-coded ESR version.
const uint32_t kKnownEsrVersion = 60;
const uint32_t kKnownEsrVersion = 78;
nsresult rv;
nsCOMPtr<nsIXULAppInfo> appInfo =
@ -672,15 +672,33 @@ static uint32_t GetSpoofedVersion() {
// version has changed. Once changed, we must update the formula in this
// function.
if (!strcmp(MOZ_STRINGIFY(MOZ_UPDATE_CHANNEL), "esr")) {
MOZ_ASSERT(((firefoxVersion % 8) == 4),
MOZ_ASSERT(((firefoxVersion - kKnownEsrVersion) % 13) == 0,
"Please update ESR version formula in nsRFPService.cpp");
}
#endif // DEBUG
// Starting with Firefox 52, a new ESR version will be released every
// eight Firefox versions: 52, 60, 68, ...
// Starting with Firefox 78, a new ESR version will be released every June.
// We can't accurately calculate the next ESR version, but it will be
// probably be every ~13 Firefox releases, assuming four-week release
// cycles. If this assumption is wrong, we won't need to worry about it
// until ESR 104±1 in 2022. :) We have a debug assert above to catch if the
// spoofed version doesn't match the actual ESR version then.
// We infer the last and closest ESR version based on this rule.
return firefoxVersion - ((firefoxVersion - 4) % 8);
if (firefoxVersion < 78) {
// 68 is the last ESR version from the old six-week release cadence. After
// 78 we can assume the four-week new release cadence.
return 68;
}
uint32_t spoofedVersion =
firefoxVersion - ((firefoxVersion - kKnownEsrVersion) % 13);
MOZ_ASSERT(spoofedVersion >= kKnownEsrVersion &&
spoofedVersion <= firefoxVersion &&
(spoofedVersion - kKnownEsrVersion) % 13 == 0);
return spoofedVersion;
}
/* static */