mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-07 03:38:51 +02:00
This commit does three main things: 1) It allows to configure the global singleton `nsUpdateSyncManager` with an `nsIFile` rather than having it use the ambient XPCOM directory service. This allows to initialize the `nsUpdateSyncManager` very early: before processing updates and long before XPCOM is initialized. This in turn allows us to determine if other instances early enough to skip processing updates when appropriate. When this initialization path is followed, i.e., in Firefox but not `xpcshell`, the `xpcom-startup` notification will be received but no action taken, since the singleton will already exist. There is a classic time-of-check, time-of-use race window in this implementation: an instance may be launched immediately after we check for other instances. In practice this will result in behaviour that is alreay possible: two independent instances both processing updates. It is expected that the updater itself will exclude one of the instances using its existing mutex. 2) It updates an existing background task test to use an explicit `nsIFile` rather than the existing directory service method. This exercises the newer API. There are other tests that might benefit, but there's no harm in remaining with the previous approach, since both are required. 3) It adds a new background task test to verify that update processing is skipped if we're not the sole instance running. Differential Revision: https://phabricator.services.mozilla.com/D106994
24 lines
833 B
JavaScript
24 lines
833 B
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/. */
|
|
|
|
var EXPORTED_SYMBOLS = ["runBackgroundTask"];
|
|
|
|
async function runBackgroundTask(commandLine) {
|
|
var env = Cc["@mozilla.org/process/environment;1"].getService(
|
|
Ci.nsIEnvironment
|
|
);
|
|
|
|
let exitCode =
|
|
env.get("MOZ_TEST_PROCESS_UPDATES") == "!ShouldProcessUpdates()" ? 80 : 81;
|
|
console.debug(`runBackgroundTask: shouldprocessupdates`, {
|
|
exists: env.exists("MOZ_TEST_PROCESS_UPDATES"),
|
|
get: env.get("MOZ_TEST_PROCESS_UPDATES"),
|
|
});
|
|
console.error(
|
|
`runBackgroundTask: shouldprocessupdates exiting with exitCode ${exitCode}`
|
|
);
|
|
|
|
return exitCode;
|
|
}
|