From MozillaWiki
Jump to: navigation, search

This page documents how to test the Enterprise Policies Manager

Prefs to enable

Please set these two prefs to test this feature:

browser.policies.enabled = true = true

Note: the browser.policies.enabled pref doesn't exist and will need to be created (as a Boolean pref).

Adding the policies.json file

To test this feature (once enabled), you'll need to create a policies.json file (example files are given below), and to put it in a specific location in the installation directory of Firefox (not the profile directory).

Since this location varies by platform and by install type (local build, try build, installed with the installer, etc.), the easier way to figure out the location is by running the following code Snippet in the Browser Console:

Services.dirsvc.get("XREAppDist", Ci.nsIFile).path

Per-platform examples

(these may be different depending on how you installed the try build, so I recommend running the snippet above). These are for illustration purposes only.

  • Mac: /Applications/
  • Windows: C:\Program Files (x86)\Mozilla Firefox\distribution

Checking the status of the engine

Soon, this status will be exposed in about:support. In the meantime, you can run this snippet in the Browser Console to get it:


The values are:

  • 0: Uninitialized - Should never see this value
  • 1: Inactive - When the feature is disabled (the pref wasn't created), or if the policies.json file doesn't exist. This should be the default value you get when the feature is not being used.
  • 2: Active - When the feature is correctly in use
  • 3: Error - When the feature was attempted to be used, but there was a malformed error in the policies.json file

Testing the policies

There are currently a few dummy policies implemented, and we can test that they are being correctly activated by the policies.json file by verifying some log messages or running a snippet:

Policy Name How to verify
block_about_config Snippet: Services.policies.isAllowed("about:config") returns false when the policy is in use
block_devtools Snippet: Services.policies.isAllowed("devtools") returns false when the policy is in use
test_dummy_feature1 Snippet Services.policies.isAllowed("test_dummy_feature1") returns false when the policy is in use
url_policy Watch the message "URL POLICY spec:" in the Browser console
bookmarks_test_policy Watch the message "BOOKMARK: TITLE: foo, URL: bar" for each entry in the Browser console

Example files

  • JSON file with all policies enabled:
  "policies": {
    "block_about_config": true,
    "block_devtools": true,
    "test_dummy_feature1": true,
    "url_policy": "",
    "bookmarks_test_policy": {
      "title": "Bookmark title",
      "url": ""
  • JSON with just the about:config enabled (use it to verify that devtools doesn't get blocked):
  "policies": {
    "block_about_config": true
  • Malformed JSON (to test the ERROR state):

View supported policies

To view the policies that have already landed in the Nightly you're testing, run this Snippet:

var { schema } = Cu.import("resource:///modules/policies/schema.jsm", {});
console.log("Available Policies:")
for (let policy of Object.keys( { console.log(`  ${policy}`); }

Note: Please ignore the `block_about_config` policy because it's just in the list of supported policies as a placeholder, but the code for it hasn't landed yet. Every other policy will land together with the code and should be ready to test.