Bug 1460086 - Disable pref: browser.policies.alternatePath except in testing and Nightly
MozReview-Commit-ID: GA5Ntp7izPl
--- 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, "\\");