Bug 1460086 - Disable pref: browser.policies.alternatePath except in testing and Nightly r=Felipe,mkaply
authorKirk Steuber <ksteuber@mozilla.com>
Tue, 22 May 2018 14:54:25 -0700
changeset 420446 c2ac7dded317abfb28772626bd8368a217c5091f
parent 420445 f8369de48c34d6b6eb3d147785aed27474a24e0d
child 420447 e8eb0005b50cbcd82856604682d8dfceb7be1ab7
push id34072
push useraiakab@mozilla.com
push dateWed, 30 May 2018 22:00:19 +0000
treeherdermozilla-central@6272dd5e7417 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, mkaply
bugs1460086
milestone62.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 1460086 - Disable pref: browser.policies.alternatePath except in testing and Nightly r=Felipe,mkaply MozReview-Commit-ID: GA5Ntp7izPl
browser/components/enterprisepolicies/EnterprisePolicies.js
--- a/browser/components/enterprisepolicies/EnterprisePolicies.js
+++ b/browser/components/enterprisepolicies/EnterprisePolicies.js
@@ -365,22 +365,24 @@ class JSONPoliciesProvider {
       configFile.append(POLICIES_FILENAME);
     } catch (ex) {
       // Getting the correct directory will fail in xpcshell tests. This should
       // be handled the same way as if the configFile simply does not exist.
     }
 
     let alternatePath = Services.prefs.getStringPref(PREF_ALTERNATE_PATH, "");
 
-    if (alternatePath && (!configFile || !configFile.exists())) {
-      // We only want to use the alternate file path if the file on the install
-      // folder doesn't exist. Otherwise it'd be possible for a user to override
-      // the admin-provided policies by changing the user-controlled prefs.
-      // This pref is only meant for tests, so it's fine to use this extra
-      // synchronous configFile.exists() above.
+    // 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) &&
+        (!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") {
           relativePath = relativePath.replace(/\//g, "\\");