Bug 1924993 - [devtools] Debugger tests wait before typing in conditional panel r...
[gecko.git] / devtools / client / webconsole / utils / prefs.js
blob9235c820694d4b30f05027715f3afa439cbd889e
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 function getPreferenceName(hud, suffix) {
8 if (!suffix) {
9 console.error("Suffix shouldn't be falsy", { suffix });
10 return null;
13 if (!hud) {
14 console.error("hud shouldn't be falsy", { hud });
15 return null;
18 if (suffix.startsWith("devtools.")) {
19 // We don't have a suffix but a full pref name. Let's return it.
20 return suffix;
23 const component = hud.isBrowserConsole ? "browserconsole" : "webconsole";
24 return `devtools.${component}.${suffix}`;
27 function getPrefsService(hud) {
28 const getPrefName = pref => getPreferenceName(hud, pref);
30 return {
31 getBoolPref: (pref, deflt) =>
32 Services.prefs.getBoolPref(getPrefName(pref), deflt),
33 getIntPref: (pref, deflt) =>
34 Services.prefs.getIntPref(getPrefName(pref), deflt),
35 setBoolPref: (pref, value) =>
36 Services.prefs.setBoolPref(getPrefName(pref), value),
37 setIntPref: (pref, value) =>
38 Services.prefs.setIntPref(getPrefName(pref), value),
39 clearUserPref: pref => Services.prefs.clearUserPref(getPrefName(pref)),
40 getPrefName,
44 module.exports = {
45 getPrefsService,