Bug 1890689 accumulate input in LargerReceiverBlockSizeThanDesiredBuffering GTest...
[gecko.git] / devtools / client / shared / test / browser_prefs-01.js
blob2989cdee57127908e90c61777651ebf7da5f69ff
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 // Tests that the preference helpers work properly.
8 const { PrefsHelper } = require("resource://devtools/client/shared/prefs.js");
10 function test() {
11   const Prefs = new PrefsHelper("devtools.debugger", {
12     foo: ["Bool", "enabled"],
13   });
15   const originalPrefValue = Services.prefs.getBoolPref(
16     "devtools.debugger.enabled"
17   );
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).");
22   is(
23     Services.prefs.getBoolPref("devtools.debugger.enabled"),
24     !originalPrefValue,
25     "The pref was was correctly changed (2)."
26   );
28   Services.prefs.setBoolPref("devtools.debugger.enabled", originalPrefValue);
29   info("The pref value was reset (1).");
30   is(
31     Prefs.foo,
32     !originalPrefValue,
33     "The cached pref value hasn't changed yet (1)."
34   );
36   Services.prefs.setBoolPref("devtools.debugger.enabled", !originalPrefValue);
37   info("The pref value was reset (2).");
38   is(
39     Prefs.foo,
40     !originalPrefValue,
41     "The cached pref value hasn't changed yet (2)."
42   );
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();
52   finish();