Bug 1541508 - Use Services.env in xpcom/ r=xpcom-reviewers,kmag

Differential Revision: https://phabricator.services.mozilla.com/D160152
This commit is contained in:
Barret Rennie 2022-11-25 19:09:13 +00:00
Родитель 514ca65bbf
Коммит c4ddcc3f20
2 изменённых файлов: 3 добавлений и 9 удалений

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

@ -8,17 +8,14 @@ function get_test_program(prog) {
}
function set_process_running_environment() {
var envSvc = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// Importing Services here messes up appInfo for some of the tests.
// eslint-disable-next-line mozilla/use-services
var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(
Ci.nsIProperties
);
var greBinDir = dirSvc.get("GreBinD", Ci.nsIFile);
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
Services.env.set("DYLD_LIBRARY_PATH", greBinDir.path);
// For Linux
envSvc.set("LD_LIBRARY_PATH", greBinDir.path);
Services.env.set("LD_LIBRARY_PATH", greBinDir.path);
// XXX: handle windows
}

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

@ -11,11 +11,8 @@ function run_test() {
var homeDir = Services.dirsvc.get("Home", Ci.nsIFile);
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
var expected = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
expected.initWithPath(env.get(envVar));
expected.initWithPath(Services.env.get(envVar));
Assert.equal(homeDir.path, expected.path);
}