Bug 1859544 - Fix IMServices.core.getProtocols returning an empty list. r=mkmelin
Differential Revision: https://phabricator.services.mozilla.com/D191197 --HG-- extra : amend_source : b461a1e236bccfc35fc764815decf87d64ac4261 extra : absorb_source : 42d65fdb67b9c9dcd4a722ac24fb2c8984e8f884
This commit is contained in:
Родитель
f456cbb8fb
Коммит
d2ab715995
|
@ -409,25 +409,20 @@ class CoreService {
|
|||
throw Components.Exception("", Cr.NS_ERROR_NOT_INITIALIZED);
|
||||
}
|
||||
|
||||
const protocols = [];
|
||||
for (const id of Object.keys(protocols)) {
|
||||
// If the preference is set to disable this prpl, don't show it in the
|
||||
// full list of protocols.
|
||||
const pref = "chat.prpls." + id + ".disable";
|
||||
if (
|
||||
Services.prefs.getPrefType(pref) == Services.prefs.PREF_BOOL &&
|
||||
Services.prefs.getBoolPref(pref)
|
||||
) {
|
||||
this.LOG("Disabling prpl: " + id);
|
||||
continue;
|
||||
}
|
||||
|
||||
const proto = this.getProtocolById(id);
|
||||
if (proto) {
|
||||
protocols.push(proto);
|
||||
}
|
||||
}
|
||||
return protocols;
|
||||
return (
|
||||
Object.keys(protocols)
|
||||
// If the preference is set to disable this prpl, don't show it in the
|
||||
// full list of protocols.
|
||||
.filter(protocolId => {
|
||||
const pref = `chat.prpls.${protocolId}.disable`;
|
||||
return (
|
||||
Services.prefs.getPrefType(pref) != Services.prefs.PREF_BOOL ||
|
||||
!Services.prefs.getBoolPref(pref)
|
||||
);
|
||||
})
|
||||
.map(protocolId => this.getProtocolById(protocolId))
|
||||
.filter(Boolean)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
var { IMServices } = ChromeUtils.importESModule(
|
||||
"resource:///modules/IMServices.sys.mjs"
|
||||
);
|
||||
const { updateAppInfo } = ChromeUtils.importESModule(
|
||||
"resource://testing-common/AppInfo.sys.mjs"
|
||||
);
|
||||
|
||||
function run_test() {
|
||||
do_get_profile();
|
||||
|
@ -25,9 +22,6 @@ function run_test() {
|
|||
Services.prefs.setCharPref("mail.server.server1.userName", kAccountName);
|
||||
Services.prefs.setCharPref("mail.server.server1.hostname", kPrplId);
|
||||
try {
|
||||
// Having an implementation of nsIXULAppInfo is required for
|
||||
// IMServices.core.init to work.
|
||||
updateAppInfo();
|
||||
IMServices.core.init();
|
||||
|
||||
const account = IMServices.accounts.getAccountByNumericId(1);
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* 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/. */
|
||||
|
||||
var { IMServices } = ChromeUtils.importESModule(
|
||||
"resource:///modules/IMServices.sys.mjs"
|
||||
);
|
||||
|
||||
const DISABLED_PROTOCOLS = [
|
||||
"prpl-facebook",
|
||||
"prpl-gtalk",
|
||||
"prpl-twitter",
|
||||
"prpl-yahoo",
|
||||
];
|
||||
|
||||
add_setup(() => {
|
||||
do_get_profile();
|
||||
IMServices.core.init();
|
||||
});
|
||||
|
||||
add_task(function test_getProtocols() {
|
||||
const protocols = IMServices.core.getProtocols();
|
||||
|
||||
Assert.ok(Array.isArray(protocols), "Protocols are returned as array");
|
||||
Assert.greaterOrEqual(
|
||||
protocols.length,
|
||||
4,
|
||||
"At least 4 active protocols are returned"
|
||||
);
|
||||
for (const protocol of protocols) {
|
||||
Assert.ok(
|
||||
!DISABLED_PROTOCOLS.includes(protocol.id),
|
||||
`${protocol.id} is not one of the disabled protocols`
|
||||
);
|
||||
}
|
||||
});
|
|
@ -1,9 +1,10 @@
|
|||
[DEFAULT]
|
||||
head =
|
||||
tail =
|
||||
head =
|
||||
tail =
|
||||
|
||||
[test_accounts.js]
|
||||
[test_commands.js]
|
||||
[test_conversations.js]
|
||||
[test_core.js]
|
||||
[test_init.js]
|
||||
[test_logger.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче