Bug 1599205 Part 2: fix onChange event details object r=zombie

Differential Revision: https://phabricator.services.mozilla.com/D54639

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Shane Caraveo 2019-11-26 19:43:38 +00:00
Родитель 234c7eb128
Коммит 38d51e8a42
5 изменённых файлов: 27 добавлений и 16 удалений

Просмотреть файл

@ -561,9 +561,7 @@ this.ExtensionPreferencesManager = {
name: `${name}.onChange`,
register: fire => {
let listener = async () => {
fire.async({
details: await settingsAPI.get({}),
});
fire.async(await settingsAPI.get({}));
};
Management.on(`extension-setting-changed:${name}`, listener);
return () => {

Просмотреть файл

@ -253,10 +253,8 @@ this.browserSettings = class extends ExtensionAPI {
register: fire => {
let listener = () => {
fire.async({
details: {
levelOfControl: "not_controllable",
value: Services.prefs.getStringPref(HOMEPAGE_URL_PREF),
},
});
};
Services.prefs.addObserver(HOMEPAGE_URL_PREF, listener);
@ -304,10 +302,8 @@ this.browserSettings = class extends ExtensionAPI {
register: fire => {
let listener = (text, id) => {
fire.async({
details: {
levelOfControl: "not_controllable",
value: aboutNewTabService.newTabURL,
},
});
};
Services.obs.addObserver(listener, "newtab-url-changed");

Просмотреть файл

@ -119,10 +119,8 @@ this.captivePortal = class extends ExtensionAPI {
register: fire => {
let listener = (text, id) => {
fire.async({
details: {
levelOfControl: "not_controllable",
value: Services.prefs.getStringPref(CAPTIVE_URL_PREF),
},
});
};
Services.prefs.addObserver(CAPTIVE_URL_PREF, listener);

Просмотреть файл

@ -48,7 +48,7 @@ add_task(async function test_browser_settings() {
if (!listeners.has(apiName)) {
apiObj.onChange.addListener(details => {
browser.test.sendMessage("onChange", {
details: details.details,
details,
setting: apiName,
});
});

Просмотреть файл

@ -4,6 +4,9 @@
add_task(async function test_url_get_without_set() {
async function background() {
browser.captivePortal.canonicalURL.onChange.addListener(details => {
browser.test.sendMessage("url", details);
});
let url = await browser.captivePortal.canonicalURL.get({});
browser.test.sendMessage("url", url);
}
@ -30,5 +33,21 @@ add_task(async function test_url_get_without_set() {
"The canonicalURL setting has the expected levelOfControl."
);
Services.prefs.setStringPref(
"captivedetect.canonicalURL",
"http://example.com"
);
url = await extension.awaitMessage("url");
equal(
url.value,
"http://example.com",
"The canonicalURL setting has the expected value."
);
equal(
url.levelOfControl,
"not_controllable",
"The canonicalURL setting has the expected levelOfControl."
);
await extension.unload();
});