Bug 1548684 - Move enterprise tests to xpcshell. r=zombie
authorMichael Kaply <mozilla@kaply.com>
Sat, 11 May 2019 19:37:35 +0000
changeset 532341 93a5696c543140dce1f640adeace24d322ad1837
parent 532340 4440662cd0177f3fc3200cff190daed47d71a167
child 532342 c7646277eaf2befffa92853d2fce162ee1300007
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)
reviewerszombie
bugs1548684
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 1548684 - Move enterprise tests to xpcshell. r=zombie Differential Revision: https://phabricator.services.mozilla.com/D29757
browser/components/enterprisepolicies/tests/browser/browser.ini
browser/components/enterprisepolicies/tests/browser/browser_policies_macosparser_unflatten.js
browser/components/enterprisepolicies/tests/browser/browser_policies_popups_cookies_addons_flash.js
browser/components/enterprisepolicies/tests/browser/browser_policies_runOnce_helper.js
browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
browser/components/enterprisepolicies/tests/browser/browser_policies_sorted_alphabetically.js
browser/components/enterprisepolicies/tests/browser/browser_policy_3rdparty.js
browser/components/enterprisepolicies/tests/browser/browser_policy_app_update_URL.js
browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
browser/components/enterprisepolicies/tests/browser/browser_policy_default_browser_check.js
browser/components/enterprisepolicies/tests/browser/browser_policy_locale.js
browser/components/enterprisepolicies/tests/browser/browser_policy_permissions.js
browser/components/enterprisepolicies/tests/browser/browser_policy_preferences.js
browser/components/enterprisepolicies/tests/browser/browser_policy_proxy.js
browser/components/enterprisepolicies/tests/browser/config_popups_cookies_addons_flash.json
browser/components/enterprisepolicies/tests/moz.build
browser/components/enterprisepolicies/tests/xpcshell/config_popups_cookies_addons_flash.json
browser/components/enterprisepolicies/tests/xpcshell/head.js
browser/components/enterprisepolicies/tests/xpcshell/test_3rdparty.js
browser/components/enterprisepolicies/tests/xpcshell/test_appupdateurl.js
browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js
browser/components/enterprisepolicies/tests/xpcshell/test_defaultbrowsercheck.js
browser/components/enterprisepolicies/tests/xpcshell/test_macosparser_unflatten.js
browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js
browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js
browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js
browser/components/enterprisepolicies/tests/xpcshell/test_proxy.js
browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js
browser/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js
browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js
browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js
browser/components/enterprisepolicies/tests/xpcshell/xpcshell.ini
toolkit/components/enterprisepolicies/EnterprisePolicies.js
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -1,42 +1,32 @@
 [DEFAULT]
 support-files =
   head.js
-  config_popups_cookies_addons_flash.json
   opensearch.html
   opensearchEngine.xml
   policytest_v0.1.xpi
   policytest_v0.2.xpi
   policy_websitefilter_block.html
   policy_websitefilter_exception.html
   ../../../../../toolkit/components/antitracking/test/browser/page.html
   ../../../../../toolkit/components/antitracking/test/browser/subResources.sjs
 
 [browser_policies_getActivePolicies.js]
-[browser_policies_macosparser_unflatten.js]
 skip-if = os != 'mac'
 [browser_policies_notice_in_aboutpreferences.js]
-[browser_policies_popups_cookies_addons_flash.js]
-[browser_policies_runOnce_helper.js]
 [browser_policies_setAndLockPref_API.js]
-[browser_policies_simple_pref_policies.js]
-[browser_policies_sorted_alphabetically.js]
-[browser_policy_3rdparty.js]
 [browser_policy_app_update.js]
-[browser_policy_app_update_URL.js]
 [browser_policy_block_about_addons.js]
 [browser_policy_block_about_config.js]
 [browser_policy_block_about_profiles.js]
 [browser_policy_block_about_support.js]
 [browser_policy_block_set_desktop_background.js]
 [browser_policy_bookmarks.js]
-[browser_policy_clear_blocked_cookies.js]
 [browser_policy_cookie_settings.js]
-[browser_policy_default_browser_check.js]
 [browser_policy_disable_feedback_commands.js]
 [browser_policy_disable_flash_plugin.js]
 skip-if = (processor == 'aarch64' && os == 'win') # aarch64 due to 1538785
 [browser_policy_disable_fxaccounts.js]
 skip-if = (verify && debug && (os == 'mac'))
 [browser_policy_disable_masterpassword.js]
 [browser_policy_disable_pocket.js]
 [browser_policy_disable_popup_blocker.js]
@@ -46,19 +36,15 @@ skip-if = (verify && debug && (os == 'ma
 [browser_policy_disable_safemode.js]
 [browser_policy_disable_shield.js]
 [browser_policy_disable_telemetry.js]
 [browser_policy_display_bookmarks.js]
 [browser_policy_display_menu.js]
 [browser_policy_extensions.js]
 [browser_policy_downloads.js]
 [browser_policy_extensionsettings.js]
-[browser_policy_locale.js]
 [browser_policy_firefoxhome.js]
 [browser_policy_override_postupdatepage.js]
-[browser_policy_permissions.js]
-[browser_policy_proxy.js]
-[browser_policy_preferences.js]
 [browser_policy_search_engine.js]
 [browser_policy_searchbar.js]
 [browser_policy_set_homepage.js]
 [browser_policy_support_menu.js]
 [browser_policy_websitefilter.js]
--- a/browser/components/enterprisepolicies/tests/moz.build
+++ b/browser/components/enterprisepolicies/tests/moz.build
@@ -8,8 +8,10 @@ BROWSER_CHROME_MANIFESTS += [
     'browser/browser.ini',
     'browser/disable_app_update/browser.ini',
     'browser/disable_default_bookmarks/browser.ini',
     'browser/disable_developer_tools/browser.ini',
     'browser/disable_forget_button/browser.ini',
     'browser/disable_fxscreenshots/browser.ini',
     'browser/hardware_acceleration/browser.ini',
 ]
+
+XPCSHELL_TESTS_MANIFESTS += ['xpcshell/xpcshell.ini']
rename from browser/components/enterprisepolicies/tests/browser/config_popups_cookies_addons_flash.json
rename to browser/components/enterprisepolicies/tests/xpcshell/config_popups_cookies_addons_flash.json
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/xpcshell/head.js
@@ -0,0 +1,61 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
+const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
+const {Preferences} = ChromeUtils.import("resource://gre/modules/Preferences.jsm");
+const {FileTestUtils} = ChromeUtils.import("resource://testing-common/FileTestUtils.jsm");
+
+// This initializes the policy engine for xpcshell tests
+let policies = Cc["@mozilla.org/enterprisepolicies;1"].getService(Ci.nsIObserver);
+policies.observe(null, "policies-startup", null);
+
+// Any changes to this function should also be made to the corresponding version
+// in browser/components/enterprisepolicies/tests/browser/head.js
+async function setupPolicyEngineWithJson(json, customSchema) {
+  let filePath;
+  if (typeof(json) == "object") {
+    filePath = FileTestUtils.getTempFile("policies.json").path;
+
+    // This file gets automatically deleted by FileTestUtils
+    // at the end of the test run.
+    await OS.File.writeAtomic(filePath, JSON.stringify(json), {
+      encoding: "utf-8",
+    });
+  } else {
+    filePath = do_get_file(json ? json : "non-existing-file.json").path;
+  }
+
+  Services.prefs.setStringPref("browser.policies.alternatePath", filePath);
+
+  let promise = new Promise(resolve => {
+    Services.obs.addObserver(function observer() {
+      Services.obs.removeObserver(observer, "EnterprisePolicies:AllPoliciesApplied");
+      resolve();
+    }, "EnterprisePolicies:AllPoliciesApplied");
+  });
+
+  // Clear any previously used custom schema
+  Cu.unload("resource:///modules/policies/schema.jsm");
+
+  if (customSchema) {
+    let schemaModule = ChromeUtils.import("resource:///modules/policies/schema.jsm", null);
+    schemaModule.schema = customSchema;
+  }
+
+  Services.obs.notifyObservers(null, "EnterprisePolicies:Restart");
+  return promise;
+}
+
+function checkLockedPref(prefName, prefValue) {
+  equal(Preferences.locked(prefName), true, `Pref ${prefName} is correctly locked`);
+  equal(Preferences.get(prefName), prefValue, `Pref ${prefName} has the correct value`);
+}
+
+function checkUnlockedPref(prefName, prefValue) {
+  equal(Preferences.locked(prefName), false, `Pref ${prefName} is correctly unlocked`);
+  equal(Preferences.get(prefName), prefValue, `Pref ${prefName} has the correct value`);
+}
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_3rdparty.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_3rdparty.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_3rdparty.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_3rdparty.js
@@ -11,10 +11,10 @@ add_task(async function setup() {
                                             "string": "value",
                                           },
                                         },
                                       },
                                     },
                                   });
 
   let extensionPolicy = Services.policies.getExtensionPolicy("3rdparty-policy@mozilla.com");
-  Assert.deepEqual(extensionPolicy, {"string": "value"});
+  deepEqual(extensionPolicy, {"string": "value"});
 });
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_app_update_URL.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_appupdateurl.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_app_update_URL.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_appupdateurl.js
@@ -5,15 +5,15 @@
 
 add_task(async function test_app_update_URL() {
   await setupPolicyEngineWithJson({
     "policies": {
       "AppUpdateURL": "https://www.example.com/",
     },
   });
 
-  is(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
+  equal(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
 
   // The app.update.url preference is read from the default preferences.
   let expected = Services.prefs.getDefaultBranch(null).getCharPref("app.update.url", undefined);
 
-  is("https://www.example.com/", expected, "Correct app update URL");
+  equal("https://www.example.com/", expected, "Correct app update URL");
 });
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_clear_blocked_cookies.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_clear_blocked_cookies.js
@@ -46,17 +46,17 @@ add_task(async function test_cookies_for
     hostname: [],
     origin: [],
     keep: [
       {host: "example.net",
        name: "secure",
        path: "/"},
     ],
   };
-  is(JSON.stringify(cookies), JSON.stringify(expected),
+  equal(JSON.stringify(cookies), JSON.stringify(expected),
      "All stored cookies for blocked origins should be cleared");
 });
 
 add_task(function teardown() {
   for (let host of [HOSTNAME_DOMAIN, ORIGIN_DOMAIN, "example.net"]) {
     Services.cookies.removeCookiesWithOriginAttributes("{}", host);
   }
 });
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_default_browser_check.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_defaultbrowsercheck.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_default_browser_check.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_defaultbrowsercheck.js
@@ -5,38 +5,38 @@
 const { ShellService } = ChromeUtils.import("resource:///modules/ShellService.jsm");
 
 add_task(async function test_default_browser_check() {
   ShellService._checkedThisSession = false;
   // On a normal profile, the default is true. However, this gets set to false on the
   // testing profile. Let's start with true for a sanity check.
 
   ShellService.shouldCheckDefaultBrowser = true;
-  is(ShellService.shouldCheckDefaultBrowser, true, "Sanity check");
+  equal(ShellService.shouldCheckDefaultBrowser, true, "Sanity check");
 
   await setupPolicyEngineWithJson({
     "policies": {
       "DontCheckDefaultBrowser": true,
     },
   });
 
-  is(ShellService.shouldCheckDefaultBrowser, false, "Policy changed it to not check");
+  equal(ShellService.shouldCheckDefaultBrowser, false, "Policy changed it to not check");
 
   // Try to change it to true and check that it doesn't take effect
   ShellService.shouldCheckDefaultBrowser = true;
 
-  is(ShellService.shouldCheckDefaultBrowser, false, "Policy is enforced");
+  equal(ShellService.shouldCheckDefaultBrowser, false, "Policy is enforced");
 });
 
 add_task(async function test_default_browser_check() {
   await setupPolicyEngineWithJson({
     "policies": {
       "DontCheckDefaultBrowser": false,
     },
   });
 
-  is(ShellService.shouldCheckDefaultBrowser, true, "Policy changed it to check");
+  equal(ShellService.shouldCheckDefaultBrowser, true, "Policy changed it to check");
 
   // Try to change it to false and check that it doesn't take effect
   ShellService.shouldCheckDefaultBrowser = false;
 
-  is(ShellService.shouldCheckDefaultBrowser, true, "Policy is enforced");
+  equal(ShellService.shouldCheckDefaultBrowser, true, "Policy is enforced");
 });
rename from browser/components/enterprisepolicies/tests/browser/browser_policies_macosparser_unflatten.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_macosparser_unflatten.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_macosparser_unflatten.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_macosparser_unflatten.js
@@ -90,31 +90,31 @@ add_task(async function test_object_unfl
         "URL": "https://bookmark2.example.com",
         "Folder": "Folder",
       },
     ],
   };
 
   let unflattened = macOSPoliciesParser.unflatten(input);
 
-  Assert.deepEqual(unflattened, expected, "Input was unflattened correctly.");
+  deepEqual(unflattened, expected, "Input was unflattened correctly.");
 });
 
 add_task(async function test_array_unflatten() {
   let input = {
     "Foo__1": 1,
     "Foo__5": 5,
     "Foo__10": 10,
     "Foo__30": 30,
     "Foo__51": 51, // This one should not be included as the limit is 50
   };
 
   let unflattened = macOSPoliciesParser.unflatten(input);
-  is(unflattened.Foo.length, 31, "Array size is correct");
+  equal(unflattened.Foo.length, 31, "Array size is correct");
 
   let expected = {
     Foo: [, 1, , , , 5], // eslint-disable-line no-sparse-arrays
   };
   expected.Foo[10] = 10;
   expected.Foo[30] = 30;
 
-  Assert.deepEqual(unflattened, expected, "Array was unflattened correctly.");
+  deepEqual(unflattened, expected, "Array was unflattened correctly.");
 });
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_permissions.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_permissions.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_permissions.js
@@ -94,32 +94,32 @@ add_task(async function test_setup_activ
           "Block": [
             "https://www.deny.com",
             "https://www.pre-existing-allow.com",
           ],
         },
       },
     },
   });
-  is(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
+  equal(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
 });
 
 function checkPermission(url, expected, permissionName) {
   let expectedValue = Ci.nsIPermissionManager[`${expected}_ACTION`];
   let uri = Services.io.newURI(`https://www.${url}`);
 
-  is(Services.perms.testPermission(uri, permissionName),
+  equal(Services.perms.testPermission(uri, permissionName),
     expectedValue,
     `Correct (${permissionName}=${expected}) for URL ${url}`);
 
   if (expected != "UNKNOWN") {
     let permission = Services.perms.getPermissionObjectForURI(
       uri, permissionName, true);
     ok(permission, "Permission object exists");
-    is(permission.expireType, Ci.nsIPermissionManager.EXPIRE_POLICY,
+    equal(permission.expireType, Ci.nsIPermissionManager.EXPIRE_POLICY,
        "Permission expireType is correct");
   }
 }
 
 function checkAllPermissionsForType(type, typeSupportsDeny = true) {
   checkPermission("allow.com", "ALLOW", type);
   checkPermission("unknown.com", "UNKNOWN", type);
   checkPermission("pre-existing-deny.com", "ALLOW", type);
rename from browser/components/enterprisepolicies/tests/browser/browser_policies_popups_cookies_addons_flash.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_popups_cookies_addons_flash.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_popups_cookies_addons_flash.js
@@ -44,32 +44,32 @@ add_task(async function test_setup_preex
   Services.perms.add(URI("https://www.pre-existing-deny.com"),
                      "plugin:flash",
                      Ci.nsIPermissionManager.DENY_ACTION,
                      Ci.nsIPermissionManager.EXPIRE_SESSION);
 });
 
 add_task(async function test_setup_activate_policies() {
   await setupPolicyEngineWithJson("config_popups_cookies_addons_flash.json");
-  is(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
+  equal(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
 });
 
 function checkPermission(url, expected, permissionName) {
   let expectedValue = Ci.nsIPermissionManager[`${expected}_ACTION`];
   let uri = Services.io.newURI(`https://www.${url}`);
 
-  is(Services.perms.testPermission(uri, permissionName),
+  equal(Services.perms.testPermission(uri, permissionName),
     expectedValue,
     `Correct (${permissionName}=${expected}) for URL ${url}`);
 
   if (expected != "UNKNOWN") {
     let permission = Services.perms.getPermissionObjectForURI(
       uri, permissionName, true);
     ok(permission, "Permission object exists");
-    is(permission.expireType, Ci.nsIPermissionManager.EXPIRE_POLICY,
+    equal(permission.expireType, Ci.nsIPermissionManager.EXPIRE_POLICY,
        "Permission expireType is correct");
   }
 }
 
 function checkAllPermissionsForType(type, typeSupportsDeny = true) {
   checkPermission("allow.com", "ALLOW", type);
   checkPermission("unknown.com", "UNKNOWN", type);
   checkPermission("pre-existing-deny.com", "ALLOW", type);
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_preferences.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_preferences.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js
@@ -13,10 +13,10 @@ add_task(async function test_policy_pref
       "Preferences": {
         "network.IDN_show_punycode": true,
         "app.update.log": true,
       },
     },
   });
 
   checkLockedPref("network.IDN_show_punycode", true);
-  is(Services.prefs.getBoolPref("app.update.log"), false, "Disallowed pref was not been changed");
+  equal(Services.prefs.getBoolPref("app.update.log"), false, "Disallowed pref was not been changed");
  });
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_proxy.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_proxy.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_proxy.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_proxy.js
@@ -7,23 +7,23 @@ add_task(async function test_proxy_modes
   // the API instead of the policy engine, because the test harness
   // uses these prefs, and changing them interfere with the harness.
 
   // Checks that every Mode value translates correctly to the expected pref value
   let { ProxyPolicies, PROXY_TYPES_MAP } = ChromeUtils.import("resource:///modules/policies/ProxyPolicies.jsm", null);
 
   for (let [mode, expectedValue] of PROXY_TYPES_MAP) {
     ProxyPolicies.configureProxySettings({Mode: mode}, (_, value) => {
-      is(value, expectedValue, "Correct proxy mode");
+      equal(value, expectedValue, "Correct proxy mode");
     });
   }
 
   let autoconfigURL = new URL("data:text/plain,test");
   ProxyPolicies.configureProxySettings({AutoConfigURL: autoconfigURL}, (_, value) => {
-    is(value, autoconfigURL.href, "AutoconfigURL correctly set");
+    equal(value, autoconfigURL.href, "AutoconfigURL correctly set");
   });
 });
 
 add_task(async function test_proxy_boolean_settings() {
   // Tests that both false and true values are correctly set and locked
   await setupPolicyEngineWithJson({
     "policies": {
       "Proxy": {
rename from browser/components/enterprisepolicies/tests/browser/browser_policy_locale.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policy_locale.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_requestedlocales.js
@@ -7,17 +7,17 @@ const REQ_LOC_CHANGE_EVENT = "intl:reque
 
 function promiseLocaleChanged(requestedLocale) {
   return new Promise(resolve => {
     let localeObserver = {
       observe(aSubject, aTopic, aData) {
         switch (aTopic) {
           case REQ_LOC_CHANGE_EVENT:
             let reqLocs = Services.locale.requestedLocales;
-            is(reqLocs[0], requestedLocale);
+            equal(reqLocs[0], requestedLocale);
             Services.obs.removeObserver(localeObserver, REQ_LOC_CHANGE_EVENT);
             resolve();
         }
       },
     };
     Services.obs.addObserver(localeObserver, REQ_LOC_CHANGE_EVENT);
   });
 }
rename from browser/components/enterprisepolicies/tests/browser/browser_policies_runOnce_helper.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_runOnce_helper.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_runOnce_helper.js
@@ -7,13 +7,13 @@ let { runOnce } = ChromeUtils.import("re
 
 let runCount = 0;
 function callback() {
   runCount++;
 }
 
 add_task(async function test_runonce_helper() {
   runOnce("test_action", callback);
-  is(runCount, 1, "Callback ran for the first time.");
+  equal(runCount, 1, "Callback ran for the first time.");
 
   runOnce("test_action", callback);
-  is(runCount, 1, "Callback didn't run again.");
+  equal(runCount, 1, "Callback didn't run again.");
 });
rename from browser/components/enterprisepolicies/tests/browser/browser_policies_simple_pref_policies.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_simple_pref_policies.js
rename from browser/components/enterprisepolicies/tests/browser/browser_policies_sorted_alphabetically.js
rename to browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js
--- a/browser/components/enterprisepolicies/tests/browser/browser_policies_sorted_alphabetically.js
+++ b/browser/components/enterprisepolicies/tests/xpcshell/test_sorted_alphabetically.js
@@ -21,10 +21,10 @@ add_task(async function test_policies_so
   let { Policies } = ChromeUtils.import("resource:///modules/policies/Policies.jsm");
 
   checkArrayIsSorted(Object.keys(schema.properties), "policies-schema.json is alphabetically sorted.");
   checkArrayIsSorted(Object.keys(Policies), "Policies.jsm is alphabetically sorted.");
 });
 
 add_task(async function check_naming_conventions() {
   let { schema } = ChromeUtils.import("resource:///modules/policies/schema.jsm");
-  is(Object.keys(schema.properties).some(key => key.includes("__")), false, "Can't use __ in a policy name as it's used as a delimiter");
+  equal(Object.keys(schema.properties).some(key => key.includes("__")), false, "Can't use __ in a policy name as it's used as a delimiter");
 });
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/xpcshell/xpcshell.ini
@@ -0,0 +1,19 @@
+[DEFAULT]
+firefox-appdir = browser
+head = head.js
+
+[test_3rdparty.js]
+[test_appupdateurl.js]
+[test_clear_blocked_cookies.js]
+[test_defaultbrowsercheck.js]
+[test_macosparser_unflatten.js]
+skip-if = os != 'mac'
+[test_permissions.js]
+[test_popups_cookies_addons_flash.js]
+support-files = config_popups_cookies_addons_flash.json
+[test_preferences.js]
+[test_proxy.js]
+[test_requestedlocales.js]
+[test_runOnce_helper.js]
+[test_simple_pref_policies.js]
+[test_sorted_alphabetically.js]
--- a/toolkit/components/enterprisepolicies/EnterprisePolicies.js
+++ b/toolkit/components/enterprisepolicies/EnterprisePolicies.js
@@ -169,20 +169,16 @@ EnterprisePoliciesManager.prototype = {
         callback();
       } catch (ex) {
         log.error("Error running ", callback, `for ${timing}:`, ex);
       }
     }
   },
 
   async _restart() {
-    if (!Cu.isInAutomation) {
-      return;
-    }
-
     DisallowedFeatures = {};
 
     Services.ppmm.sharedData.delete("EnterprisePolicies:Status");
     Services.ppmm.sharedData.delete("EnterprisePolicies:DisallowedFeatures");
 
     this._status = Ci.nsIEnterprisePolicies.UNINITIALIZED;
     for (let timing of Object.keys(this._callbacks)) {
       this._callbacks[timing] = [];
@@ -410,18 +406,23 @@ class JSONPoliciesProvider {
                      .createInstance(Ci.nsIFile);
       configFile.initWithPath(alternatePath);
     }
 
     return configFile;
   }
 
   _readData() {
+    let configFile = this._getConfigurationFile();
+    if (!configFile) {
+      // Do nothing, _policies will remain null
+      return;
+    }
     try {
-      let data = Cu.readUTF8File(this._getConfigurationFile());
+      let data = Cu.readUTF8File(configFile);
       if (data) {
         this._policies = JSON.parse(data).policies;
 
         if (!this._policies) {
           log.error("Policies file doesn't contain a 'policies' object");
           this._failed = true;
         }
       }