Bug 1541508 - Use Services.env in extensions/ r=extension-reviewers,robwu

Differential Revision: https://phabricator.services.mozilla.com/D160139
This commit is contained in:
Barret Rennie 2022-11-25 19:09:07 +00:00
Родитель fa6f96215a
Коммит 9c5e6dab31
4 изменённых файлов: 5 добавлений и 18 удалений

Просмотреть файл

@ -195,10 +195,7 @@ function displayError(funcname, message) {
function getenv(name) {
try {
var environment = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
return environment.get(name);
return Services.env.get(name);
} catch (e) {
displayError("getEnvironment", e);
}

Просмотреть файл

@ -6,9 +6,6 @@
* http://eslint.org/docs/rules/no-unsafe-finally */
function run_test() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let prefs = Services.prefs.getBranch(null);
let defPrefs = Services.prefs.getDefaultBranch(null);
@ -29,7 +26,7 @@ function run_test() {
autoConfigCfg.append("autoconfig-all.cfg");
autoConfigCfg.copyTo(greD, "autoconfig.cfg");
env.set("AUTOCONFIG_TEST_GETENV", "getenv");
Services.env.set("AUTOCONFIG_TEST_GETENV", "getenv");
Services.obs.notifyObservers(
Services.prefs,

Просмотреть файл

@ -6,12 +6,8 @@ const { updateAppInfo } = ChromeUtils.importESModule(
);
function run_test() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let testDirName = do_get_cwd().clone();
env.set("MOZ_SYSTEM_CONFIG_DIR", testDirName.path);
Services.env.set("MOZ_SYSTEM_CONFIG_DIR", testDirName.path);
updateAppInfo();

Просмотреть файл

@ -20,16 +20,13 @@ function ensureRemove(file) {
}
async function run_test() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let prefs = Services.prefs.getBranch(null);
let testDir = do_get_cwd();
let confDir = testDir.clone();
confDir.append("MozSystemConfigDir");
env.set("MOZ_SYSTEM_CONFIG_DIR", confDir.path);
env.set("SNAP_INSTANCE_NAME", "xpcshell");
Services.env.set("MOZ_SYSTEM_CONFIG_DIR", confDir.path);
Services.env.set("SNAP_INSTANCE_NAME", "xpcshell");
updateAppInfo();