1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
6 // Tests that the preference helpers work properly.
8 const { PrefsHelper } = require("resource://devtools/client/shared/prefs.js");
11 const Prefs = new PrefsHelper("devtools.debugger", {
12 foo: ["Bool", "enabled"],
15 const originalPrefValue = Services.prefs.getBoolPref(
16 "devtools.debugger.enabled"
18 is(Prefs.foo, originalPrefValue, "The pref value was correctly fetched.");
20 Prefs.foo = !originalPrefValue;
21 is(Prefs.foo, !originalPrefValue, "The pref was was correctly changed (1).");
23 Services.prefs.getBoolPref("devtools.debugger.enabled"),
25 "The pref was was correctly changed (2)."
28 Services.prefs.setBoolPref("devtools.debugger.enabled", originalPrefValue);
29 info("The pref value was reset (1).");
33 "The cached pref value hasn't changed yet (1)."
36 Services.prefs.setBoolPref("devtools.debugger.enabled", !originalPrefValue);
37 info("The pref value was reset (2).");
41 "The cached pref value hasn't changed yet (2)."
44 Prefs.registerObserver();
46 Services.prefs.setBoolPref("devtools.debugger.enabled", originalPrefValue);
47 info("The pref value was reset (3).");
48 is(Prefs.foo, originalPrefValue, "The cached pref value has changed now.");
50 Prefs.unregisterObserver();