fune/devtools/shared/specs/preference.js
Julian Descottes 3a577649e6 Bug 1662067 - Set default preferences from about:debugging when connecting to remote runtimes r=daisuke,nchevobbe,devtools-backward-compat-reviewers
At the moment, it is easy to break remote debugging by reading preferences incorrectly.
Typically, creating a preference in the firefox preference index file will only create it for Firefox, not for mobile (Fenix).
When trying to read the preference from the server with the Services.prefs.get*Pref APIs, the call will throw unless a fallback value was specified.

A longer term solution is investigated at https://bugzilla.mozilla.org/show_bug.cgi?id=1660182, but for now this changeset allows about:debugging to set a few default values for preferences when connecting to a remote runtime.

Differential Revision: https://phabricator.services.mozilla.com/D88782
2020-09-03 07:49:33 +00:00

51 lines
1.3 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
const preferenceSpec = generateActorSpec({
typeName: "preference",
methods: {
getTraits: {
request: {},
response: { traits: RetVal("json") },
},
getBoolPref: {
request: { value: Arg(0) },
response: { value: RetVal("boolean") },
},
getCharPref: {
request: { value: Arg(0) },
response: { value: RetVal("string") },
},
getIntPref: {
request: { value: Arg(0) },
response: { value: RetVal("number") },
},
getAllPrefs: {
request: {},
response: { value: RetVal("json") },
},
setBoolPref: {
request: { name: Arg(0), value: Arg(1) },
response: {},
},
setCharPref: {
request: { name: Arg(0), value: Arg(1) },
response: {},
},
setIntPref: {
request: { name: Arg(0), value: Arg(1) },
response: {},
},
clearUserPref: {
request: { name: Arg(0) },
response: {},
},
},
});
exports.preferenceSpec = preferenceSpec;