Backed out 19 changesets (bug 1541508) for causing xpcshell failures on test_notHeadlessByDefault.js CLOSED TREE

Backed out changeset 08476fa2bc27 (bug 1541508)
Backed out changeset 0bf7514845db (bug 1541508)
Backed out changeset aa612a5e9ef7 (bug 1541508)
Backed out changeset 6bb9360473f7 (bug 1541508)
Backed out changeset b3d8e92f50c2 (bug 1541508)
Backed out changeset fa40dded133e (bug 1541508)
Backed out changeset 2e7db4aa8d4f (bug 1541508)
Backed out changeset 6098e2eb62ea (bug 1541508)
Backed out changeset 2c599ee639c4 (bug 1541508)
Backed out changeset 7d44f6e2644c (bug 1541508)
Backed out changeset c1279c3d674c (bug 1541508)
Backed out changeset 8bd08a62a590 (bug 1541508)
Backed out changeset 740010cb005c (bug 1541508)
Backed out changeset 0bfc7dd85c62 (bug 1541508)
Backed out changeset c4374a351356 (bug 1541508)
Backed out changeset 44ccfeca7364 (bug 1541508)
Backed out changeset e944e706a523 (bug 1541508)
Backed out changeset 2c59d66f43e4 (bug 1541508)
Backed out changeset a1896eacb6f1 (bug 1541508)
This commit is contained in:
Cristian Tuns 2022-11-01 22:38:52 -04:00
parent 39ca7d2cd7
commit 4d37cf70f1
194 changed files with 995 additions and 371 deletions

View File

@ -15,7 +15,11 @@ var DevelopmentHelpers = {
quickRestart() {
Services.obs.notifyObservers(null, "startupcache-invalidate");
Services.env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
Services.startup.quit(
Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart

View File

@ -17,7 +17,10 @@ function restartApp() {
function resetProfile() {
// Set the reset profile environment variable.
Services.env.set("MOZ_RESET_PROFILE_RESTART", "1");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("MOZ_RESET_PROFILE_RESTART", "1");
}
function showResetDialog() {

View File

@ -437,7 +437,9 @@ add_task(async function() {
ok(shouldPass, "No unexpected main thread I/O during startup");
} else {
const filename = "profile_startup_content_mainthreadio.json";
let path = Services.env.get("MOZ_UPLOAD_DIR");
let path = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZ_UPLOAD_DIR");
let profilePath = PathUtils.join(path, filename);
await IOUtils.writeJSON(profilePath, startupRecorder.data.profile);
ok(

View File

@ -837,7 +837,9 @@ add_task(async function() {
ok(shouldPass, "No unexpected main thread I/O during startup");
} else {
const filename = "profile_startup_mainthreadio.json";
let path = Services.env.get("MOZ_UPLOAD_DIR");
let path = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZ_UPLOAD_DIR");
let profilePath = PathUtils.join(path, filename);
await IOUtils.writeJSON(profilePath, startupRecorder.data.profile);
ok(

View File

@ -417,7 +417,9 @@ add_task(async function() {
ok(shouldPass, "No unexpected sync IPC during startup");
} else {
const filename = "profile_startup_syncIPC.json";
let path = Services.env.get("MOZ_UPLOAD_DIR");
let path = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZ_UPLOAD_DIR");
let profilePath = PathUtils.join(path, filename);
await IOUtils.writeJSON(profilePath, startupRecorder.data.profile);
ok(

View File

@ -117,14 +117,17 @@ async function setupLocalCrashReportServer() {
// report server, and fortunately one is already set up by toolkit/
// crashreporter/test/Makefile.in. Assign its URL to MOZ_CRASHREPORTER_URL,
// which CrashSubmit.jsm uses as a server override.
let noReport = Services.env.get("MOZ_CRASHREPORTER_NO_REPORT");
let serverUrl = Services.env.get("MOZ_CRASHREPORTER_URL");
Services.env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
Services.env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let noReport = env.get("MOZ_CRASHREPORTER_NO_REPORT");
let serverUrl = env.get("MOZ_CRASHREPORTER_URL");
env.set("MOZ_CRASHREPORTER_NO_REPORT", "");
env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
registerCleanupFunction(function() {
Services.env.set("MOZ_CRASHREPORTER_NO_REPORT", noReport);
Services.env.set("MOZ_CRASHREPORTER_URL", serverUrl);
env.set("MOZ_CRASHREPORTER_NO_REPORT", noReport);
env.set("MOZ_CRASHREPORTER_URL", serverUrl);
});
}
@ -143,15 +146,18 @@ function prepareNoDump() {
}
const kBuildidMatchEnv = "MOZ_BUILDID_MATCH_DONTSEND";
const envService = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
function setBuildidMatchDontSendEnv() {
info("Setting " + kBuildidMatchEnv + "=1");
Services.env.set(kBuildidMatchEnv, "1");
envService.set(kBuildidMatchEnv, "1");
}
function unsetBuildidMatchDontSendEnv() {
info("Setting " + kBuildidMatchEnv + "=0");
Services.env.set(kBuildidMatchEnv, "0");
envService.set(kBuildidMatchEnv, "0");
}
function getEventPromise(eventName, eventKind) {

View File

@ -22,7 +22,10 @@ const permissionError =
const notFoundError = "error: NotFoundError: The object can not be found here.";
const isHeadless = Services.env.get("MOZ_HEADLESS");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const isHeadless = env.get("MOZ_HEADLESS");
var gTests = [
{

View File

@ -203,7 +203,10 @@ StartupRecorder.prototype = {
}
paints = null;
if (!Services.env.exists("MOZ_PROFILER_STARTUP_PERFORMANCE_TEST")) {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (!env.exists("MOZ_PROFILER_STARTUP_PERFORMANCE_TEST")) {
this._resolve();
this._resolve = null;
return;

View File

@ -88,14 +88,17 @@ var AttributionCode = {
try {
file = Services.dirsvc.get("UpdRootD", Ci.nsIFile);
} catch (ex) {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// It's most common to test for the profile dir, even though we actually
// are using the temp dir.
if (
ex instanceof Ci.nsIException &&
ex.result == Cr.NS_ERROR_FAILURE &&
Services.env.exists("XPCSHELL_TEST_PROFILE_DIR")
env.exists("XPCSHELL_TEST_PROFILE_DIR")
) {
let path = Services.env.get("XPCSHELL_TEST_TEMP_DIR");
let path = env.get("XPCSHELL_TEST_TEMP_DIR");
file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(path);
file.append("nested_UpdRootD_1");
@ -435,7 +438,10 @@ var AttributionCode = {
* Does nothing if called from outside of an xpcshell test.
*/
_clearCache() {
if (Services.env.exists("XPCSHELL_TEST_PROFILE_DIR")) {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (env.exists("XPCSHELL_TEST_PROFILE_DIR")) {
gCachedAttrData = null;
}
},

View File

@ -15,9 +15,12 @@ const INDEX_QUARANTINE_ERROR = 3;
add_setup(function() {
// AttributionCode._clearCache is only possible in a testing environment
Services.env.set("XPCSHELL_TEST_PROFILE_DIR", "testing");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("XPCSHELL_TEST_PROFILE_DIR", "testing");
registerCleanupFunction(() => {
Services.env.set("XPCSHELL_TEST_PROFILE_DIR", null);
env.set("XPCSHELL_TEST_PROFILE_DIR", null);
});
});

View File

@ -46,7 +46,10 @@ function ensureNoTelemetry() {
}
function setup() {
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -38,7 +38,10 @@ const PREF_LOGLEVEL = "browser.policies.loglevel";
const BROWSER_DOCUMENT_URL = AppConstants.BROWSER_CHROME_URL;
const ABOUT_CONTRACT = "@mozilla.org/network/protocol/about;1?what=";
const isXpcshell = Services.env.exists("XPCSHELL_TEST_PROFILE_DIR");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
let { ConsoleAPI } = ChromeUtils.importESModule(

View File

@ -172,12 +172,15 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(
let dictionary = getFileResource(types.OTHERDATA, ["persdict.dat"]);
let session;
if (Services.env.get("MOZ_RESET_PROFILE_MIGRATE_SESSION")) {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (env.get("MOZ_RESET_PROFILE_MIGRATE_SESSION")) {
// We only want to restore the previous firefox session if the profile refresh was
// triggered by user. The MOZ_RESET_PROFILE_MIGRATE_SESSION would be set when a user-triggered
// profile refresh happened in nsAppRunner.cpp. Hence, we detect the MOZ_RESET_PROFILE_MIGRATE_SESSION
// to see if session data migration is required.
Services.env.set("MOZ_RESET_PROFILE_MIGRATE_SESSION", "");
env.set("MOZ_RESET_PROFILE_MIGRATE_SESSION", "");
let sessionCheckpoints = this._getFileObject(
sourceProfileDir,
"sessionCheckpoints.json"

View File

@ -59,13 +59,18 @@ var MigrationWizard = {
this.isInitialMigration =
entryPointId == MigrationUtils.MIGRATION_ENTRYPOINT_FIRSTRUN;
// Record that the uninstaller requested a profile refresh
if (Services.env.get("MOZ_UNINSTALLER_PROFILE_REFRESH")) {
Services.env.set("MOZ_UNINSTALLER_PROFILE_REFRESH", "");
Services.telemetry.scalarSet(
"migration.uninstaller_profile_refresh",
true
{
// Record that the uninstaller requested a profile refresh
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (env.get("MOZ_UNINSTALLER_PROFILE_REFRESH")) {
env.set("MOZ_UNINSTALLER_PROFILE_REFRESH", "");
Services.telemetry.scalarSet(
"migration.uninstaller_profile_refresh",
true
);
}
}
if (args.length == 2) {

View File

@ -621,18 +621,18 @@ class TestFirefoxRefresh(MarionetteTestCase):
global.profSvc.flush()
// Now add the reset parameters:
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
let prefsToKeep = Array.from(Services.prefs.getChildList("marionette."));
// Add all the modified preferences set from geckoinstance.py to avoid
// non-local connections.
prefsToKeep = prefsToKeep.concat(JSON.parse(
Services.env.get("MOZ_MARIONETTE_REQUIRED_PREFS")));
prefsToKeep = prefsToKeep.concat(JSON.parse(env.get("MOZ_MARIONETTE_REQUIRED_PREFS")));
let prefObj = {};
for (let pref of prefsToKeep) {
prefObj[pref] = global.Preferences.get(pref);
}
Services.env.set("MOZ_MARIONETTE_PREF_STATE_ACROSS_RESTARTS", JSON.stringify(prefObj));
Services.env.set("MOZ_RESET_PROFILE_RESTART", "1");
Services.env.set("XRE_PROFILE_PATH", arguments[0]);
env.set("MOZ_MARIONETTE_PREF_STATE_ACROSS_RESTARTS", JSON.stringify(prefObj));
env.set("MOZ_RESET_PROFILE_RESTART", "1");
env.set("XRE_PROFILE_PATH", arguments[0]);
""",
script_args=(
self.marionette.instance.profile.profile,

View File

@ -1735,7 +1735,10 @@ class _ASRouter {
}
// Clear cache call is only possible in a testing environment
Services.env.set("XPCSHELL_TEST_PROFILE_DIR", "testing");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("XPCSHELL_TEST_PROFILE_DIR", "testing");
// Clear and refresh Attribution, and then fetch the messages again to update
AttributionCode._clearCache();

View File

@ -55,7 +55,10 @@ async function openRTAMOWelcomePage() {
registerCleanupFunction(async () => {
BrowserTestUtils.removeTab(tab);
// Clear cache call is only possible in a testing environment
Services.env.set("XPCSHELL_TEST_PROFILE_DIR", "testing");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("XPCSHELL_TEST_PROFILE_DIR", "testing");
await ASRouter.forceAttribution({
source: "",
medium: "",

View File

@ -74,7 +74,7 @@ function adjustGeneralPaths() {
// test, so its path can serve to provide the unique key that the update
// sync manager requires (it doesn't need for this to be the actual
// path to any real file, it's only used as an opaque string).
let tempPath = Services.env.get("MOZ_PROCESS_LOG");
let tempPath = gEnv.get("MOZ_PROCESS_LOG");
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(tempPath);
return file;
@ -119,7 +119,7 @@ function adjustGeneralPaths() {
* See the files in toolkit/mozapps/update/tests/browser.
*/
async function initUpdate(params) {
Services.env.set("MOZ_TEST_SLOW_SKIP_UPDATE_STAGE", "1");
gEnv.set("MOZ_TEST_SLOW_SKIP_UPDATE_STAGE", "1");
await SpecialPowers.pushPrefEnv({
set: [
[PREF_APP_UPDATE_DISABLEDFORTESTING, false],

View File

@ -11,7 +11,12 @@ add_task(async function detach() {
// editor or selection code in Gecko. Since this has only been observed on Mac
// in chaos mode and doesn't seem to be a problem in urlbar code, skip the
// test in that case.
if (AppConstants.platform == "macosx" && Services.env.get("MOZ_CHAOSMODE")) {
if (
AppConstants.platform == "macosx" &&
Cc["@mozilla.org/process/environment;1"]
.getService(SpecialPowers.Ci.nsIEnvironment)
.get("MOZ_CHAOSMODE")
) {
Assert.ok(true, "Skipping test in chaos mode on Mac");
return;
}

View File

@ -167,7 +167,10 @@ var TabCrashHandler = {
}
// check for environment affecting crash reporting
let shutdown = Services.env.exists("MOZ_CRASHREPORTER_SHUTDOWN");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let shutdown = env.exists("MOZ_CRASHREPORTER_SHUTDOWN");
if (shutdown) {
dump(

View File

@ -215,8 +215,11 @@ add_setup(async function() {
notification.close();
}
let oldServerURL = Services.env.get("MOZ_CRASHREPORTER_URL");
Services.env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let oldServerURL = env.get("MOZ_CRASHREPORTER_URL");
env.set("MOZ_CRASHREPORTER_URL", SERVER_URL);
// nsBrowserGlue starts up UnsubmittedCrashHandler automatically
// on a timer, so at this point, it can be in one of several states:
@ -255,7 +258,7 @@ add_setup(async function() {
registerCleanupFunction(function() {
clearPendingCrashReports();
Services.env.set("MOZ_CRASHREPORTER_URL", oldServerURL);
env.set("MOZ_CRASHREPORTER_URL", oldServerURL);
});
});

View File

@ -9,6 +9,9 @@
const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(
Ci.nsIChromeRegistry
);
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const EXTENSION_DIR =
"chrome://mochitests/content/browser/browser/tools/mozscreenshots/mozscreenshots/extension/mozscreenshots/browser/";
@ -44,7 +47,7 @@ async function setup() {
* @return {bool} whether to capture screenshots.
*/
function shouldCapture() {
if (Services.env.get("MOZSCREENSHOTS_SETS")) {
if (env.get("MOZSCREENSHOTS_SETS")) {
ok(
true,
"MOZSCREENSHOTS_SETS was specified so only capture what was " +

View File

@ -6,6 +6,9 @@
var EXPORTED_SYMBOLS = ["TestRunner"];
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const APPLY_CONFIG_TIMEOUT_MS = 60 * 1000;
const HOME_PAGE = "resource://mozscreenshots/lib/mozscreenshots.html";
@ -94,8 +97,8 @@ var TestRunner = {
];
let screenshotPath = PathUtils.join(PathUtils.tempDir, ...subDirs);
const MOZ_UPLOAD_DIR = Services.env.get("MOZ_UPLOAD_DIR");
const GECKO_HEAD_REPOSITORY = Services.env.get("GECKO_HEAD_REPOSITORY");
const MOZ_UPLOAD_DIR = env.get("MOZ_UPLOAD_DIR");
const GECKO_HEAD_REPOSITORY = env.get("GECKO_HEAD_REPOSITORY");
// We don't want to upload images (from MOZ_UPLOAD_DIR) on integration
// branches in order to reduce bandwidth/storage.
if (MOZ_UPLOAD_DIR && !GECKO_HEAD_REPOSITORY.includes("/integration/")) {

View File

@ -7,7 +7,7 @@
/* import-globals-from ../../head.js */
add_task(async function capture() {
let setsEnv = Services.env.get("MOZSCREENSHOTS_SETS");
let setsEnv = env.get("MOZSCREENSHOTS_SETS");
if (!setsEnv) {
ok(
true,

View File

@ -14,7 +14,7 @@ async function getExpectedRuntime() {
async function getExpectedRuntimeAll() {
const runtimesPath = _getExpectedRuntimesPath();
const currentPath = Services.env.get("PWD");
const currentPath = env.get("PWD");
const path = `${currentPath}/${runtimesPath}`;
info(`Load ${path}`);
const buffer = await IOUtils.read(path);
@ -50,5 +50,8 @@ async function openAboutDebuggingWithADB() {
/* exported openAboutDebuggingWithADB */
function _getExpectedRuntimesPath() {
return Services.env.get("USB_RUNTIMES");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
return env.get("USB_RUNTIMES");
}

View File

@ -39,6 +39,10 @@ XPCOMUtils.defineLazyServiceGetters(lazy, {
const Telemetry = require("resource://devtools/client/shared/telemetry.js");
const EventEmitter = require("resource://devtools/shared/event-emitter.js");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const processes = new Set();
/**
@ -290,7 +294,7 @@ export class BrowserToolboxLauncher extends EventEmitter {
// so that you could pass an optimized build for the browser toolbox.
// This is also useful when debugging a patch that break devtools,
// so that you could use a build that works for the browser toolbox.
const customBinaryPath = Services.env.get("MOZ_BROWSER_TOOLBOX_BINARY");
const customBinaryPath = env.get("MOZ_BROWSER_TOOLBOX_BINARY");
if (customBinaryPath) {
command = customBinaryPath;
profilePath = lazy.FileUtils.getDir(
@ -321,9 +325,7 @@ export class BrowserToolboxLauncher extends EventEmitter {
const environment = {
// Allow recording the startup of the browser toolbox when setting
// MOZ_BROWSER_TOOLBOX_PROFILER_STARTUP=1 when running firefox.
MOZ_PROFILER_STARTUP: Services.env.get(
"MOZ_BROWSER_TOOLBOX_PROFILER_STARTUP"
),
MOZ_PROFILER_STARTUP: env.get("MOZ_BROWSER_TOOLBOX_PROFILER_STARTUP"),
// And prevent profiling any subsequent toolbox
MOZ_BROWSER_TOOLBOX_PROFILER_STARTUP: "0",

View File

@ -15,15 +15,22 @@ add_task(async function() {
// Running devtools should prevent processing updates. By setting this
// environment variable and then inspecting it from the launched devtools
// process, we can witness update processing being skipped.
Services.env.set("MOZ_TEST_PROCESS_UPDATES", "1");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("MOZ_TEST_PROCESS_UPDATES", "1");
const ToolboxTask = await initBrowserToolboxTask();
await ToolboxTask.importFunctions({});
let result = await ToolboxTask.spawn(null, async () => {
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const result = {
exists: Services.env.exists("MOZ_TEST_PROCESS_UPDATES"),
get: Services.env.get("MOZ_TEST_PROCESS_UPDATES"),
exists: env.exists("MOZ_TEST_PROCESS_UPDATES"),
get: env.get("MOZ_TEST_PROCESS_UPDATES"),
};
// Log so that we have a hope of debugging.
console.log("result", result);

View File

@ -29,6 +29,9 @@ const { LocalizationHelper } = require("resource://devtools/shared/l10n.js");
const L10N = new LocalizationHelper(
"devtools/client/locales/toolbox.properties"
);
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -84,19 +87,19 @@ var connect = async function() {
// otherwise it is set to "0".
Services.prefs.setBoolPref(
"devtools.browsertoolbox.fission",
Services.env.get("MOZ_BROWSER_TOOLBOX_FISSION_PREF") === "1"
env.get("MOZ_BROWSER_TOOLBOX_FISSION_PREF") === "1"
);
// Similar, but for the WebConsole input context dropdown.
Services.prefs.setBoolPref(
"devtools.webconsole.input.context",
Services.env.get("MOZ_BROWSER_TOOLBOX_INPUT_CONTEXT") === "1"
env.get("MOZ_BROWSER_TOOLBOX_INPUT_CONTEXT") === "1"
);
// Similar, but for the Browser Toolbox mode
if (Services.env.get("MOZ_BROWSER_TOOLBOX_FORCE_MULTIPROCESS") === "1") {
if (env.get("MOZ_BROWSER_TOOLBOX_FORCE_MULTIPROCESS") === "1") {
Services.prefs.setCharPref("devtools.browsertoolbox.scope", "everything");
}
const port = Services.env.get("MOZ_BROWSER_TOOLBOX_PORT");
const port = env.get("MOZ_BROWSER_TOOLBOX_PORT");
// A port needs to be passed in from the environment, for instance:
// MOZ_BROWSER_TOOLBOX_PORT=6080 ./mach run -chrome \
@ -251,7 +254,7 @@ async function openToolbox(commands) {
await gToolbox.raise();
// Warn the user if we started recording this browser toolbox via MOZ_BROWSER_TOOLBOX_PROFILER_STARTUP=1
if (Services.env.get("MOZ_PROFILER_STARTUP") === "1") {
if (env.get("MOZ_PROFILER_STARTUP") === "1") {
const notificationBox = gToolbox.getNotificationBox();
const text =
"The profiler started recording this toolbox, open another browser toolbox to open the profile via the performance panel";

View File

@ -57,7 +57,10 @@ SpecialPowers.pushPrefEnv({
});
// Set DEBUG_DEVTOOLS_ALLOCATIONS=allocations|leaks in order print debug informations.
const DEBUG_ALLOCATIONS = Services.env.get("DEBUG_DEVTOOLS_ALLOCATIONS");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const DEBUG_ALLOCATIONS = env.get("DEBUG_DEVTOOLS_ALLOCATIONS");
async function addTab(url) {
const tab = BrowserTestUtils.addTab(gBrowser, url);

View File

@ -147,11 +147,6 @@ declare namespace MockedExports {
}
type Services = {
env: {
set: (name: string, value: string) => void;
get: (name: string) => string;
exists: (name: string) => boolean;
},
prefs: nsIPrefBranch;
profiler: {
StartProfiler: (

View File

@ -198,6 +198,12 @@ export type RestartBrowserWithEnvironmentVariable = (
*/
export type OnProfileReceived = (profile: MinimallyTypedGeckoProfile) => void;
/**
* This is the type signature for a function to query the browser for an
* environment variable. Currently only implemented for the popup.
*/
export type GetEnvironmentVariable = (envName: string) => string;
/**
* This is the type signature for a function to query the browser for the
* ID of the active tab.

View File

@ -15,6 +15,7 @@
* @typedef {import("./@types/perf").PerformancePref} PerformancePref
* @typedef {import("./@types/perf").RecordingSettings} RecordingSettings
* @typedef {import("./@types/perf").RestartBrowserWithEnvironmentVariable} RestartBrowserWithEnvironmentVariable
* @typedef {import("./@types/perf").GetEnvironmentVariable} GetEnvironmentVariable
* @typedef {import("./@types/perf").GetActiveBrowserID} GetActiveBrowserID
* @typedef {import("./@types/perf").MinimallyTypedGeckoProfile} MinimallyTypedGeckoProfile
* * @typedef {import("./@types/perf").ProfilerViewMode} ProfilerViewMode
@ -136,13 +137,28 @@ function sharedLibrariesFromProfile(profile) {
* @type {RestartBrowserWithEnvironmentVariable}
*/
function restartBrowserWithEnvironmentVariable(envName, value) {
Services.env.set(envName, value);
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set(envName, value);
Services.startup.quit(
Services.startup.eForceQuit | Services.startup.eRestart
);
}
/**
* Gets an environment variable from the browser.
*
* @type {GetEnvironmentVariable}
*/
function getEnvironmentVariable(envName) {
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
return env.get(envName);
}
/**
* @param {Window} window
* @param {string[]} objdirs
@ -168,5 +184,6 @@ module.exports = {
openProfilerTab,
sharedLibrariesFromProfile,
restartBrowserWithEnvironmentVariable,
getEnvironmentVariable,
openFilePickerForObjdir,
};

View File

@ -139,7 +139,10 @@ function initialize(toggleProfilerKeyShortcuts) {
// but we try to avoid interfering with profiling of automated tests.
if (
Services.profiler.IsActive() &&
(!Cu.isInAutomation || !Services.env.exists("MOZ_PROFILER_STARTUP"))
(!Cu.isInAutomation ||
!Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.exists("MOZ_PROFILER_STARTUP"))
) {
Services.profiler.StopProfiler();
}

View File

@ -5,6 +5,9 @@
"use strict";
const selectors = require("resource://devtools/client/performance-new/store/selectors.js");
const {
getEnvironmentVariable,
} = require("resource://devtools/client/performance-new/browser.js");
/**
* @typedef {import("../@types/perf").Action} Action
@ -84,7 +87,7 @@ exports.changeFeatures = features => {
// this hasn't been updated yet for the about:profiling workflow, because
// jstracer is disabled for now.
if (
!Services.env.get("JS_TRACE_LOGGING") &&
!getEnvironmentVariable("JS_TRACE_LOGGING") &&
features.includes("jstracer")
) {
promptEnvRestart = "JS_TRACE_LOGGING";

View File

@ -11,6 +11,7 @@
* @typedef {import("../@types/perf").PerfFront} PerfFront
* @typedef {import("../@types/perf").ReceiveProfile} ReceiveProfile
* @typedef {import("../@types/perf").RestartBrowserWithEnvironmentVariable} RestartBrowserWithEnvironmentVariable
* @typedef {import("../@types/perf").GetEnvironmentVariable} GetEnvironmentVariable
* @typedef {import("../@types/perf").PageContext} PageContext
* @typedef {import("../@types/perf").Presets} Presets
*/

View File

@ -19,8 +19,11 @@ add_task(async function test() {
{
info("Ensure that JS Tracer is not currently enabled.");
const {
getEnvironmentVariable,
} = require("resource://devtools/client/performance-new/browser.js");
ok(
!Services.env.get("JS_TRACE_LOGGING"),
!getEnvironmentVariable("JS_TRACE_LOGGING"),
"The JS_TRACE_LOGGING is not currently enabled."
);
}

View File

@ -19,14 +19,18 @@ const { require } = ChromeUtils.importESModule(
);
{
if (Services.env.get("MOZ_PROFILER_SHUTDOWN")) {
const {
getEnvironmentVariable,
} = require("resource://devtools/client/performance-new/browser.js");
if (getEnvironmentVariable("MOZ_PROFILER_SHUTDOWN")) {
throw new Error(
"These tests cannot be run with shutdown profiling as they rely on manipulating " +
"the state of the profiler."
);
}
if (Services.env.get("MOZ_PROFILER_STARTUP")) {
if (getEnvironmentVariable("MOZ_PROFILER_STARTUP")) {
throw new Error(
"These tests cannot be run with startup profiling as they rely on manipulating " +
"the state of the profiler."

View File

@ -120,7 +120,7 @@ const EXPRESSIONS_BY_FILE = {
};
add_task(async function() {
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
const tab = await addTab(TEST_URI);
const {
@ -135,7 +135,7 @@ add_task(async function() {
const generatedStubs = await generateStubs(commands, stubFile);
if (isStubsUpdate) {
await writeStubsToFile(stubFile, generatedStubs);
await writeStubsToFile(env, stubFile, generatedStubs);
ok(true, `${stubFile} was updated`);
continue;
}
@ -248,11 +248,12 @@ const STUBS_UPDATE_ENV = "STUBS_UPDATE";
/**
* Write stubs to a given file
*
* @param {Object} env
* @param {String} fileName: The file to write the stubs in.
* @param {Map} packets: A Map of the packets.
*/
async function writeStubsToFile(fileName, packets) {
const mozRepo = Services.env.get("MOZ_DEVELOPER_REPO_DIR");
async function writeStubsToFile(env, fileName, packets) {
const mozRepo = env.get("MOZ_DEVELOPER_REPO_DIR");
const filePath = `${mozRepo}/${STUBS_FOLDER + fileName}`;
const stubs = Array.from(packets.entries()).map(([key, packet]) => {

View File

@ -23,7 +23,10 @@ const { Constructor: CC } = Components;
// Print allocation count if DEBUG_DEVTOOLS_ALLOCATIONS is set to "normal",
// and allocation sites if DEBUG_DEVTOOLS_ALLOCATIONS is set to "verbose".
const DEBUG_ALLOCATIONS = Services.env.get("DEBUG_DEVTOOLS_ALLOCATIONS");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const DEBUG_ALLOCATIONS = env.get("DEBUG_DEVTOOLS_ALLOCATIONS");
if (DEBUG_ALLOCATIONS) {
// Use a custom loader with `invisibleToDebugger` flag for the allocation tracker
// as it instantiates custom Debugger API instances and has to be running in a distinct

View File

@ -17,13 +17,13 @@ const TEST_URI =
const STUB_FILE = "consoleApi.js";
add_task(async function() {
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
info(`${isStubsUpdate ? "Update" : "Check"} ${STUB_FILE}`);
const generatedStubs = await generateConsoleApiStubs();
if (isStubsUpdate) {
await writeStubsToFile(STUB_FILE, generatedStubs);
await writeStubsToFile(env, STUB_FILE, generatedStubs);
ok(true, `${STUB_FILE} was updated`);
return;
}

View File

@ -17,13 +17,13 @@ const TEST_URI =
const STUB_FILE = "cssMessage.js";
add_task(async function() {
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
info(`${isStubsUpdate ? "Update" : "Check"} ${STUB_FILE}`);
const generatedStubs = await generateCssMessageStubs();
if (isStubsUpdate) {
await writeStubsToFile(STUB_FILE, generatedStubs);
await writeStubsToFile(env, STUB_FILE, generatedStubs);
ok(true, `${STUB_FILE} was updated`);
return;
}

View File

@ -15,13 +15,13 @@ const TEST_URI = "data:text/html;charset=utf-8,<!DOCTYPE html>stub generation";
const STUB_FILE = "evaluationResult.js";
add_task(async function() {
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
info(`${isStubsUpdate ? "Update" : "Check"} ${STUB_FILE}`);
const generatedStubs = await generateEvaluationResultStubs();
if (isStubsUpdate) {
await writeStubsToFile(STUB_FILE, generatedStubs);
await writeStubsToFile(env, STUB_FILE, generatedStubs);
ok(true, `${STUB_FILE} was updated`);
return;
}

View File

@ -17,13 +17,13 @@ const TEST_URI =
const STUB_FILE = "networkEvent.js";
add_task(async function() {
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
info(`${isStubsUpdate ? "Update" : "Check"} ${STUB_FILE}`);
const generatedStubs = await generateNetworkEventStubs();
if (isStubsUpdate) {
await writeStubsToFile(STUB_FILE, generatedStubs, true);
await writeStubsToFile(env, STUB_FILE, generatedStubs, true);
ok(true, `${STUB_FILE} was updated`);
return;
}

View File

@ -19,13 +19,13 @@ const STUB_FILE = "pageError.js";
add_task(async function() {
await pushPref("javascript.options.asyncstack_capture_debuggee_only", false);
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
info(`${isStubsUpdate ? "Update" : "Check"} ${STUB_FILE}`);
const generatedStubs = await generatePageErrorStubs();
if (isStubsUpdate) {
await writeStubsToFile(STUB_FILE, generatedStubs);
await writeStubsToFile(env, STUB_FILE, generatedStubs);
ok(true, `${STUB_FILE} was updated`);
return;
}

View File

@ -15,13 +15,13 @@ const {
const STUB_FILE = "platformMessage.js";
add_task(async function() {
const isStubsUpdate = Services.env.get(STUBS_UPDATE_ENV) == "true";
const isStubsUpdate = env.get(STUBS_UPDATE_ENV) == "true";
info(`${isStubsUpdate ? "Update" : "Check"} ${STUB_FILE}`);
const generatedStubs = await generatePlatformMessagesStubs();
if (isStubsUpdate) {
await writeStubsToFile(STUB_FILE, generatedStubs);
await writeStubsToFile(env, STUB_FILE, generatedStubs);
ok(true, `${STUB_FILE} was updated`);
return;
}

View File

@ -86,7 +86,10 @@ const ProcessDescriptorActor = ActorClassWithSpec(processDescriptorSpec, {
},
get isXpcshell() {
return Services.env.exists("XPCSHELL_TEST_PROFILE_DIR");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
return env.exists("XPCSHELL_TEST_PROFILE_DIR");
},
get isBackgroundTaskMode() {
@ -233,7 +236,10 @@ const ProcessDescriptorActor = ActorClassWithSpec(processDescriptorSpec, {
Services.obs.notifyObservers(null, "startupcache-invalidate");
// Avoid safemode popup from appearing on restart
Services.env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
Services.startup.quit(
Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart

View File

@ -903,10 +903,13 @@ DevToolsStartup.prototype = {
const { BrowserToolboxLauncher } = ChromeUtils.importESModule(
"resource://devtools/client/framework/browser-toolbox/Launcher.sys.mjs"
);
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// --jsdebugger $binaryPath is an helper alias to set MOZ_BROWSER_TOOLBOX_BINARY=$binaryPath
// See comment within BrowserToolboxLauncher.
// Setting it as an environment variable helps it being reused if we restart the browser via CmdOrCtrl+R
Services.env.set("MOZ_BROWSER_TOOLBOX_BINARY", binaryPath);
env.set("MOZ_BROWSER_TOOLBOX_BINARY", binaryPath);
const browserToolboxLauncherConfig = {};

View File

@ -109,8 +109,11 @@ add_task(async function test_background_window() {
});
add_task(async function test_minimized() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// Minimizing windows doesn't supported in headless mode.
if (Services.env.get("MOZ_HEADLESS")) {
if (env.get("MOZ_HEADLESS")) {
return;
}

View File

@ -2,7 +2,9 @@ const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
// Returns the test H/2 server port, throwing if it's missing or invalid.
function getTestServerPort() {
let portEnv = Services.env.get("MOZHTTP2_PORT");
let portEnv = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZHTTP2_PORT");
let port = parseInt(portEnv, 10);
if (!Number.isFinite(port) || port < 1 || port > 65535) {
throw new Error(`Invalid port in MOZHTTP2_PORT env var: ${portEnv}`);

View File

@ -211,8 +211,11 @@ add_task(async function test_new_window_get() {
});
add_task(async function test_minimize_make() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// Minimizing windows doesn't supported in headless mode.
if (Services.env.get("MOZ_HEADLESS")) {
if (env.get("MOZ_HEADLESS")) {
return;
}
@ -241,8 +244,11 @@ add_task(async function test_minimize_make() {
});
add_task(async function test_minimize_get() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
// Minimizing windows doesn't supported in headless mode.
if (Services.env.get("MOZ_HEADLESS")) {
if (env.get("MOZ_HEADLESS")) {
return;
}

View File

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

View File

@ -6,6 +6,9 @@
* 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);
@ -26,7 +29,7 @@ function run_test() {
autoConfigCfg.append("autoconfig-all.cfg");
autoConfigCfg.copyTo(greD, "autoconfig.cfg");
Services.env.set("AUTOCONFIG_TEST_GETENV", "getenv");
env.set("AUTOCONFIG_TEST_GETENV", "getenv");
Services.obs.notifyObservers(
Services.prefs,

View File

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

View File

@ -20,13 +20,16 @@ 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");
Services.env.set("MOZ_SYSTEM_CONFIG_DIR", confDir.path);
Services.env.set("SNAP_INSTANCE_NAME", "xpcshell");
env.set("MOZ_SYSTEM_CONFIG_DIR", confDir.path);
env.set("SNAP_INSTANCE_NAME", "xpcshell");
updateAppInfo();

View File

@ -121,7 +121,9 @@ async function test() {
}
function isOnChaosMode() {
return Services.env.get("MOZ_CHAOSMODE");
const env = SpecialPowers.Cc["@mozilla.org/process/environment;1"]
.getService(SpecialPowers.Ci.nsIEnvironment);
return env.get("MOZ_CHAOSMODE");
}
if (searchParams.get("input-type") == "native-key" &&

View File

@ -42,7 +42,9 @@ async function test() {
}
function isOnChaosMode() {
return Services.env.get("MOZ_CHAOSMODE");
const env = SpecialPowers.Cc["@mozilla.org/process/environment;1"]
.getService(SpecialPowers.Ci.nsIEnvironment);
return env.get("MOZ_CHAOSMODE");
}
if ((getPlatform() == "mac" || getPlatform() == "windows") &&

View File

@ -341,7 +341,10 @@ function OnLDBLoad() {
if (gArgs.profile) {
if (Services.profiler) {
if (!Services.env.exists("MOZ_PROFILER_SYMBOLICATE")) {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
if (!env.exists("MOZ_PROFILER_SYMBOLICATE")) {
dump(
"Warning: MOZ_PROFILER_SYMBOLICATE environment variable not set; " +
"profile will not be symbolicated.\n"

View File

@ -472,6 +472,8 @@ function BuildConditionSandbox(aURL) {
sandbox.isCoverageBuild = g.isCoverageBuild;
var prefs = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var env = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
sandbox.xulRuntime = Cu.cloneInto({widgetToolkit: xr.widgetToolkit, OS: xr.OS, XPCOMABI: xr.XPCOMABI}, sandbox);

View File

@ -8,6 +8,7 @@ const XHTML_NS = "http://www.w3.org/1999/xhtml";
const DEBUG_CONTRACTID = "@mozilla.org/xpcom/debug;1";
const PRINTSETTINGS_CONTRACTID = "@mozilla.org/gfx/printsettings-service;1";
const ENVIRONMENT_CONTRACTID = "@mozilla.org/process/environment;1";
const NS_OBSERVER_SERVICE_CONTRACTID = "@mozilla.org/observer-service;1";
const NS_GFXINFO_CONTRACTID = "@mozilla.org/gfx/info;1";
const IO_SERVICE_CONTRACTID = "@mozilla.org/network/io-service;1"
@ -107,7 +108,8 @@ function OnInitialLoad()
if (gDebug.isDebugBuild) {
gAssertionCount = gDebug.assertionCount;
}
gVerbose = !!Services.env.get("MOZ_REFTEST_VERBOSE");
var env = Cc[ENVIRONMENT_CONTRACTID].getService(Ci.nsIEnvironment);
gVerbose = !!env.get("MOZ_REFTEST_VERBOSE");
RegisterMessageListeners();

View File

@ -186,6 +186,9 @@ function OnRefTestLoad(win)
g.pendingCrashDumpDir.append("Crash Reports");
g.pendingCrashDumpDir.append("pending");
var env = Cc["@mozilla.org/process/environment;1"].
getService(Ci.nsIEnvironment);
g.browserIsRemote = Services.appinfo.browserTabsRemoteAutostart;
g.browserIsFission = Services.appinfo.fissionAutostart;

View File

@ -11,7 +11,10 @@ const { FileUtils } = ChromeUtils.importESModule(
);
// The xpcshell test harness sets PYTHON so we can read it here.
var gPythonName = Services.env.get("PYTHON");
var gEnv = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
var gPythonName = gEnv.get("PYTHON");
// If we're testing locally, the executable file is in "CurProcD". Otherwise,
// it is in another location that we have to find.
@ -134,7 +137,7 @@ function run_test() {
// in-place (to fix stacks) when it runs dmd.py, and that's not safe to do
// asynchronously.
Services.env.set("DMD", "1");
gEnv.set("DMD", "1");
runProcess(gDmdTestFile, []);

View File

@ -49,7 +49,9 @@ var ChildCrashHandler = {
aSubject.QueryInterface(Ci.nsIPropertyBag2);
const disableReporting = Services.env.get("MOZ_CRASHREPORTER_NO_REPORT");
const disableReporting = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZ_CRASHREPORTER_NO_REPORT");
if (
!aSubject.get("abnormal") ||

View File

@ -77,7 +77,10 @@ var GeckoViewRemoteDebugger = {
//
// If package name isn't available, it will be "@firefox-debugger-socket".
let packageName = Services.env.get("MOZ_ANDROID_PACKAGE_NAME");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let packageName = env.get("MOZ_ANDROID_PACKAGE_NAME");
if (packageName) {
packageName = packageName + "/";
} else {

View File

@ -930,7 +930,10 @@ class NodeServer {
// Issues a request to the node server (handler defined in moz-http2.js)
// This method should not be called directly.
static sendCommand(command, path) {
let h2Port = Services.env.get("MOZNODE_EXEC_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZNODE_EXEC_PORT");
if (!h2Port) {
throw new Error("Could not find MOZNODE_EXEC_PORT");
}

View File

@ -384,13 +384,16 @@ async function asyncStartTLSTestServer(
const CALLBACK_PORT = 8444;
let envSvc = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let greBinDir = Services.dirsvc.get("GreBinD", Ci.nsIFile);
Services.env.set("DYLD_LIBRARY_PATH", greBinDir.path);
envSvc.set("DYLD_LIBRARY_PATH", greBinDir.path);
// TODO(bug 1107794): Android libraries are in /data/local/xpcb, but "GreBinD"
// does not return this path on Android, so hard code it here.
Services.env.set("LD_LIBRARY_PATH", greBinDir.path + ":/data/local/xpcb");
Services.env.set("MOZ_TLS_SERVER_DEBUG_LEVEL", "3");
Services.env.set("MOZ_TLS_SERVER_CALLBACK_PORT", CALLBACK_PORT);
envSvc.set("LD_LIBRARY_PATH", greBinDir.path + ":/data/local/xpcb");
envSvc.set("MOZ_TLS_SERVER_DEBUG_LEVEL", "3");
envSvc.set("MOZ_TLS_SERVER_CALLBACK_PORT", CALLBACK_PORT);
let httpServer = new HttpServer();
let serverReady = new Promise(resolve => {

View File

@ -6,7 +6,11 @@
/* import-globals-from head_cookies.js */
async function http3_setup_tests(http3version) {
let h3Port = Services.env.get("MOZHTTP3_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
let h3Route = "foo.example.com:" + h3Port;

View File

@ -21,7 +21,10 @@ let gDNS;
function trr_test_setup() {
dump("start!\n");
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -24,7 +24,10 @@ var httpBarOrigin; // http://bar.example.com:PORT/
var httpsBarOrigin; // https://bar.example.com:PORT/
function run_test() {
h2Port = Services.env.get("MOZHTTP2_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -20,7 +20,10 @@ var httpBarOrigin; // http://bar.example.com:PORT/
var httpsBarOrigin; // https://bar.example.com:PORT/
function run_test() {
h3Port = Services.env.get("MOZHTTP3_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");

View File

@ -27,7 +27,10 @@ function run_next_test() {
}
function run_test() {
h3Port = Services.env.get("MOZHTTP3_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3AltSvc = ":" + h3Port;

View File

@ -13,7 +13,10 @@ var http2pref;
var extpref;
function run_test() {
h2Port = Services.env.get("MOZHTTP2_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -185,7 +185,9 @@ add_task(async function test_redirect_https() {
Services.prefs.setBoolPref(PREF_CAPTIVE_ENABLED, false);
equal(cps.state, Ci.nsICaptivePortalService.UNKNOWN);
let h2Port = Services.env.get("MOZHTTP2_PORT");
let h2Port = Cc["@mozilla.org/process/environment;1"]
.getService(Ci.nsIEnvironment)
.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -17,7 +17,10 @@ const { TestUtils } = ChromeUtils.import(
);
add_setup(async function setup() {
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -57,7 +57,10 @@ let http2Port;
add_task(async function setup() {
Services.prefs.setCharPref("network.dns.localDomains", "foo.example.com");
http2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
http2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(http2Port, null);
Assert.notEqual(http2Port, "");

View File

@ -37,7 +37,10 @@ function run_test() {
Services.prefs.clearUserPref("network.dns.localDomains");
});
var serverPort = Services.env.get("MOZHTTP2_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
var serverPort = env.get("MOZHTTP2_PORT");
make_and_open_channel(
"https://foo.example.com:" + serverPort + "/server-timing",
readServerContent

View File

@ -100,7 +100,10 @@ add_task(async function setup() {
);
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
let proxy_port = Services.env.get("MOZHTTP2_PORT");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let proxy_port = env.get("MOZHTTP2_PORT");
Assert.notEqual(proxy_port, null);
Services.prefs.setBoolPref("network.http.http2.enabled", true);

View File

@ -356,7 +356,10 @@ add_task(async function setup() {
);
addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
let server_port = Services.env.get("MOZHTTP2_PORT");
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let server_port = env.get("MOZHTTP2_PORT");
Assert.notEqual(server_port, null);
processId = await NodeServer.fork();
await NodeServer.execute(processId, `serverPort = ${server_port}`);

View File

@ -1388,7 +1388,10 @@ function resetPrefs() {
}
function run_test() {
serverPort = Services.env.get("MOZHTTP2_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
serverPort = env.get("MOZHTTP2_PORT");
Assert.notEqual(serverPort, null);
dump("using port " + serverPort + "\n");

View File

@ -56,10 +56,13 @@ function run_next_test() {
}
function run_test() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
let h3Port = Services.env.get("MOZHTTP3_PORT");
let h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3AltSvc = ":" + h3Port;

View File

@ -17,10 +17,13 @@ function run_next_test() {
}
function run_test() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
let h3Port = Services.env.get("MOZHTTP3_PORT");
let h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3AltSvc = ":" + h3Port;

View File

@ -18,10 +18,13 @@ function run_next_test() {
}
function run_test() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
let h3Port = Services.env.get("MOZHTTP3_PORT");
let h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3AltSvc = ":" + h3Port;

View File

@ -17,11 +17,14 @@ const certOverrideService = Cc[
].getService(Ci.nsICertOverrideService);
function setup() {
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
h3Port = Services.env.get("MOZHTTP3_PORT");
h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
Services.prefs.setBoolPref("network.http.http3.enable", true);

View File

@ -26,9 +26,13 @@ function makeChan() {
}
add_task(async function test_setup() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
let h3Port = Services.env.get("MOZHTTP3_PORT_NO_RESPONSE");
let h3Port = env.get("MOZHTTP3_PORT_NO_RESPONSE");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");

View File

@ -24,11 +24,14 @@ const certOverrideService = Cc[
].getService(Ci.nsICertOverrideService);
add_setup(async function setup() {
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
h3Port = Services.env.get("MOZHTTP3_PORT_NO_RESPONSE");
h3Port = env.get("MOZHTTP3_PORT_NO_RESPONSE");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");

View File

@ -62,10 +62,14 @@ function altsvcSetupPromise(chan, listener) {
}
add_task(async function test_fatal_error() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
let h3Port = Services.env.get("MOZHTTP3_PORT_FAILED");
let h3Port = env.get("MOZHTTP3_PORT_FAILED");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");

View File

@ -62,10 +62,13 @@ function run_next_test() {
// eslint-disable-next-line no-unused-vars
function run_test() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
let h3Port = Services.env.get("MOZHTTP3_PORT");
let h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3AltSvc = ":" + h3Port;

View File

@ -36,7 +36,11 @@ function altsvcSetupPromise(chan, listener) {
}
add_task(async function test_fatal_error() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Services.prefs.setBoolPref("network.http.http3.enable", true);

View File

@ -10,7 +10,11 @@ registerCleanupFunction(async () => {
let httpsUri;
add_task(async function pre_setup() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
httpsUri = "https://foo.example.com:" + h2Port + "/";

View File

@ -62,7 +62,10 @@ let cancelDuringOnStartListener = {
var uri = ios.newURI("http://site3.com/");
// Need to set NECKO_ERRORS_ARE_FATAL=0 else we'll abort process
Services.env.set("NECKO_ERRORS_ARE_FATAL", "0");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("NECKO_ERRORS_ARE_FATAL", "0");
// we expect setting referrer to fail
try {
request.referrerInfo = new ReferrerInfo(

View File

@ -12,6 +12,10 @@ const certOverrideService = Cc[
"@mozilla.org/security/certoverride;1"
].getService(Ci.nsICertOverrideService);
const env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
function setup() {
// Allow telemetry probes which may otherwise be disabled for some
// applications (e.g. Thunderbird).
@ -30,7 +34,7 @@ function setup() {
Services.prefs.setIntPref("network.trr.mode", Ci.nsIDNSService.MODE_TRRONLY);
// Set the server to always select http/1.1
Services.env.set("MOZ_TLS_ECH_ALPN_FLAG", 1);
env.set("MOZ_TLS_ECH_ALPN_FLAG", 1);
add_tls_server_setup(
"EncryptedClientHelloServer",
@ -50,7 +54,7 @@ registerCleanupFunction(async () => {
Services.prefs.clearUserPref("network.dns.echconfig.fallback_to_origin");
Services.prefs.clearUserPref("network.http.speculative-parallel-limit");
Services.prefs.clearUserPref("network.dns.port_prefixed_qname_https_rr");
Services.env.set("MOZ_TLS_ECH_ALPN_FLAG", "");
env.set("MOZ_TLS_ECH_ALPN_FLAG", "");
if (trrServer) {
await trrServer.stop();
}

View File

@ -21,7 +21,10 @@ const { TestUtils } = ChromeUtils.import(
add_setup(async function setup() {
trr_test_setup();
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -20,7 +20,10 @@ const { TestUtils } = ChromeUtils.import(
);
add_setup(async function setup() {
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -56,11 +56,14 @@ function setup() {
"../../../security/manager/ssl/tests/unit/test_encrypted_client_hello"
);
h3Port = Services.env.get("MOZHTTP3_PORT_ECH");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h3Port = env.get("MOZHTTP3_PORT_ECH");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3EchConfig = Services.env.get("MOZHTTP3_ECH");
h3EchConfig = env.get("MOZHTTP3_ECH");
Assert.notEqual(h3EchConfig, null);
Assert.notEqual(h3EchConfig, "");
}

View File

@ -6,7 +6,10 @@ var origin;
var rcwnpref;
function run_test() {
var h2Port = Services.env.get("MOZHTTP2_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
var h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -23,7 +23,10 @@ function setup() {
Services.prefs.setIntPref("network.max_socket_process_failed_count", 2);
trr_test_setup();
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -7,7 +7,10 @@ var extpref;
var loadGroup;
function run_test() {
h2Port = Services.env.get("MOZHTTP2_PORT");
var env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

View File

@ -28,7 +28,10 @@ async function get_response(channel, fromCache) {
add_task(async function() {
do_get_profile();
const PORT = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
const PORT = env.get("MOZHTTP2_PORT");
const URI = `https://localhost:${PORT}/stale-while-revalidate-loop-test`;
let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(

View File

@ -10,7 +10,11 @@ registerCleanupFunction(async () => {
let httpsUri;
add_task(async function setup() {
let h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
let h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
httpsUri = "https://foo.example.com:" + h2Port + "/";

View File

@ -24,15 +24,18 @@ const certOverrideService = Cc[
add_setup(async function setup() {
trr_test_setup();
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");
h3Port = Services.env.get("MOZHTTP3_PORT");
h3Port = env.get("MOZHTTP3_PORT");
Assert.notEqual(h3Port, null);
Assert.notEqual(h3Port, "");
h3NoResponsePort = Services.env.get("MOZHTTP3_PORT_NO_RESPONSE");
h3NoResponsePort = env.get("MOZHTTP3_PORT_NO_RESPONSE");
Assert.notEqual(h3NoResponsePort, null);
Assert.notEqual(h3NoResponsePort, "");

View File

@ -26,7 +26,10 @@ add_setup(async function setup() {
}
trr_test_setup();
h2Port = Services.env.get("MOZHTTP2_PORT");
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
h2Port = env.get("MOZHTTP2_PORT");
Assert.notEqual(h2Port, null);
Assert.notEqual(h2Port, "");

Some files were not shown because too many files have changed in this diff Show More