Bug 1551072 - Need xpcshell check in addition to automation. r=Felipe a=aryx FIREFOX_BETA_68_BASE
authorMichael Kaply <mozilla@kaply.com>
Mon, 13 May 2019 01:21:40 +0000
changeset 532389 390914f7108f4f6065834d8983af9ac855cbf2df
parent 532388 fa3cfee27619ddc9bcbcf70555bda4eb1e815146
child 532390 cb5734727c0a9d88e3e236a3e4a741a051509e0e
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, aryx
bugs1551072
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551072 - Need xpcshell check in addition to automation. r=Felipe a=aryx Differential Revision: https://phabricator.services.mozilla.com/D30812
toolkit/components/enterprisepolicies/EnterprisePolicies.js
--- a/toolkit/components/enterprisepolicies/EnterprisePolicies.js
+++ b/toolkit/components/enterprisepolicies/EnterprisePolicies.js
@@ -39,16 +39,19 @@ XPCOMUtils.defineLazyGetter(this, "log",
     prefix: "Enterprise Policies",
     // tip: set maxLogLevel to "debug" and use log.debug() to create detailed
     // messages during development. See LOG_LEVELS in Console.jsm for details.
     maxLogLevel: "error",
     maxLogLevelPref: PREF_LOGLEVEL,
   });
 });
 
+let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
+const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
+
 function EnterprisePoliciesManager() {
   Services.obs.addObserver(this, "profile-after-change", true);
   Services.obs.addObserver(this, "final-ui-startup", true);
   Services.obs.addObserver(this, "sessionstore-windows-restored", true);
   Services.obs.addObserver(this, "EnterprisePolicies:Restart", true);
 }
 
 EnterprisePoliciesManager.prototype = {
@@ -331,17 +334,17 @@ function areEnterpriseOnlyPoliciesAllowe
   if (Services.prefs.getBoolPref(PREF_DISALLOW_ENTERPRISE, false)) {
     // This is used as an override to test the "enterprise_only"
     // functionality itself on tests, which would always return
     // true due to the Cu.isInAutomation check below.
     return false;
   }
 
   if (AppConstants.MOZ_UPDATE_CHANNEL != "release" ||
-      Cu.isInAutomation) {
+      Cu.isInAutomation || isXpcshell) {
     return true;
   }
 
   return false;
 }
 
 /*
  * JSON PROVIDER OF POLICIES
@@ -383,17 +386,17 @@ class JSONPoliciesProvider {
     let alternatePath = Services.prefs.getStringPref(PREF_ALTERNATE_PATH, "");
 
     // Check if we are in automation *before* we use the synchronous
     // nsIFile.exists() function or allow the config file to be overriden
     // An alternate policy path can also be used in Nightly builds (for
     // testing purposes), but the Background Update Agent will be unable to
     // detect the alternate policy file so the DisableAppUpdate policy may not
     // work as expected.
-    if (alternatePath && (Cu.isInAutomation || AppConstants.NIGHTLY_BUILD) &&
+    if (alternatePath && (Cu.isInAutomation || AppConstants.NIGHTLY_BUILD || isXpcshell) &&
         (!configFile || !configFile.exists())) {
       if (alternatePath.startsWith(MAGIC_TEST_ROOT_PREFIX)) {
         // Intentionally not using a default value on this pref lookup. If no
         // test root is set, we are not currently testing and this function
         // should throw rather than returning something.
         let testRoot = Services.prefs.getStringPref(PREF_TEST_ROOT);
         let relativePath = alternatePath.substring(MAGIC_TEST_ROOT_PREFIX.length);
         if (AppConstants.platform == "win") {