Bug 1918194 - Pre: Add pref to allow downloading without BITS in background update task. r=bytesized,application-update-reviewers

There are lots of ways to achieve this for tests; this one is easier
to understand than mocking parts deep inside of
`UpdateService.sys.mjs`, i.e., within the `lazy` container object.

Differential Revision: https://phabricator.services.mozilla.com/D221859
This commit is contained in:
Nick Alexander 2024-10-31 21:26:35 +00:00
parent 8999660240
commit 8eadf5e644

View File

@ -61,6 +61,8 @@ const UPDATESERVICE_CID = Components.ID(
const PREF_APP_UPDATE_ALTUPDATEDIRPATH = "app.update.altUpdateDirPath";
const PREF_APP_UPDATE_BACKGROUNDERRORS = "app.update.backgroundErrors";
const PREF_APP_UPDATE_BACKGROUNDMAXERRORS = "app.update.backgroundMaxErrors";
const PREF_APP_UPDATE_BACKGROUND_ALLOWDOWNLOADSWITHOUTBITS =
"app.update.background.allowDownloadsWithoutBITS";
const PREF_APP_UPDATE_BITS_ENABLED = "app.update.BITS.enabled";
const PREF_APP_UPDATE_CANCELATIONS = "app.update.cancelations";
const PREF_APP_UPDATE_CANCELATIONS_OSX = "app.update.cancelations.osx";
@ -6200,7 +6202,16 @@ class Downloader {
let patchFile = updateDir.clone();
patchFile.append(FILE_UPDATE_MAR);
if (lazy.gIsBackgroundTaskMode) {
// Background updates generally should not fall back to internal (Necko)
// downloads: on Windows, they should only use Windows BITS. In
// automation, this pref allows Necko for testing.
let allowDownloadsWithoutBITS =
Cu.isInAutomation &&
Services.prefs.getBoolPref(
PREF_APP_UPDATE_BACKGROUND_ALLOWDOWNLOADSWITHOUTBITS,
false
);
if (lazy.gIsBackgroundTaskMode && !allowDownloadsWithoutBITS) {
// We don't normally run a background update if we can't use BITS, but
// this branch is possible because we do fall back from BITS failures by
// attempting an internal download.