Files
tubestation/toolkit/components/backgroundtasks/tests/BackgroundTask_shouldprocessupdates.sys.mjs
Robin Steuber 0ca6934f6c Bug 1907126 - Add testing for the multi session install lock feature r=nrishel,nalexander,application-update-reviewers
Additionally disables the multi session install lock feature by default in update tests so that it doesn't interfere with tests not meant to test that behavior.

This does add telemetry testing, but does not do it as part of the main feature test. The problem with testing the telemetry in that test is that something has to stick around after startup to observe the telemetry. It is possible to have the update applied by a background task rather than a regular instance of the application and then to have that background task observe the telemetry. The problem is that applying the updates with a background task screws up the test because we are making sure that, in some cases, updates are applied at startup even if another instance is running. But background tasks are forbidden from doing exactly that. So the telemetry testing for this feature instead lives in the `shouldprocessupdates` background task used by `toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_shouldprocessupdates.js`.

Differential Revision: https://phabricator.services.mozilla.com/D230014
2024-12-13 02:57:38 +00:00

76 lines
2.1 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
export async function runBackgroundTask() {
const gleanRoot = await IOUtils.getDirectory(
Services.dirsvc.get("UpdRootD", Ci.nsIFile).path,
"backgroundupdate",
"datareporting",
"glean"
);
Services.prefs.setIntPref("telemetry.fog.test.localhost_port", -1);
Services.fog.initializeFOG(
gleanRoot.path,
"firefox.desktop.background.update.test"
);
const get = Services.env.get("MOZ_TEST_SHOULD_NOT_PROCESS_UPDATES");
let exitCode = 81;
if (get == "ShouldNotProcessUpdates(): OtherInstanceRunning") {
if (
Glean.update.skipStartupUpdateReason.OtherInstanceRunning.testGetValue() >
0
) {
exitCode = 80;
} else {
exitCode = 82;
}
}
if (get == "ShouldNotProcessUpdates(): DevToolsLaunching") {
if (
Glean.update.skipStartupUpdateReason.DevToolsLaunching.testGetValue() > 0
) {
exitCode = 79;
} else {
exitCode = 82;
}
}
if (get == "ShouldNotProcessUpdates(): NotAnUpdatingTask") {
if (
Glean.update.skipStartupUpdateReason.NotAnUpdatingTask.testGetValue() > 0
) {
exitCode = 78;
} else {
exitCode = 82;
}
}
if (get == "ShouldNotProcessUpdates(): FirstStartup") {
if (Glean.update.skipStartupUpdateReason.FirstStartup.testGetValue() > 0) {
exitCode = 77;
} else {
exitCode = 82;
}
}
if (get == "ShouldNotProcessUpdates(): MultiSessionInstallLockout") {
if (
Glean.update.skipStartupUpdateReason.MultiSessionInstallLockout.testGetValue() >
0
) {
exitCode = 76;
} else {
exitCode = 82;
}
}
console.debug(`runBackgroundTask: shouldprocessupdates`, {
exists: Services.env.exists("MOZ_TEST_SHOULD_NOT_PROCESS_UPDATES"),
get,
});
console.error(
`runBackgroundTask: shouldprocessupdates exiting with exitCode ${exitCode}`
);
return exitCode;
}