Bug 1875678 - use set/getStringPref instead of set/getCharPref in services/. r=skhamis,sync-reviewers

Theoretically we only need to change this where the strings might be
non-ascii but it seems safer in the long run to just avoid the "char"
versions entirely.

Differential Revision: https://phabricator.services.mozilla.com/D200342
This commit is contained in:
Mark Hammond 2024-02-07 00:59:20 +00:00
parent 69300a43c4
commit e4a5ee36a6
50 changed files with 166 additions and 145 deletions

View file

@ -392,7 +392,7 @@ export var Sync = {
}; };
export function initConfig(autoconfig) { export function initConfig(autoconfig) {
Services.prefs.setCharPref(AUTOCONFIG_PREF, autoconfig); Services.prefs.setStringPref(AUTOCONFIG_PREF, autoconfig);
} }
export async function triggerSync(username, password, autoconfig) { export async function triggerSync(username, password, autoconfig) {

View file

@ -54,7 +54,7 @@ ChromeUtils.defineLazyGetter(lazy, "log", function () {
let level = let level =
Services.prefs.getPrefType(PREF_LOG_LEVEL) == Services.prefs.getPrefType(PREF_LOG_LEVEL) ==
Ci.nsIPrefBranch.PREF_STRING && Ci.nsIPrefBranch.PREF_STRING &&
Services.prefs.getCharPref(PREF_LOG_LEVEL); Services.prefs.getStringPref(PREF_LOG_LEVEL);
appender.level = Log.Level[level] || Log.Level.Error; appender.level = Log.Level[level] || Log.Level.Error;
} catch (e) { } catch (e) {
log.error(e); log.error(e);

View file

@ -236,7 +236,8 @@ LogManager.prototype = {
// dump=Error, we need to keep dump=Debug so consumerA is respected. // dump=Error, we need to keep dump=Debug so consumerA is respected.
for (let branch of allBranches) { for (let branch of allBranches) {
let lookPrefBranch = Services.prefs.getBranch(branch); let lookPrefBranch = Services.prefs.getBranch(branch);
let lookVal = Log.Level[lookPrefBranch.getCharPref(prefName, null)]; let lookVal =
Log.Level[lookPrefBranch.getStringPref(prefName, null)];
if (lookVal && lookVal < level) { if (lookVal && lookVal < level) {
level = lookVal; level = lookVal;
} }
@ -247,7 +248,7 @@ LogManager.prototype = {
this._prefs.addObserver(prefName, observer); this._prefs.addObserver(prefName, observer);
this._prefObservers.push([prefName, observer]); this._prefObservers.push([prefName, observer]);
// and call the observer now with the current pref value. // and call the observer now with the current pref value.
observer(this._prefs.getCharPref(prefName, null)); observer(this._prefs.getStringPref(prefName, null));
return observer; return observer;
}; };

View file

@ -42,9 +42,12 @@ add_task(async function test_noPrefs() {
// Test that changes to the prefs used by the log manager are updated dynamically. // Test that changes to the prefs used by the log manager are updated dynamically.
add_task(async function test_PrefChanges() { add_task(async function test_PrefChanges() {
Services.prefs.setCharPref("log-manager.test.log.appender.console", "Trace"); Services.prefs.setStringPref(
Services.prefs.setCharPref("log-manager.test.log.appender.dump", "Trace"); "log-manager.test.log.appender.console",
Services.prefs.setCharPref( "Trace"
);
Services.prefs.setStringPref("log-manager.test.log.appender.dump", "Trace");
Services.prefs.setStringPref(
"log-manager.test.log.appender.file.level", "log-manager.test.log.appender.file.level",
"Trace" "Trace"
); );
@ -56,9 +59,12 @@ add_task(async function test_PrefChanges() {
equal(dapp.level, Log.Level.Trace); equal(dapp.level, Log.Level.Trace);
equal(fapp.level, Log.Level.Trace); equal(fapp.level, Log.Level.Trace);
// adjust the prefs and they should magically be reflected in the appenders. // adjust the prefs and they should magically be reflected in the appenders.
Services.prefs.setCharPref("log-manager.test.log.appender.console", "Debug"); Services.prefs.setStringPref(
Services.prefs.setCharPref("log-manager.test.log.appender.dump", "Debug"); "log-manager.test.log.appender.console",
Services.prefs.setCharPref( "Debug"
);
Services.prefs.setStringPref("log-manager.test.log.appender.dump", "Debug");
Services.prefs.setStringPref(
"log-manager.test.log.appender.file.level", "log-manager.test.log.appender.file.level",
"Debug" "Debug"
); );
@ -66,9 +72,12 @@ add_task(async function test_PrefChanges() {
equal(dapp.level, Log.Level.Debug); equal(dapp.level, Log.Level.Debug);
equal(fapp.level, Log.Level.Debug); equal(fapp.level, Log.Level.Debug);
// and invalid values should cause them to fallback to their defaults. // and invalid values should cause them to fallback to their defaults.
Services.prefs.setCharPref("log-manager.test.log.appender.console", "xxx"); Services.prefs.setStringPref("log-manager.test.log.appender.console", "xxx");
Services.prefs.setCharPref("log-manager.test.log.appender.dump", "xxx"); Services.prefs.setStringPref("log-manager.test.log.appender.dump", "xxx");
Services.prefs.setCharPref("log-manager.test.log.appender.file.level", "xxx"); Services.prefs.setStringPref(
"log-manager.test.log.appender.file.level",
"xxx"
);
equal(capp.level, Log.Level.Fatal); equal(capp.level, Log.Level.Fatal);
equal(dapp.level, Log.Level.Error); equal(dapp.level, Log.Level.Error);
equal(fapp.level, Log.Level.Debug); equal(fapp.level, Log.Level.Debug);
@ -78,24 +87,24 @@ add_task(async function test_PrefChanges() {
// Test that the same log used by multiple log managers does the right thing. // Test that the same log used by multiple log managers does the right thing.
add_task(async function test_SharedLogs() { add_task(async function test_SharedLogs() {
// create the prefs for the first instance. // create the prefs for the first instance.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"log-manager-1.test.log.appender.console", "log-manager-1.test.log.appender.console",
"Trace" "Trace"
); );
Services.prefs.setCharPref("log-manager-1.test.log.appender.dump", "Trace"); Services.prefs.setStringPref("log-manager-1.test.log.appender.dump", "Trace");
Services.prefs.setCharPref( Services.prefs.setStringPref(
"log-manager-1.test.log.appender.file.level", "log-manager-1.test.log.appender.file.level",
"Trace" "Trace"
); );
let lm1 = new LogManager("log-manager-1.test.", ["TestLog3"], "test"); let lm1 = new LogManager("log-manager-1.test.", ["TestLog3"], "test");
// and the second. // and the second.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"log-manager-2.test.log.appender.console", "log-manager-2.test.log.appender.console",
"Debug" "Debug"
); );
Services.prefs.setCharPref("log-manager-2.test.log.appender.dump", "Debug"); Services.prefs.setStringPref("log-manager-2.test.log.appender.dump", "Debug");
Services.prefs.setCharPref( Services.prefs.setStringPref(
"log-manager-2.test.log.appender.file.level", "log-manager-2.test.log.appender.file.level",
"Debug" "Debug"
); );
@ -111,12 +120,12 @@ add_task(async function test_SharedLogs() {
// Set the prefs on the -1 branch to "Error" - it should then end up with // Set the prefs on the -1 branch to "Error" - it should then end up with
// "Debug" from the -2 branch. // "Debug" from the -2 branch.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"log-manager-1.test.log.appender.console", "log-manager-1.test.log.appender.console",
"Error" "Error"
); );
Services.prefs.setCharPref("log-manager-1.test.log.appender.dump", "Error"); Services.prefs.setStringPref("log-manager-1.test.log.appender.dump", "Error");
Services.prefs.setCharPref( Services.prefs.setStringPref(
"log-manager-1.test.log.appender.file.level", "log-manager-1.test.log.appender.file.level",
"Error" "Error"
); );

View file

@ -16,7 +16,7 @@ add_test(function test_set_basic() {
let now = new Date(); let now = new Date();
CommonUtils.setDatePref(prefs, "test00", now); CommonUtils.setDatePref(prefs, "test00", now);
let value = prefs.getCharPref("test00"); let value = prefs.getStringPref("test00");
Assert.equal(value, "" + now.getTime()); Assert.equal(value, "" + now.getTime());
let now2 = CommonUtils.getDatePref(prefs, "test00"); let now2 = CommonUtils.getDatePref(prefs, "test00");
@ -42,7 +42,7 @@ add_test(function test_set_bounds_checking() {
}); });
add_test(function test_get_bounds_checking() { add_test(function test_get_bounds_checking() {
prefs.setCharPref("test_bounds_checking", "13241431"); prefs.setStringPref("test_bounds_checking", "13241431");
let log = new DummyLogger(); let log = new DummyLogger();
let d = CommonUtils.getDatePref(prefs, "test_bounds_checking", 0, log); let d = CommonUtils.getDatePref(prefs, "test_bounds_checking", 0, log);
@ -66,7 +66,7 @@ add_test(function test_get_bad_default() {
}); });
add_test(function test_get_invalid_number() { add_test(function test_get_invalid_number() {
prefs.setCharPref("get_invalid_number", "hello world"); prefs.setStringPref("get_invalid_number", "hello world");
let log = new DummyLogger(); let log = new DummyLogger();
let d = CommonUtils.getDatePref(prefs, "get_invalid_number", 42, log); let d = CommonUtils.getDatePref(prefs, "get_invalid_number", 42, log);

View file

@ -510,7 +510,7 @@ export var CommonUtils = {
throw new Error("Default value is not a number: " + def); throw new Error("Default value is not a number: " + def);
} }
let valueStr = branch.getCharPref(pref, null); let valueStr = branch.getStringPref(pref, null);
if (valueStr !== null) { if (valueStr !== null) {
let valueInt = parseInt(valueStr, 10); let valueInt = parseInt(valueStr, 10);
@ -614,7 +614,7 @@ export var CommonUtils = {
); );
} }
branch.setCharPref(pref, "" + date.getTime()); branch.setStringPref(pref, "" + date.getTime());
}, },
/** /**

View file

@ -8,7 +8,7 @@ ChromeUtils.defineESModuleGetters(this, {
}); });
// Enable logging from jwcrypto.jsm. // Enable logging from jwcrypto.jsm.
Services.prefs.setCharPref("services.crypto.jwcrypto.log.level", "Debug"); Services.prefs.setStringPref("services.crypto.jwcrypto.log.level", "Debug");
add_task(async function test_jwe_roundtrip_ecdh_es_encryption() { add_task(async function test_jwe_roundtrip_ecdh_es_encryption() {
const plaintext = crypto.getRandomValues(new Uint8Array(123)); const plaintext = crypto.getRandomValues(new Uint8Array(123));

View file

@ -30,7 +30,7 @@ try {
LOG_LEVEL = LOG_LEVEL =
Services.prefs.getPrefType(PREF_LOG_LEVEL) == Services.prefs.getPrefType(PREF_LOG_LEVEL) ==
Ci.nsIPrefBranch.PREF_STRING && Ci.nsIPrefBranch.PREF_STRING &&
Services.prefs.getCharPref(PREF_LOG_LEVEL); Services.prefs.getStringPref(PREF_LOG_LEVEL);
} catch (e) {} } catch (e) {}
var log = Log.repository.getLogger("Identity.FxAccounts"); var log = Log.repository.getLogger("Identity.FxAccounts");

View file

@ -28,7 +28,7 @@ const SIGNUP = "/account/create";
const DEVICES_FILTER_DAYS = 21; const DEVICES_FILTER_DAYS = 21;
export var FxAccountsClient = function ( export var FxAccountsClient = function (
host = Services.prefs.getCharPref(HOST_PREF) host = Services.prefs.getStringPref(HOST_PREF)
) { ) {
this.host = host; this.host = host;

View file

@ -199,7 +199,7 @@ export var FxAccountsConfig = {
}, },
getAutoConfigURL() { getAutoConfigURL() {
let pref = Services.prefs.getCharPref( let pref = Services.prefs.getStringPref(
"identity.fxaccounts.autoconfig.uri", "identity.fxaccounts.autoconfig.uri",
"" ""
); );
@ -263,31 +263,31 @@ export var FxAccountsConfig = {
if (!authServerBase.endsWith("/v1")) { if (!authServerBase.endsWith("/v1")) {
authServerBase += "/v1"; authServerBase += "/v1";
} }
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.auth.uri", "identity.fxaccounts.auth.uri",
authServerBase authServerBase
); );
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.oauth.uri", "identity.fxaccounts.remote.oauth.uri",
config.oauth_server_base_url + "/v1" config.oauth_server_base_url + "/v1"
); );
// At the time of landing this, our servers didn't yet answer with pairing_server_base_uri. // At the time of landing this, our servers didn't yet answer with pairing_server_base_uri.
// Remove this condition check once Firefox 68 is stable. // Remove this condition check once Firefox 68 is stable.
if (config.pairing_server_base_uri) { if (config.pairing_server_base_uri) {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.pairing.uri", "identity.fxaccounts.remote.pairing.uri",
config.pairing_server_base_uri config.pairing_server_base_uri
); );
} }
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.profile.uri", "identity.fxaccounts.remote.profile.uri",
config.profile_server_base_url + "/v1" config.profile_server_base_url + "/v1"
); );
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.sync.tokenserver.uri", "identity.sync.tokenserver.uri",
config.sync_tokenserver_base_url + "/1.0/sync/1.5" config.sync_tokenserver_base_url + "/1.0/sync/1.5"
); );
Services.prefs.setCharPref("identity.fxaccounts.remote.root", rootURL); Services.prefs.setStringPref("identity.fxaccounts.remote.root", rootURL);
// Ensure the webchannel is pointed at the correct uri // Ensure the webchannel is pointed at the correct uri
lazy.EnsureFxAccountsWebChannel(); lazy.EnsureFxAccountsWebChannel();

View file

@ -73,7 +73,7 @@ let rightEmail = "Greta.Garbo@gmail.COM";
let password = "123456"; let password = "123456";
function runTest() { function runTest() {
is(Services.prefs.getCharPref("identity.fxaccounts.auth.uri"), TEST_SERVER, is(Services.prefs.getStringPref("identity.fxaccounts.auth.uri"), TEST_SERVER,
"Pref for auth.uri should be set to test server"); "Pref for auth.uri should be set to test server");
let fxa = new MockFxAccounts(); let fxa = new MockFxAccounts();

View file

@ -45,9 +45,9 @@ var log = Log.repository.getLogger("Services.FxAccounts.test");
log.level = Log.Level.Debug; log.level = Log.Level.Debug;
// See verbose logging from FxAccounts.jsm and jwcrypto.jsm. // See verbose logging from FxAccounts.jsm and jwcrypto.jsm.
Services.prefs.setCharPref("identity.fxaccounts.loglevel", "Trace"); Services.prefs.setStringPref("identity.fxaccounts.loglevel", "Trace");
Log.repository.getLogger("FirefoxAccounts").level = Log.Level.Trace; Log.repository.getLogger("FirefoxAccounts").level = Log.Level.Trace;
Services.prefs.setCharPref("services.crypto.jwcrypto.log.level", "Debug"); Services.prefs.setStringPref("services.crypto.jwcrypto.log.level", "Debug");
/* /*
* The FxAccountsClient communicates with the remote Firefox * The FxAccountsClient communicates with the remote Firefox
@ -1143,7 +1143,7 @@ add_test(function test_resend_email() {
}); });
}); });
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.oauth.uri", "identity.fxaccounts.remote.oauth.uri",
"https://example.com/v1" "https://example.com/v1"
); );
@ -1346,7 +1346,7 @@ add_test(function test_getOAuthToken_invalid_scope_array() {
add_test(function test_getOAuthToken_misconfigure_oauth_uri() { add_test(function test_getOAuthToken_misconfigure_oauth_uri() {
let fxa = new MockFxAccounts(); let fxa = new MockFxAccounts();
const prevServerURL = Services.prefs.getCharPref( const prevServerURL = Services.prefs.getStringPref(
"identity.fxaccounts.remote.oauth.uri" "identity.fxaccounts.remote.oauth.uri"
); );
Services.prefs.deleteBranch("identity.fxaccounts.remote.oauth.uri"); Services.prefs.deleteBranch("identity.fxaccounts.remote.oauth.uri");
@ -1354,7 +1354,7 @@ add_test(function test_getOAuthToken_misconfigure_oauth_uri() {
fxa.getOAuthToken().catch(err => { fxa.getOAuthToken().catch(err => {
Assert.equal(err.message, "INVALID_PARAMETER"); Assert.equal(err.message, "INVALID_PARAMETER");
// revert the pref // revert the pref
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.oauth.uri", "identity.fxaccounts.remote.oauth.uri",
prevServerURL prevServerURL
); );

View file

@ -10,7 +10,7 @@ const { FxAccounts } = ChromeUtils.importESModule(
add_task( add_task(
async function test_non_https_remote_server_uri_with_requireHttps_false() { async function test_non_https_remote_server_uri_with_requireHttps_false() {
Services.prefs.setBoolPref("identity.fxaccounts.allowHttp", true); Services.prefs.setBoolPref("identity.fxaccounts.allowHttp", true);
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.root", "identity.fxaccounts.remote.root",
"http://example.com/" "http://example.com/"
); );
@ -25,7 +25,7 @@ add_task(
); );
add_task(async function test_non_https_remote_server_uri() { add_task(async function test_non_https_remote_server_uri() {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.fxaccounts.remote.root", "identity.fxaccounts.remote.root",
"http://example.com/" "http://example.com/"
); );
@ -43,13 +43,16 @@ add_task(async function test_is_production_config() {
Assert.ok(FxAccounts.config.isProductionConfig()); Assert.ok(FxAccounts.config.isProductionConfig());
// Set an auto-config URL. // Set an auto-config URL.
Services.prefs.setCharPref("identity.fxaccounts.autoconfig.uri", "http://x"); Services.prefs.setStringPref(
"identity.fxaccounts.autoconfig.uri",
"http://x"
);
Assert.equal(FxAccounts.config.getAutoConfigURL(), "http://x"); Assert.equal(FxAccounts.config.getAutoConfigURL(), "http://x");
Assert.ok(!FxAccounts.config.isProductionConfig()); Assert.ok(!FxAccounts.config.isProductionConfig());
// Clear the auto-config URL, but set one of the other config params. // Clear the auto-config URL, but set one of the other config params.
Services.prefs.clearUserPref("identity.fxaccounts.autoconfig.uri"); Services.prefs.clearUserPref("identity.fxaccounts.autoconfig.uri");
Services.prefs.setCharPref("identity.sync.tokenserver.uri", "http://t"); Services.prefs.setStringPref("identity.sync.tokenserver.uri", "http://t");
Assert.ok(!FxAccounts.config.isProductionConfig()); Assert.ok(!FxAccounts.config.isProductionConfig());
Services.prefs.clearUserPref("identity.sync.tokenserver.uri"); Services.prefs.clearUserPref("identity.sync.tokenserver.uri");
}); });

View file

@ -35,7 +35,7 @@ const BOGUS_PUBLICKEY =
"BBXOKjUb84pzws1wionFpfCBjDuCh4-s_1b52WA46K5wYL2gCWEOmFKWn_NkS5nmJwTBuO8qxxdjAIDtNeklvQc"; "BBXOKjUb84pzws1wionFpfCBjDuCh4-s_1b52WA46K5wYL2gCWEOmFKWn_NkS5nmJwTBuO8qxxdjAIDtNeklvQc";
const BOGUS_AUTHKEY = "GSsIiaD2Mr83iPqwFNK4rw"; const BOGUS_AUTHKEY = "GSsIiaD2Mr83iPqwFNK4rw";
Services.prefs.setCharPref("identity.fxaccounts.loglevel", "Trace"); Services.prefs.setStringPref("identity.fxaccounts.loglevel", "Trace");
const DEVICE_REGISTRATION_VERSION = 42; const DEVICE_REGISTRATION_VERSION = 42;

View file

@ -6,7 +6,7 @@
// Tests for FxAccounts, storage and the master password. // Tests for FxAccounts, storage and the master password.
// See verbose logging from FxAccounts.jsm // See verbose logging from FxAccounts.jsm
Services.prefs.setCharPref("identity.fxaccounts.loglevel", "Trace"); Services.prefs.setStringPref("identity.fxaccounts.loglevel", "Trace");
const { FxAccounts } = ChromeUtils.importESModule( const { FxAccounts } = ChromeUtils.importESModule(
"resource://gre/modules/FxAccounts.sys.mjs" "resource://gre/modules/FxAccounts.sys.mjs"

View file

@ -387,7 +387,7 @@ In order to enable verbose logging, set the log level preference to ``debug``.
.. code-block:: javascript .. code-block:: javascript
Services.prefs.setCharPref("services.settings.loglevel", "debug"); Services.prefs.setStringPref("services.settings.loglevel", "debug");
Remote Settings Dev Tools Remote Settings Dev Tools
------------------------- -------------------------

View file

@ -223,7 +223,7 @@ function remoteSettingsFunction() {
// Check if the server backoff time is elapsed. // Check if the server backoff time is elapsed.
if (lazy.gPrefs.prefHasUserValue(PREF_SETTINGS_SERVER_BACKOFF)) { if (lazy.gPrefs.prefHasUserValue(PREF_SETTINGS_SERVER_BACKOFF)) {
const backoffReleaseTime = lazy.gPrefs.getCharPref( const backoffReleaseTime = lazy.gPrefs.getStringPref(
PREF_SETTINGS_SERVER_BACKOFF PREF_SETTINGS_SERVER_BACKOFF
); );
const remainingMilliseconds = const remainingMilliseconds =
@ -288,7 +288,7 @@ function remoteSettingsFunction() {
// Every time we register a new client, we have to fetch the whole list again. // Every time we register a new client, we have to fetch the whole list again.
const lastEtag = _invalidatePolling const lastEtag = _invalidatePolling
? "" ? ""
: lazy.gPrefs.getCharPref(PREF_SETTINGS_LAST_ETAG, ""); : lazy.gPrefs.getStringPref(PREF_SETTINGS_LAST_ETAG, "");
let pollResult; let pollResult;
try { try {
@ -352,7 +352,10 @@ function remoteSettingsFunction() {
"Server asks clients to backoff for ${backoffSeconds} seconds" "Server asks clients to backoff for ${backoffSeconds} seconds"
); );
const backoffReleaseTime = Date.now() + backoffSeconds * 1000; const backoffReleaseTime = Date.now() + backoffSeconds * 1000;
lazy.gPrefs.setCharPref(PREF_SETTINGS_SERVER_BACKOFF, backoffReleaseTime); lazy.gPrefs.setStringPref(
PREF_SETTINGS_SERVER_BACKOFF,
backoffReleaseTime
);
} }
// Record new update time and the difference between local and server time. // Record new update time and the difference between local and server time.
@ -450,7 +453,7 @@ function remoteSettingsFunction() {
} }
// Save current Etag for next poll. // Save current Etag for next poll.
lazy.gPrefs.setCharPref(PREF_SETTINGS_LAST_ETAG, currentEtag); lazy.gPrefs.setStringPref(PREF_SETTINGS_LAST_ETAG, currentEtag);
// Report the global synchronization success. // Report the global synchronization success.
const status = lazy.UptakeTelemetry.STATUS.SUCCESS; const status = lazy.UptakeTelemetry.STATUS.SUCCESS;
@ -523,7 +526,7 @@ function remoteSettingsFunction() {
serverURL: lazy.Utils.SERVER_URL, serverURL: lazy.Utils.SERVER_URL,
pollingEndpoint: lazy.Utils.SERVER_URL + lazy.Utils.CHANGES_PATH, pollingEndpoint: lazy.Utils.SERVER_URL + lazy.Utils.CHANGES_PATH,
serverTimestamp, serverTimestamp,
localTimestamp: lazy.gPrefs.getCharPref(PREF_SETTINGS_LAST_ETAG, null), localTimestamp: lazy.gPrefs.getStringPref(PREF_SETTINGS_LAST_ETAG, null),
lastCheck: lazy.gPrefs.getIntPref(PREF_SETTINGS_LAST_UPDATE, 0), lastCheck: lazy.gPrefs.getIntPref(PREF_SETTINGS_LAST_UPDATE, 0),
mainBucket: lazy.Utils.actualBucketName( mainBucket: lazy.Utils.actualBucketName(
AppConstants.REMOTE_SETTINGS_DEFAULT_BUCKET AppConstants.REMOTE_SETTINGS_DEFAULT_BUCKET

View file

@ -61,7 +61,7 @@ function run_test() {
} }
async function clear_state() { async function clear_state() {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
`http://localhost:${server.identity.primaryPort}/v1` `http://localhost:${server.identity.primaryPort}/v1`
); );
@ -101,7 +101,7 @@ add_task(clear_state);
add_task(async function test_base_attachment_url_depends_on_server() { add_task(async function test_base_attachment_url_depends_on_server() {
const before = await downloader._baseAttachmentsURL(); const before = await downloader._baseAttachmentsURL();
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
`http://localhost:${server.identity.primaryPort}/v2` `http://localhost:${server.identity.primaryPort}/v2`
); );

View file

@ -64,12 +64,12 @@ function run_test() {
Policy.getChannel = () => "nightly"; Policy.getChannel = () => "nightly";
// Point the blocklist clients to use this local HTTP server. // Point the blocklist clients to use this local HTTP server.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
`http://localhost:${server.identity.primaryPort}/v1` `http://localhost:${server.identity.primaryPort}/v1`
); );
Services.prefs.setCharPref("services.settings.loglevel", "debug"); Services.prefs.setStringPref("services.settings.loglevel", "debug");
client = RemoteSettings("password-fields"); client = RemoteSettings("password-fields");
clientWithDump = RemoteSettings("language-dictionaries"); clientWithDump = RemoteSettings("language-dictionaries");

View file

@ -48,7 +48,7 @@ var server;
async function clear_state() { async function clear_state() {
// set up prefs so the kinto updater talks to the test server // set up prefs so the kinto updater talks to the test server
Services.prefs.setCharPref( Services.prefs.setStringPref(
PREF_SETTINGS_SERVER, PREF_SETTINGS_SERVER,
`http://localhost:${server.identity.primaryPort}/v1` `http://localhost:${server.identity.primaryPort}/v1`
); );
@ -203,7 +203,7 @@ add_task(async function test_check_success() {
Assert.ok(maybeSyncCalled, "maybeSync was called"); Assert.ok(maybeSyncCalled, "maybeSync was called");
Assert.ok(notificationObserved, "a notification should have been observed"); Assert.ok(notificationObserved, "a notification should have been observed");
// Last timestamp was saved. An ETag header value is a quoted string. // Last timestamp was saved. An ETag header value is a quoted string.
Assert.equal(Services.prefs.getCharPref(PREF_LAST_ETAG), '"1100"'); Assert.equal(Services.prefs.getStringPref(PREF_LAST_ETAG), '"1100"');
// check the last_update is updated // check the last_update is updated
Assert.equal(Services.prefs.getIntPref(PREF_LAST_UPDATE), serverTime / 1000); Assert.equal(Services.prefs.getIntPref(PREF_LAST_UPDATE), serverTime / 1000);
@ -268,7 +268,7 @@ add_task(async function test_update_timer_interface() {
}); });
// Everything went fine. // Everything went fine.
Assert.equal(Services.prefs.getCharPref(PREF_LAST_ETAG), '"42"'); Assert.equal(Services.prefs.getStringPref(PREF_LAST_ETAG), '"42"');
Assert.equal(Services.prefs.getIntPref(PREF_LAST_UPDATE), serverTime / 1000); Assert.equal(Services.prefs.getIntPref(PREF_LAST_UPDATE), serverTime / 1000);
}); });
add_task(clear_state); add_task(clear_state);
@ -283,7 +283,7 @@ add_task(async function test_check_up_to_date() {
const serverTime = 4000; const serverTime = 4000;
server.registerPathHandler(CHANGES_PATH, serveChangesEntries(serverTime, [])); server.registerPathHandler(CHANGES_PATH, serveChangesEntries(serverTime, []));
Services.prefs.setCharPref(PREF_LAST_ETAG, '"1100"'); Services.prefs.setStringPref(PREF_LAST_ETAG, '"1100"');
// Ensure that the remote-settings:changes-poll-end notification is sent. // Ensure that the remote-settings:changes-poll-end notification is sent.
let notificationObserved = false; let notificationObserved = false;
@ -764,7 +764,7 @@ add_task(async function test_server_error_4xx() {
} }
server.registerPathHandler(CHANGES_PATH, simulateErrorResponse); server.registerPathHandler(CHANGES_PATH, simulateErrorResponse);
Services.prefs.setCharPref(PREF_LAST_ETAG, '"abc"'); Services.prefs.setStringPref(PREF_LAST_ETAG, '"abc"');
let error; let error;
try { try {
@ -1113,7 +1113,7 @@ add_task(async function test_backoff() {
}, },
]) ])
); );
Services.prefs.setCharPref( Services.prefs.setStringPref(
PREF_SETTINGS_SERVER_BACKOFF, PREF_SETTINGS_SERVER_BACKOFF,
`${Date.now() - 1000}` `${Date.now() - 1000}`
); );
@ -1144,7 +1144,7 @@ add_task(async function test_network_error() {
); );
// Simulate a network error (to check telemetry report). // Simulate a network error (to check telemetry report).
Services.prefs.setCharPref(PREF_SETTINGS_SERVER, "http://localhost:42/v1"); Services.prefs.setStringPref(PREF_SETTINGS_SERVER, "http://localhost:42/v1");
try { try {
await RemoteSettings.pollChanges(); await RemoteSettings.pollChanges();
} catch (e) {} } catch (e) {}

View file

@ -23,9 +23,9 @@ let maybeSyncBackup;
async function clear_state() { async function clear_state() {
// Disable logging output. // Disable logging output.
Services.prefs.setCharPref("services.settings.loglevel", "critical"); Services.prefs.setStringPref("services.settings.loglevel", "critical");
// Pull data from the test server. // Pull data from the test server.
Services.prefs.setCharPref( Services.prefs.setStringPref(
PREF_SETTINGS_SERVER, PREF_SETTINGS_SERVER,
`http://localhost:${server.identity.primaryPort}/v1` `http://localhost:${server.identity.primaryPort}/v1`
); );

View file

@ -38,7 +38,7 @@ add_task(
skip_if: () => !AppConstants.RELEASE_OR_BETA, skip_if: () => !AppConstants.RELEASE_OR_BETA,
}, },
async function test_server_url_cannot_be_toggled_in_release() { async function test_server_url_cannot_be_toggled_in_release() {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
"http://localhost:8888/v1" "http://localhost:8888/v1"
); );
@ -58,7 +58,7 @@ add_task(
skip_if: () => AppConstants.RELEASE_OR_BETA, skip_if: () => AppConstants.RELEASE_OR_BETA,
}, },
async function test_server_url_cannot_be_toggled_in_dev_nightly() { async function test_server_url_cannot_be_toggled_in_dev_nightly() {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
"http://localhost:8888/v1" "http://localhost:8888/v1"
); );
@ -107,7 +107,7 @@ add_task(
skip_if: () => !AppConstants.RELEASE_OR_BETA, skip_if: () => !AppConstants.RELEASE_OR_BETA,
}, },
async function test_load_dumps_will_always_be_loaded_in_release() { async function test_load_dumps_will_always_be_loaded_in_release() {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
"http://localhost:8888/v1" "http://localhost:8888/v1"
); );
@ -128,7 +128,7 @@ add_task(
skip_if: () => AppConstants.RELEASE_OR_BETA, skip_if: () => AppConstants.RELEASE_OR_BETA,
}, },
async function test_load_dumps_can_be_disabled_in_dev_nightly() { async function test_load_dumps_can_be_disabled_in_dev_nightly() {
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
"http://localhost:8888/v1" "http://localhost:8888/v1"
); );
@ -148,7 +148,7 @@ add_task(clear_state);
add_task( add_task(
async function test_server_url_can_be_changed_in_all_versions_if_running_for_devtools() { async function test_server_url_can_be_changed_in_all_versions_if_running_for_devtools() {
Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "1"); Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "1");
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
"http://localhost:8888/v1" "http://localhost:8888/v1"
); );
@ -179,7 +179,7 @@ add_task(clear_state);
add_task( add_task(
async function test_dumps_are_not_loaded_if_server_is_not_prod_if_running_for_devtools() { async function test_dumps_are_not_loaded_if_server_is_not_prod_if_running_for_devtools() {
Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "1"); Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "1");
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
"http://localhost:8888/v1" "http://localhost:8888/v1"
); );
@ -193,7 +193,7 @@ add_task(clear_state);
add_task( add_task(
async function test_dumps_are_loaded_if_server_is_prod_if_running_for_devtools() { async function test_dumps_are_loaded_if_server_is_prod_if_running_for_devtools() {
Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "1"); Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "1");
Services.prefs.setCharPref( Services.prefs.setStringPref(
"services.settings.server", "services.settings.server",
AppConstants.REMOTE_SETTINGS_SERVER_URL AppConstants.REMOTE_SETTINGS_SERVER_URL
); );

View file

@ -47,7 +47,7 @@ function run_test() {
// because these tests were originally written for OneCRL. // because these tests were originally written for OneCRL.
client = RemoteSettings("signed", { signerName: SIGNER_NAME }); client = RemoteSettings("signed", { signerName: SIGNER_NAME });
Services.prefs.setCharPref("services.settings.loglevel", "debug"); Services.prefs.setStringPref("services.settings.loglevel", "debug");
// Set up an HTTP Server // Set up an HTTP Server
server = new HttpServer(); server = new HttpServer();
@ -148,7 +148,7 @@ add_task(async function test_check_synchronization_with_signatures() {
} }
// set up prefs so the kinto updater talks to the test server // set up prefs so the kinto updater talks to the test server
Services.prefs.setCharPref( Services.prefs.setStringPref(
PREF_SETTINGS_SERVER, PREF_SETTINGS_SERVER,
`http://localhost:${server.identity.primaryPort}/v1` `http://localhost:${server.identity.primaryPort}/v1`
); );

View file

@ -192,7 +192,7 @@ const UIStateInternal = {
_setLastSyncTime(state) { _setLastSyncTime(state) {
if (state?.status == UIState.STATUS_SIGNED_IN) { if (state?.status == UIState.STATUS_SIGNED_IN) {
const lastSync = Services.prefs.getCharPref( const lastSync = Services.prefs.getStringPref(
"services.sync.lastSync", "services.sync.lastSync",
null null
); );

View file

@ -16,7 +16,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
function AddonUtilsInternal() { function AddonUtilsInternal() {
this._log = Log.repository.getLogger("Sync.AddonUtils"); this._log = Log.repository.getLogger("Sync.AddonUtils");
this._log.Level = this._log.Level =
Log.Level[Svc.PrefBranch.getCharPref("log.logger.addonutils", null)]; Log.Level[Svc.PrefBranch.getStringPref("log.logger.addonutils", null)];
} }
AddonUtilsInternal.prototype = { AddonUtilsInternal.prototype = {
/** /**

View file

@ -647,7 +647,7 @@ EngineManager.prototype = {
}, },
persistDeclined() { persistDeclined() {
Svc.PrefBranch.setCharPref( Svc.PrefBranch.setStringPref(
"declinedEngines", "declinedEngines",
[...this._declined].join(",") [...this._declined].join(",")
); );
@ -1007,7 +1007,7 @@ SyncEngine.prototype = {
); );
await this.resetClient(); await this.resetClient();
Svc.PrefBranch.setStringPref(this.name + ".syncID", newSyncID); Svc.PrefBranch.setStringPref(this.name + ".syncID", newSyncID);
Svc.PrefBranch.setCharPref(this.name + ".lastSync", "0"); Svc.PrefBranch.setStringPref(this.name + ".lastSync", "0");
return newSyncID; return newSyncID;
}, },
@ -1052,7 +1052,7 @@ SyncEngine.prototype = {
}, },
async setLastSync(lastSync) { async setLastSync(lastSync) {
// Store the value as a string to keep floating point precision // Store the value as a string to keep floating point precision
Svc.PrefBranch.setCharPref(this.name + ".lastSync", lastSync.toString()); Svc.PrefBranch.setStringPref(this.name + ".lastSync", lastSync.toString());
}, },
async resetLastSync() { async resetLastSync() {
this._log.debug("Resetting " + this.name + " last sync time"); this._log.debug("Resetting " + this.name + " last sync time");

View file

@ -262,7 +262,7 @@ PrefStore.prototype = {
_setAllPrefs(values) { _setAllPrefs(values) {
const selectedThemeIDPref = "extensions.activeThemeID"; const selectedThemeIDPref = "extensions.activeThemeID";
let selectedThemeIDBefore = this._prefs.getCharPref( let selectedThemeIDBefore = this._prefs.getStringPref(
selectedThemeIDPref, selectedThemeIDPref,
null null
); );

View file

@ -429,7 +429,7 @@ Sync11Service.prototype = {
Svc.PrefBranch.getPrefType("registerEngines") != Svc.PrefBranch.getPrefType("registerEngines") !=
Ci.nsIPrefBranch.PREF_INVALID Ci.nsIPrefBranch.PREF_INVALID
) { ) {
engines = Svc.PrefBranch.getCharPref("registerEngines").split(","); engines = Svc.PrefBranch.getStringPref("registerEngines").split(",");
this._log.info("Registering custom set of engines", engines); this._log.info("Registering custom set of engines", engines);
} else { } else {
// default is all engines. // default is all engines.
@ -437,7 +437,7 @@ Sync11Service.prototype = {
} }
let declined = []; let declined = [];
let pref = Svc.PrefBranch.getCharPref("declinedEngines", null); let pref = Svc.PrefBranch.getStringPref("declinedEngines", null);
if (pref) { if (pref) {
declined = pref.split(","); declined = pref.split(",");
} }
@ -1009,7 +1009,7 @@ Sync11Service.prototype = {
this._ignorePrefObserver = false; this._ignorePrefObserver = false;
this.clusterURL = null; this.clusterURL = null;
Svc.PrefBranch.setCharPref("lastversion", WEAVE_VERSION); Svc.PrefBranch.setStringPref("lastversion", WEAVE_VERSION);
try { try {
this.identity.finalize(); this.identity.finalize();
@ -1303,7 +1303,7 @@ Sync11Service.prototype = {
Utils.mpLocked() Utils.mpLocked()
) { ) {
reason = kSyncMasterPasswordLocked; reason = kSyncMasterPasswordLocked;
} else if (Svc.PrefBranch.getCharPref("firstSync", null) == "notReady") { } else if (Svc.PrefBranch.getStringPref("firstSync", null) == "notReady") {
reason = kFirstSyncChoiceNotMade; reason = kFirstSyncChoiceNotMade;
} else if (!Async.isAppReady()) { } else if (!Async.isAppReady()) {
reason = kFirefoxShuttingDown; reason = kFirefoxShuttingDown;

View file

@ -111,7 +111,7 @@ EngineSynchronizer.prototype = {
// a first sync. // a first sync.
let allowEnginesHint = false; let allowEnginesHint = false;
// Wipe data in the desired direction if necessary // Wipe data in the desired direction if necessary
switch (Svc.PrefBranch.getCharPref("firstSync", null)) { switch (Svc.PrefBranch.getStringPref("firstSync", null)) {
case "resetClient": case "resetClient":
await this.service.resetClient(engineManager.enabledEngineNames); await this.service.resetClient(engineManager.enabledEngineNames);
break; break;
@ -227,7 +227,7 @@ EngineSynchronizer.prototype = {
this.service.status.service == SYNC_FAILED_PARTIAL || this.service.status.service == SYNC_FAILED_PARTIAL ||
this.service.status.service == STATUS_OK this.service.status.service == STATUS_OK
) { ) {
Svc.PrefBranch.setCharPref("lastSync", new Date().toString()); Svc.PrefBranch.setStringPref("lastSync", new Date().toString());
} }
} finally { } finally {
Svc.PrefBranch.clearUserPref("firstSync"); Svc.PrefBranch.clearUserPref("firstSync");

View file

@ -198,7 +198,7 @@ SyncAuthManager.prototype = {
!Svc.PrefBranch.getStringPref("client.syncID", null); !Svc.PrefBranch.getStringPref("client.syncID", null);
if (isFirstSync) { if (isFirstSync) {
this._log.info("Doing initial sync actions"); this._log.info("Doing initial sync actions");
Svc.PrefBranch.setCharPref("firstSync", "resetClient"); Svc.PrefBranch.setStringPref("firstSync", "resetClient");
Services.obs.notifyObservers(null, "weave:service:setup-complete"); Services.obs.notifyObservers(null, "weave:service:setup-complete");
} }
// There's no need to wait for sync to complete and it would deadlock // There's no need to wait for sync to complete and it would deadlock
@ -361,7 +361,7 @@ SyncAuthManager.prototype = {
// all services.sync prefs. So if that still exists, it wins. // all services.sync prefs. So if that still exists, it wins.
let url = Svc.PrefBranch.getStringPref("tokenServerURI", null); // Svc.PrefBranch "root" is services.sync let url = Svc.PrefBranch.getStringPref("tokenServerURI", null); // Svc.PrefBranch "root" is services.sync
if (!url) { if (!url) {
url = Services.prefs.getCharPref("identity.sync.tokenserver.uri"); url = Services.prefs.getStringPref("identity.sync.tokenserver.uri");
} }
while (url.endsWith("/")) { while (url.endsWith("/")) {
// trailing slashes cause problems... // trailing slashes cause problems...

View file

@ -17,7 +17,7 @@ var fhs = Cc["@mozilla.org/satchel/form-history-startup;1"].getService(
fhs.observe(null, "profile-after-change", null); fhs.observe(null, "profile-after-change", null);
// An app is going to have some prefs set which xpcshell tests don't. // An app is going to have some prefs set which xpcshell tests don't.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"identity.sync.tokenserver.uri", "identity.sync.tokenserver.uri",
"http://token-server" "http://token-server"
); );

View file

@ -920,7 +920,7 @@ add_task(async function test_command_sync() {
notEqual(clientWBO(remoteId).payload, undefined); notEqual(clientWBO(remoteId).payload, undefined);
Svc.PrefBranch.setCharPref("client.GUID", remoteId); Svc.PrefBranch.setStringPref("client.GUID", remoteId);
await engine._resetClient(); await engine._resetClient();
equal(engine.localID, remoteId); equal(engine.localID, remoteId);
_("Performing sync on resetted client."); _("Performing sync on resetted client.");

View file

@ -37,7 +37,7 @@ add_task(async function test_locally_changed_keys() {
server.start(); server.start();
try { try {
Svc.PrefBranch.setCharPref("registerEngines", "Tab"); Svc.PrefBranch.setStringPref("registerEngines", "Tab");
await configureIdentity({ username: "johndoe" }, server); await configureIdentity({ username: "johndoe" }, server);
// We aren't doing a .login yet, so fudge the cluster URL. // We aren't doing a .login yet, so fudge the cluster URL.

View file

@ -219,7 +219,7 @@ add_task(async function test_prefs_change_during_sync() {
} finally { } finally {
_("Updating local pref value"); _("Updating local pref value");
// Change the value of a synced pref. // Change the value of a synced pref.
Services.prefs.setCharPref(TEST_PREF, "hello"); Services.prefs.setStringPref(TEST_PREF, "hello");
await engine._tracker.asyncObserver.promiseObserversComplete(); await engine._tracker.asyncObserver.promiseObserversComplete();
} }
}; };

View file

@ -115,7 +115,7 @@ add_task(async function test_lastSync_not_updated_on_complete_failure() {
Assert.equal(Status.service, STATUS_OK); Assert.equal(Status.service, STATUS_OK);
Assert.equal(Status.sync, SYNC_SUCCEEDED); Assert.equal(Status.sync, SYNC_SUCCEEDED);
let lastSync = Svc.PrefBranch.getCharPref("lastSync"); let lastSync = Svc.PrefBranch.getStringPref("lastSync");
Assert.ok(lastSync); Assert.ok(lastSync);
@ -133,7 +133,7 @@ add_task(async function test_lastSync_not_updated_on_complete_failure() {
Assert.equal(Status.service, SYNC_FAILED); Assert.equal(Status.service, SYNC_FAILED);
// We shouldn't update lastSync on complete failure. // We shouldn't update lastSync on complete failure.
Assert.equal(lastSync, Svc.PrefBranch.getCharPref("lastSync")); Assert.equal(lastSync, Svc.PrefBranch.getStringPref("lastSync"));
await clean(); await clean();
await promiseStopServer(server); await promiseStopServer(server);
@ -379,7 +379,7 @@ add_task(
Assert.ok(!Status.enforceBackoff); Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK); Assert.equal(Status.service, STATUS_OK);
Svc.PrefBranch.setCharPref("firstSync", "wipeRemote"); Svc.PrefBranch.setStringPref("firstSync", "wipeRemote");
let promiseObserved = promiseOneObserver("weave:service:reset-file-log"); let promiseObserved = promiseOneObserver("weave:service:reset-file-log");
await Service.sync(); await Service.sync();
@ -389,7 +389,7 @@ add_task(
Assert.equal(backoffInterval, 42); Assert.equal(backoffInterval, 42);
Assert.equal(Status.service, SYNC_FAILED); Assert.equal(Status.service, SYNC_FAILED);
Assert.equal(Status.sync, SERVER_MAINTENANCE); Assert.equal(Status.sync, SERVER_MAINTENANCE);
Assert.equal(Svc.PrefBranch.getCharPref("firstSync"), "wipeRemote"); Assert.equal(Svc.PrefBranch.getStringPref("firstSync"), "wipeRemote");
await clean(); await clean();
await promiseStopServer(server); await promiseStopServer(server);
@ -406,7 +406,7 @@ add_task(async function test_sync_engine_generic_fail() {
engine.sync = async function sync() { engine.sync = async function sync() {
Svc.Obs.notify("weave:engine:sync:error", ENGINE_UNKNOWN_FAIL, "catapult"); Svc.Obs.notify("weave:engine:sync:error", ENGINE_UNKNOWN_FAIL, "catapult");
}; };
let lastSync = Svc.PrefBranch.getCharPref("lastSync", null); let lastSync = Svc.PrefBranch.getStringPref("lastSync", null);
let log = Log.repository.getLogger("Sync.ErrorHandler"); let log = Log.repository.getLogger("Sync.ErrorHandler");
Svc.PrefBranch.setBoolPref("log.appender.file.logOnError", true); Svc.PrefBranch.setBoolPref("log.appender.file.logOnError", true);
@ -437,7 +437,7 @@ add_task(async function test_sync_engine_generic_fail() {
Assert.equal(Status.service, SYNC_FAILED_PARTIAL); Assert.equal(Status.service, SYNC_FAILED_PARTIAL);
// lastSync should update on partial failure. // lastSync should update on partial failure.
Assert.notEqual(lastSync, Svc.PrefBranch.getCharPref("lastSync")); Assert.notEqual(lastSync, Svc.PrefBranch.getStringPref("lastSync"));
// Test Error log was written on SYNC_FAILED_PARTIAL. // Test Error log was written on SYNC_FAILED_PARTIAL.
let logFiles = getLogFiles(); let logFiles = getLogFiles();

View file

@ -338,7 +338,7 @@ add_test(function test_newFailed_errorLog() {
}); });
add_test(function test_errorLog_dumpAddons() { add_test(function test_errorLog_dumpAddons() {
Svc.PrefBranch.setCharPref("log.logger", "Trace"); Svc.PrefBranch.setStringPref("log.logger", "Trace");
Svc.PrefBranch.setBoolPref("log.appender.file.logOnError", true); Svc.PrefBranch.setBoolPref("log.appender.file.logOnError", true);
Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() { Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {

View file

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
Svc.PrefBranch.setCharPref("registerEngines", ""); Svc.PrefBranch.setStringPref("registerEngines", "");
const { Service } = ChromeUtils.importESModule( const { Service } = ChromeUtils.importESModule(
"resource://services-sync/service.sys.mjs" "resource://services-sync/service.sys.mjs"
); );
@ -174,7 +174,7 @@ add_task(async function test_unsuccessful_sync_adjustSyncInterval() {
_("Test unsuccessful sync calls adjustSyncInterval"); _("Test unsuccessful sync calls adjustSyncInterval");
// Force sync to fail. // Force sync to fail.
Svc.PrefBranch.setCharPref("firstSync", "notReady"); Svc.PrefBranch.setStringPref("firstSync", "notReady");
let server = await sync_httpd_setup(); let server = await sync_httpd_setup();
await setUp(server); await setUp(server);
@ -326,7 +326,7 @@ add_task(async function test_adjust_interval_on_sync_error() {
_("Test unsuccessful sync updates client mode & sync intervals"); _("Test unsuccessful sync updates client mode & sync intervals");
// Force a sync fail. // Force a sync fail.
Svc.PrefBranch.setCharPref("firstSync", "notReady"); Svc.PrefBranch.setStringPref("firstSync", "notReady");
Assert.equal(syncFailures, 0); Assert.equal(syncFailures, 0);
Assert.equal(false, scheduler.numClients > 1); Assert.equal(false, scheduler.numClients > 1);

View file

@ -66,7 +66,7 @@ add_task(async function run_test() {
try { try {
_("Expect the compact light theme to be active"); _("Expect the compact light theme to be active");
Assert.strictEqual( Assert.strictEqual(
Services.prefs.getCharPref("extensions.activeThemeID"), Services.prefs.getStringPref("extensions.activeThemeID"),
COMPACT_THEME_ID COMPACT_THEME_ID
); );
@ -152,12 +152,12 @@ add_task(async function run_test() {
_("Update some prefs, including one that's to be reset/deleted."); _("Update some prefs, including one that's to be reset/deleted.");
// This pref is not going to be reset or deleted as there's no "control pref" // This pref is not going to be reset or deleted as there's no "control pref"
// in either the incoming record or locally. // in either the incoming record or locally.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"testing.deleted-without-control-pref", "testing.deleted-without-control-pref",
"I'm deleted-without-control-pref" "I'm deleted-without-control-pref"
); );
// Another pref with only a local control pref. // Another pref with only a local control pref.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"testing.deleted-with-local-control-pref", "testing.deleted-with-local-control-pref",
"I'm deleted-with-local-control-pref" "I'm deleted-with-local-control-pref"
); );
@ -166,7 +166,7 @@ add_task(async function run_test() {
true true
); );
// And a pref without a local control pref but one that's incoming. // And a pref without a local control pref but one that's incoming.
Services.prefs.setCharPref( Services.prefs.setStringPref(
"testing.deleted-with-incoming-control-pref", "testing.deleted-with-incoming-control-pref",
"I'm deleted-with-incoming-control-pref" "I'm deleted-with-incoming-control-pref"
); );
@ -197,12 +197,12 @@ add_task(async function run_test() {
await store.update(record); await store.update(record);
Assert.strictEqual(Services.prefs.getIntPref("testing.int"), 42); Assert.strictEqual(Services.prefs.getIntPref("testing.int"), 42);
Assert.strictEqual( Assert.strictEqual(
Services.prefs.getCharPref("testing.string"), Services.prefs.getStringPref("testing.string"),
"im in ur prefs" "im in ur prefs"
); );
Assert.strictEqual(Services.prefs.getBoolPref("testing.bool"), false); Assert.strictEqual(Services.prefs.getBoolPref("testing.bool"), false);
Assert.strictEqual( Assert.strictEqual(
Services.prefs.getCharPref("testing.deleted-without-control-pref"), Services.prefs.getStringPref("testing.deleted-without-control-pref"),
"I'm deleted-without-control-pref" "I'm deleted-without-control-pref"
); );
Assert.strictEqual( Assert.strictEqual(
@ -210,11 +210,13 @@ add_task(async function run_test() {
Ci.nsIPrefBranch.PREF_INVALID Ci.nsIPrefBranch.PREF_INVALID
); );
Assert.strictEqual( Assert.strictEqual(
Services.prefs.getCharPref("testing.deleted-with-incoming-control-pref"), Services.prefs.getStringPref(
"testing.deleted-with-incoming-control-pref"
),
"I'm deleted-with-incoming-control-pref" "I'm deleted-with-incoming-control-pref"
); );
Assert.strictEqual( Assert.strictEqual(
Services.prefs.getCharPref("testing.dont.change"), Services.prefs.getStringPref("testing.dont.change"),
"Please don't change me." "Please don't change me."
); );
Assert.strictEqual( Assert.strictEqual(
@ -319,7 +321,7 @@ add_task(async function test_incoming_sets_seen() {
do_get_file("prefs_test_prefs_store.js") do_get_file("prefs_test_prefs_store.js")
); );
const defaultValue = "the value"; const defaultValue = "the value";
Assert.equal(Services.prefs.getCharPref("testing.seen"), defaultValue); Assert.equal(Services.prefs.getStringPref("testing.seen"), defaultValue);
let record = await store.createRecord(PREFS_GUID, "prefs"); let record = await store.createRecord(PREFS_GUID, "prefs");
// Haven't seen a non-default value before, so remains null. // Haven't seen a non-default value before, so remains null.
@ -358,25 +360,28 @@ add_task(async function test_outgoing_when_changed() {
do_get_file("prefs_test_prefs_store.js") do_get_file("prefs_test_prefs_store.js")
); );
const defaultValue = "the value"; const defaultValue = "the value";
Assert.equal(Services.prefs.getCharPref("testing.seen"), defaultValue); Assert.equal(Services.prefs.getStringPref("testing.seen"), defaultValue);
let record = await store.createRecord(PREFS_GUID, "prefs"); let record = await store.createRecord(PREFS_GUID, "prefs");
// Haven't seen a non-default value before, so remains null. // Haven't seen a non-default value before, so remains null.
Assert.strictEqual(record.value["testing.seen"], null); Assert.strictEqual(record.value["testing.seen"], null);
// Change the value. // Change the value.
Services.prefs.setCharPref("testing.seen", "new value"); Services.prefs.setStringPref("testing.seen", "new value");
record = await store.createRecord(PREFS_GUID, "prefs"); record = await store.createRecord(PREFS_GUID, "prefs");
// creating the record toggled that "seen" pref. // creating the record toggled that "seen" pref.
Assert.strictEqual( Assert.strictEqual(
Services.prefs.getBoolPref("services.sync.prefs.sync-seen.testing.seen"), Services.prefs.getBoolPref("services.sync.prefs.sync-seen.testing.seen"),
true true
); );
Assert.strictEqual(Services.prefs.getCharPref("testing.seen"), "new value"); Assert.strictEqual(Services.prefs.getStringPref("testing.seen"), "new value");
// Resetting the pref does not change that seen value. // Resetting the pref does not change that seen value.
Services.prefs.clearUserPref("testing.seen"); Services.prefs.clearUserPref("testing.seen");
Assert.strictEqual(Services.prefs.getCharPref("testing.seen"), defaultValue); Assert.strictEqual(
Services.prefs.getStringPref("testing.seen"),
defaultValue
);
record = await store.createRecord(PREFS_GUID, "prefs"); record = await store.createRecord(PREFS_GUID, "prefs");
Assert.strictEqual( Assert.strictEqual(

View file

@ -80,7 +80,7 @@ add_task(async function run_test() {
await tracker.clearChangedIDs(); await tracker.clearChangedIDs();
_("Changing some other random pref won't do anything."); _("Changing some other random pref won't do anything.");
Services.prefs.setCharPref("testing.other", "blergh"); Services.prefs.setStringPref("testing.other", "blergh");
await tracker.asyncObserver.promiseObserversComplete(); await tracker.asyncObserver.promiseObserversComplete();
Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE * 3); Assert.equal(tracker.score, SCORE_INCREMENT_XLARGE * 3);
Assert.equal(tracker.modified, false); Assert.equal(tracker.modified, false);

View file

@ -41,7 +41,7 @@ function triggerRedirect() {
let prefs = Services.prefs.getBranch("network.proxy."); let prefs = Services.prefs.getBranch("network.proxy.");
prefs.setIntPref("type", 2); prefs.setIntPref("type", 2);
prefs.setCharPref("autoconfig_url", "data:text/plain," + PROXY_FUNCTION); prefs.setStringPref("autoconfig_url", "data:text/plain," + PROXY_FUNCTION);
} }
add_task(async function test_headers_copied() { add_task(async function test_headers_copied() {

View file

@ -73,7 +73,7 @@ add_task(async function test_desktop_post() {
add_task(async function test_desktop_get() { add_task(async function test_desktop_get() {
_("Testing async."); _("Testing async.");
Svc.PrefBranch.setCharPref("client.type", "desktop"); Svc.PrefBranch.setStringPref("client.type", "desktop");
let r = new Resource(server.baseURI + "/1.1/johndoe/storage/meta/global"); let r = new Resource(server.baseURI + "/1.1/johndoe/storage/meta/global");
await r.get(); await r.get();
_("User-Agent: " + ua); _("User-Agent: " + ua);
@ -83,7 +83,7 @@ add_task(async function test_desktop_get() {
add_task(async function test_mobile_get() { add_task(async function test_mobile_get() {
_("Testing mobile."); _("Testing mobile.");
Svc.PrefBranch.setCharPref("client.type", "mobile"); Svc.PrefBranch.setStringPref("client.type", "mobile");
let r = new Resource(server.baseURI + "/1.1/johndoe/storage/meta/global"); let r = new Resource(server.baseURI + "/1.1/johndoe/storage/meta/global");
await r.get(); await r.get();
_("User-Agent: " + ua); _("User-Agent: " + ua);

View file

@ -5,8 +5,8 @@ const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs" "resource://gre/modules/AppConstants.sys.mjs"
); );
// Svc.PrefBranch.setCharPref("services.sync.log.appender.dump", "All"); // Svc.PrefBranch.setStringPref("services.sync.log.appender.dump", "All");
Svc.PrefBranch.setCharPref("registerEngines", "Tab,Bookmarks,Form,History"); Svc.PrefBranch.setStringPref("registerEngines", "Tab,Bookmarks,Form,History");
add_task(async function run_test() { add_task(async function run_test() {
validate_all_future_pings(); validate_all_future_pings();

View file

@ -110,17 +110,17 @@ add_task(async function test_lastSync() {
// Floats are properly stored as floats and synced with the preference // Floats are properly stored as floats and synced with the preference
await engine.setLastSync(123.45); await engine.setLastSync(123.45);
Assert.equal(await engine.getLastSync(), 123.45); Assert.equal(await engine.getLastSync(), 123.45);
Assert.equal(Svc.PrefBranch.getCharPref("steam.lastSync"), "123.45"); Assert.equal(Svc.PrefBranch.getStringPref("steam.lastSync"), "123.45");
// Integer is properly stored // Integer is properly stored
await engine.setLastSync(67890); await engine.setLastSync(67890);
Assert.equal(await engine.getLastSync(), 67890); Assert.equal(await engine.getLastSync(), 67890);
Assert.equal(Svc.PrefBranch.getCharPref("steam.lastSync"), "67890"); Assert.equal(Svc.PrefBranch.getStringPref("steam.lastSync"), "67890");
// resetLastSync() resets the value (and preference) to 0 // resetLastSync() resets the value (and preference) to 0
await engine.resetLastSync(); await engine.resetLastSync();
Assert.equal(await engine.getLastSync(), 0); Assert.equal(await engine.getLastSync(), 0);
Assert.equal(Svc.PrefBranch.getCharPref("steam.lastSync"), "0"); Assert.equal(Svc.PrefBranch.getStringPref("steam.lastSync"), "0");
} finally { } finally {
for (const pref of Svc.PrefBranch.getChildList("")) { for (const pref of Svc.PrefBranch.getChildList("")) {
Svc.PrefBranch.clearUserPref(pref); Svc.PrefBranch.clearUserPref(pref);

View file

@ -22,7 +22,7 @@ async function clean(engine) {
for (const pref of Svc.PrefBranch.getChildList("")) { for (const pref of Svc.PrefBranch.getChildList("")) {
Svc.PrefBranch.clearUserPref(pref); Svc.PrefBranch.clearUserPref(pref);
} }
Svc.PrefBranch.setCharPref("log.logger.engine.rotary", "Trace"); Svc.PrefBranch.setStringPref("log.logger.engine.rotary", "Trace");
Service.recordManager.clearCache(); Service.recordManager.clearCache();
await engine._tracker.clearChangedIDs(); await engine._tracker.clearChangedIDs();
await engine.finalize(); await engine.finalize();
@ -78,7 +78,7 @@ async function createServerAndConfigureClient() {
add_task(async function setup() { add_task(async function setup() {
await generateNewKeys(Service.collectionKeys); await generateNewKeys(Service.collectionKeys);
Svc.PrefBranch.setCharPref("log.logger.engine.rotary", "Trace"); Svc.PrefBranch.setStringPref("log.logger.engine.rotary", "Trace");
}); });
add_task(async function test_syncStartup_emptyOrOutdatedGlobalsResetsSync() { add_task(async function test_syncStartup_emptyOrOutdatedGlobalsResetsSync() {

View file

@ -469,7 +469,7 @@ add_task(async function test_handleSyncError() {
await setUp(server); await setUp(server);
// Force sync to fail. // Force sync to fail.
Svc.PrefBranch.setCharPref("firstSync", "notReady"); Svc.PrefBranch.setStringPref("firstSync", "notReady");
_("Ensure expected initial environment."); _("Ensure expected initial environment.");
Assert.equal(scheduler._syncErrors, 0); Assert.equal(scheduler._syncErrors, 0);
@ -523,7 +523,7 @@ add_task(async function test_handleSyncError() {
_("Arrange for a successful sync to reset the scheduler error count"); _("Arrange for a successful sync to reset the scheduler error count");
let promiseObserved = promiseOneObserver("weave:service:sync:finish"); let promiseObserved = promiseOneObserver("weave:service:sync:finish");
Svc.PrefBranch.setCharPref("firstSync", "wipeRemote"); Svc.PrefBranch.setStringPref("firstSync", "wipeRemote");
scheduler.scheduleNextSync(-1); scheduler.scheduleNextSync(-1);
await promiseObserved; await promiseObserved;
await cleanUpAndGo(server); await cleanUpAndGo(server);
@ -662,7 +662,7 @@ add_task(async function test_no_autoconnect_during_wizard() {
await setUp(server); await setUp(server);
// Simulate the Sync setup wizard. // Simulate the Sync setup wizard.
Svc.PrefBranch.setCharPref("firstSync", "notReady"); Svc.PrefBranch.setStringPref("firstSync", "notReady");
// Ensure we don't actually try to sync (or log in for that matter). // Ensure we don't actually try to sync (or log in for that matter).
function onLoginStart() { function onLoginStart() {

View file

@ -275,7 +275,7 @@ add_task(async function run_sync_on_tab_change_test() {
await tracker.clearChangedIDs(); await tracker.clearChangedIDs();
clearQuickWriteTimer(tracker); clearQuickWriteTimer(tracker);
Svc.PrefBranch.setCharPref( Svc.PrefBranch.setStringPref(
"engine.tabs.filteredSchemes", "engine.tabs.filteredSchemes",
// Removing the about scheme for this test // Removing the about scheme for this test
"resource|chrome|file|blob|moz-extension" "resource|chrome|file|blob|moz-extension"

View file

@ -34,7 +34,7 @@ add_task(async function test_isReady_unconfigured() {
add_task(async function test_isReady_signedin() { add_task(async function test_isReady_signedin() {
UIState.reset(); UIState.reset();
Services.prefs.setCharPref("services.sync.username", "foo"); Services.prefs.setStringPref("services.sync.username", "foo");
let refreshState = sinon.spy(UIStateInternal, "refreshState"); let refreshState = sinon.spy(UIStateInternal, "refreshState");
@ -58,7 +58,7 @@ add_task(async function test_refreshState_signedin() {
const fxAccountsOrig = UIStateInternal.fxAccounts; const fxAccountsOrig = UIStateInternal.fxAccounts;
const now = new Date().toString(); const now = new Date().toString();
Services.prefs.setCharPref("services.sync.lastSync", now); Services.prefs.setStringPref("services.sync.lastSync", now);
UIStateInternal.syncing = false; UIStateInternal.syncing = false;
UIStateInternal.fxAccounts = { UIStateInternal.fxAccounts = {
@ -119,7 +119,7 @@ add_task(async function test_refreshState_signedin_profile_unavailable() {
const fxAccountsOrig = UIStateInternal.fxAccounts; const fxAccountsOrig = UIStateInternal.fxAccounts;
const now = new Date().toString(); const now = new Date().toString();
Services.prefs.setCharPref("services.sync.lastSync", now); Services.prefs.setStringPref("services.sync.lastSync", now);
Services.prefs.setStringPref("services.sync.username", "test@test.com"); Services.prefs.setStringPref("services.sync.username", "test@test.com");
UIStateInternal.syncing = false; UIStateInternal.syncing = false;
@ -251,7 +251,7 @@ async function configureUIState(syncing, lastSync = new Date()) {
const fxAccountsOrig = UIStateInternal.fxAccounts; const fxAccountsOrig = UIStateInternal.fxAccounts;
UIStateInternal._syncing = syncing; UIStateInternal._syncing = syncing;
Services.prefs.setCharPref("services.sync.lastSync", lastSync.toString()); Services.prefs.setStringPref("services.sync.lastSync", lastSync.toString());
Services.prefs.setStringPref("services.sync.username", "test@test.com"); Services.prefs.setStringPref("services.sync.username", "test@test.com");
UIStateInternal.fxAccounts = { UIStateInternal.fxAccounts = {
@ -286,7 +286,7 @@ add_task(async function test_syncFinished() {
ok(oldState.syncing); ok(oldState.syncing);
let uiUpdateObserved = observeUIUpdate(); let uiUpdateObserved = observeUIUpdate();
Services.prefs.setCharPref("services.sync.lastSync", new Date().toString()); Services.prefs.setStringPref("services.sync.lastSync", new Date().toString());
Services.obs.notifyObservers(null, "weave:service:sync:finish"); Services.obs.notifyObservers(null, "weave:service:sync:finish");
await uiUpdateObserved; await uiUpdateObserved;

View file

@ -25,9 +25,9 @@ export var Logger = {
} }
if (path) { if (path) {
Services.prefs.setCharPref("tps.logfile", path); Services.prefs.setStringPref("tps.logfile", path);
} else { } else {
path = Services.prefs.getCharPref("tps.logfile"); path = Services.prefs.getStringPref("tps.logfile");
} }
this._file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); this._file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);

View file

@ -68,7 +68,7 @@ Preference.prototype = {
"string", "string",
"Wrong type used for preference value" "Wrong type used for preference value"
); );
Services.prefs.setCharPref(this.name, this.value); Services.prefs.setStringPref(this.name, this.value);
break; break;
case Ci.nsIPrefBranch.PREF_BOOL: case Ci.nsIPrefBranch.PREF_BOOL:
Logger.AssertEqual( Logger.AssertEqual(
@ -100,7 +100,7 @@ Preference.prototype = {
value = Services.prefs.getIntPref(this.name); value = Services.prefs.getIntPref(this.name);
break; break;
case Ci.nsIPrefBranch.PREF_STRING: case Ci.nsIPrefBranch.PREF_STRING:
value = Services.prefs.getCharPref(this.name); value = Services.prefs.getStringPref(this.name);
break; break;
case Ci.nsIPrefBranch.PREF_BOOL: case Ci.nsIPrefBranch.PREF_BOOL:
value = Services.prefs.getBoolPref(this.name); value = Services.prefs.getBoolPref(this.name);

View file

@ -190,7 +190,7 @@ export var TPS = {
this._setupComplete = true; this._setupComplete = true;
if (this._syncWipeAction) { if (this._syncWipeAction) {
lazy.Weave.Svc.PrefBranch.setCharPref( lazy.Weave.Svc.PrefBranch.setStringPref(
"firstSync", "firstSync",
this._syncWipeAction this._syncWipeAction
); );
@ -1103,7 +1103,7 @@ export var TPS = {
*/ */
async _executeTestPhase(file, phase, settings) { async _executeTestPhase(file, phase, settings) {
try { try {
this.config = JSON.parse(Services.prefs.getCharPref("tps.config")); this.config = JSON.parse(Services.prefs.getStringPref("tps.config"));
// parse the test file // parse the test file
Services.scriptloader.loadSubScript(file, this); Services.scriptloader.loadSubScript(file, this);
this._currentPhase = phase; this._currentPhase = phase;
@ -1375,7 +1375,7 @@ export var TPS = {
// also handle it via the "weave:service:setup-complete" notification. // also handle it via the "weave:service:setup-complete" notification.
if (wipeAction) { if (wipeAction) {
this._syncWipeAction = wipeAction; this._syncWipeAction = wipeAction;
lazy.Weave.Svc.PrefBranch.setCharPref("firstSync", wipeAction); lazy.Weave.Svc.PrefBranch.setStringPref("firstSync", wipeAction);
} else { } else {
lazy.Weave.Svc.PrefBranch.clearUserPref("firstSync"); lazy.Weave.Svc.PrefBranch.clearUserPref("firstSync");
} }