Bug 1460086 - Disable pref: browser.policies.alternatePath except in testing and Nightly draft
authorKirk Steuber <ksteuber@mozilla.com>
Tue, 22 May 2018 14:54:25 -0700
changeset 799448 c887639a74b6b6403afd63e21a7f6565135d6d9a
parent 798084 b75acf9652937ce79a9bf02de843c100db0e5ec7
push id111054
push userbmo:ksteuber@mozilla.com
push dateThu, 24 May 2018 17:24:11 +0000
bugs1460086
milestone62.0a1
Bug 1460086 - Disable pref: browser.policies.alternatePath except in testing and Nightly 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, "\\");