From eb65c20256d6bd015eef01a6c83a6efeba04ba7f Mon Sep 17 00:00:00 2001 From: Barret Rennie Date: Fri, 25 Nov 2022 19:09:11 +0000 Subject: [PATCH] Bug 1541508 - Use Services.env in tools/ r=marco Differential Revision: https://phabricator.services.mozilla.com/D160150 --- tools/code-coverage/PerTestCoverageUtils.jsm | 11 ++++------- tools/code-coverage/tests/xpcshell/head.js | 5 +---- tools/profiler/tests/browser/head.js | 5 +---- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tools/code-coverage/PerTestCoverageUtils.jsm b/tools/code-coverage/PerTestCoverageUtils.jsm index e7a5050ce214..f1945273c10a 100644 --- a/tools/code-coverage/PerTestCoverageUtils.jsm +++ b/tools/code-coverage/PerTestCoverageUtils.jsm @@ -8,17 +8,14 @@ var EXPORTED_SYMBOLS = ["PerTestCoverageUtils"]; -const env = Cc["@mozilla.org/process/environment;1"].getService( - Ci.nsIEnvironment -); // This is the directory where gcov is emitting the gcda files. -const gcovPrefixPath = env.get("GCOV_PREFIX"); +const gcovPrefixPath = Services.env.get("GCOV_PREFIX"); // This is the directory where codecoverage.py is expecting to see the gcda files. -const gcovResultsPath = env.get("GCOV_RESULTS_DIR"); +const gcovResultsPath = Services.env.get("GCOV_RESULTS_DIR"); // This is the directory where the JS engine is emitting the lcov files. -const jsvmPrefixPath = env.get("JS_CODE_COVERAGE_OUTPUT_DIR"); +const jsvmPrefixPath = Services.env.get("JS_CODE_COVERAGE_OUTPUT_DIR"); // This is the directory where codecoverage.py is expecting to see the lcov files. -const jsvmResultsPath = env.get("JSVM_RESULTS_DIR"); +const jsvmResultsPath = Services.env.get("JSVM_RESULTS_DIR"); const gcovPrefixDir = Cc["@mozilla.org/file/local;1"].createInstance( Ci.nsIFile diff --git a/tools/code-coverage/tests/xpcshell/head.js b/tools/code-coverage/tests/xpcshell/head.js index f7531561df5d..3642c5794c01 100644 --- a/tools/code-coverage/tests/xpcshell/head.js +++ b/tools/code-coverage/tests/xpcshell/head.js @@ -7,11 +7,8 @@ var { AppConstants } = ChromeUtils.importESModule( ); function getFiles() { - const env = Cc["@mozilla.org/process/environment;1"].getService( - Ci.nsIEnvironment - ); // This is the directory where gcov is emitting the gcda files. - const jsCoveragePath = env.get("JS_CODE_COVERAGE_OUTPUT_DIR"); + const jsCoveragePath = Services.env.get("JS_CODE_COVERAGE_OUTPUT_DIR"); const jsCoverageDir = Cc["@mozilla.org/file/local;1"].createInstance( Ci.nsIFile diff --git a/tools/profiler/tests/browser/head.js b/tools/profiler/tests/browser/head.js index d4a76061ee55..ef0e3128c01b 100644 --- a/tools/profiler/tests/browser/head.js +++ b/tools/profiler/tests/browser/head.js @@ -117,10 +117,7 @@ function findServiceWorkerThreads(profile) { allThreads.forEach(logInformationForThread.bind(null, "")); // Let's write the profile on disk if MOZ_UPLOAD_DIR is present - const env = Cc["@mozilla.org/process/environment;1"].getService( - Ci.nsIEnvironment - ); - const path = env.get("MOZ_UPLOAD_DIR"); + const path = Services.env.get("MOZ_UPLOAD_DIR"); if (path) { const profileName = `profile_${Date.now()}.json`; const profilePath = PathUtils.join(path, profileName);