Skip to content

Commit

Permalink
Backed out 19 changesets (bug 1541508) for causing xpcshell failures …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
Cristian Tuns committed Nov 2, 2022
1 parent 39ca7d2 commit 4d37cf7
Show file tree
Hide file tree
Showing 194 changed files with 995 additions and 371 deletions.
6 changes: 5 additions & 1 deletion browser/base/content/browser-development-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion browser/base/content/safeMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
22 changes: 14 additions & 8 deletions browser/base/content/test/tabcrashed/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
5 changes: 4 additions & 1 deletion browser/components/StartupRecorder.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 9 additions & 3 deletions browser/components/attribution/AttributionCode.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
},
Expand Down
7 changes: 5 additions & 2 deletions browser/components/attribution/test/browser/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
5 changes: 4 additions & 1 deletion browser/components/doh/test/unit/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");

Expand Down
5 changes: 4 additions & 1 deletion browser/components/enterprisepolicies/Policies.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 5 additions & 2 deletions browser/components/migration/FirefoxProfileMigrator.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 11 additions & 6 deletions browser/components/migration/content/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,18 +621,18 @@ def doReset(self):
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,
Expand Down
5 changes: 4 additions & 1 deletion browser/components/newtab/lib/ASRouter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down
4 changes: 2 additions & 2 deletions browser/components/urlbar/tests/browser-tips/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion browser/modules/ContentCrashHandlers.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -255,7 +258,7 @@ add_setup(async function() {

registerCleanupFunction(function() {
clearPendingCrashReports();
Services.env.set("MOZ_CRASHREPORTER_URL", oldServerURL);
env.set("MOZ_CRASHREPORTER_URL", oldServerURL);
});
});

Expand Down
5 changes: 4 additions & 1 deletion browser/tools/mozscreenshots/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down Expand Up @@ -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 " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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/")) {
Expand Down
Loading

0 comments on commit 4d37cf7

Please sign in to comment.