prefs module


class Branch(branch)
  • branch (string()) – Preference subtree. Uses root tree given null.

Branch.get(pref, fallback=null)

Gets value of pref in its known type.

  • pref (string()) – Preference name.

  • fallback


TypeError() – If pref is not a recognised preference and no fallback value has been provided.


string|boolean|number – Value of pref, or the fallback value if pref does not exist.

Branch.set(pref, value)

Sets the value of pref.

  • pref (string()) – Preference name.

  • value (string|boolean|number()) – pref’s new value.


TypeError() – If value is not the correct type for pref.


class EnvironmentPrefs()

Reads a JSON serialised blob stored in the environment.


Reads the environment variable key and tries to parse it as JSON Object, then provides an iterator over its keys and values.

If the environment variable is not set, this function returns empty.

  • key (string()) – Environment variable.


{Iterable.<string, (string|boolean|number)>


class MarionetteBranch(branch)

Provides shortcuts for lazily getting and setting typed Marionette preferences.

Some of Marionette’s preferences are stored using primitive values that internally are represented by complex types. One such example is marionette.log.level which stores a string such as info or DEBUG, and which is represented as Log.Level.

Because we cannot trust the input of many of these preferences, this class provides abstraction that lets us safely deal with potentially malformed input. In the marionette.log.level example, DEBUG, Debug, and dEbUg are considered valid inputs and the LogBranch specialisation deserialises the string value to the correct Log.Level by sanitising the input data first.

A further complication is that we cannot rely on Preferences.jsm in Marionette. See for further details.


The marionette.debugging.clicktostart preference delays server startup until a modal dialogue has been clicked to allow time for user to set breakpoints in the Browser Toolbox.


The marionette.port preference, detailing which port the TCP server should listen on.


Gets the marionette.setpermission.enabled preference, should only be used for testdriver’s set_permission API.