Bug 1621423 - Allow adding webextension restricted domains via policy. r=mixedpuppy

Differential Revision: https://phabricator.services.mozilla.com/D74304
This commit is contained in:
Michael Kaply 2020-05-08 21:01:58 +00:00
Родитель 9f699a4611
Коммит 990a4a43ce
3 изменённых файлов: 34 добавлений и 0 удалений

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

@ -855,6 +855,17 @@ var Policies = {
// Block about:debugging
blockAboutPage(manager, "about:debugging");
}
if ("restricted_domains" in extensionSettings["*"]) {
let restrictedDomains = Services.prefs
.getCharPref("extensions.webextensions.restrictedDomains")
.split(",");
setAndLockPref(
"extensions.webextensions.restrictedDomains",
restrictedDomains
.concat(extensionSettings["*"].restricted_domains)
.join(",")
);
}
}
let addons = await AddonManager.getAllAddons();
let allowedExtensions = [];

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

@ -437,6 +437,12 @@
"items": {
"type": "string"
}
},
"restricted_domains": {
"type": "array",
"items": {
"type": "string"
}
}
}
}

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

@ -202,3 +202,20 @@ add_task(async function test_extensionsettings_string() {
let extensionSettings = Services.policies.getExtensionSettings("*");
equal(extensionSettings.installation_mode, "blocked");
});
add_task(async function test_extensionsettings_string() {
let restrictedDomains = Services.prefs.getCharPref(
"extensions.webextensions.restrictedDomains"
);
await setupPolicyEngineWithJson({
policies: {
ExtensionSettings:
'{"*": {"restricted_domains": ["example.com","example.org"]}}',
},
});
let newRestrictedDomains = Services.prefs.getCharPref(
"extensions.webextensions.restrictedDomains"
);
equal(newRestrictedDomains, restrictedDomains + ",example.com,example.org");
});