зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1595860 add a utility function to map pref names to extension settings r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D57909 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
96dd4c966d
Коммит
c5498f5347
|
@ -234,6 +234,29 @@ this.ExtensionPreferencesManager = {
|
|||
return defaultPreferences.get(prefName);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a map of prefName to setting Name for use in about:config, about:preferences or
|
||||
* other areas of Firefox that need to know whether a specific pref is controlled by an
|
||||
* extension.
|
||||
*
|
||||
* Given a prefName, you can get the settingName. Call EPM.getSetting(settingName) to
|
||||
* get the details of the setting, including which id if any is in control of the
|
||||
* setting.
|
||||
*
|
||||
* @returns {Promise}
|
||||
* Resolves to a Map of prefName->settingName
|
||||
*/
|
||||
async getManagedPrefDetails() {
|
||||
await Management.asyncLoadSettingsModules();
|
||||
let prefs = new Map();
|
||||
settingsMap.forEach((setting, name) => {
|
||||
for (let prefName of setting.prefNames) {
|
||||
prefs.set(prefName, name);
|
||||
}
|
||||
});
|
||||
return prefs;
|
||||
},
|
||||
|
||||
/**
|
||||
* Indicates that an extension would like to change the value of a previously
|
||||
* defined setting.
|
||||
|
|
|
@ -869,3 +869,19 @@ add_task(async function test_preference_select() {
|
|||
await three.unload();
|
||||
await promiseShutdownManager();
|
||||
});
|
||||
|
||||
add_task(async function test_preference_select() {
|
||||
let prefNames = await ExtensionPreferencesManager.getManagedPrefDetails();
|
||||
// Just check a subset of settings that are in this test file.
|
||||
Assert.ok(prefNames.size > 0, "some prefs exist");
|
||||
for (let settingName in SETTINGS) {
|
||||
let setting = SETTINGS[settingName];
|
||||
for (let prefName of setting.prefNames) {
|
||||
Assert.equal(
|
||||
prefNames.get(prefName),
|
||||
settingName,
|
||||
"setting retrieved prefNames"
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче