Bug 1297028 Expose Addon.canUninstall flag to content r=bz,rhelmer

MozReview-Commit-ID: Ec6QPj9h9k7

--HG--
extra : rebase_source : 747cb4ce54d5e8d0cc7bc2cc3654471b3b07bfcb
This commit is contained in:
Andrew Swan 2016-08-23 19:24:15 -07:00
Родитель 268da026f6
Коммит 4297232844
3 изменённых файлов: 18 добавлений и 1 удалений

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

@ -24,6 +24,8 @@ interface Addon {
readonly attribute boolean isEnabled;
// If the add-on is currently active in the browser.
readonly attribute boolean isActive;
// If the add-on may be uninstalled
readonly attribute boolean canUninstall;
Promise<boolean> uninstall();
Promise<void> setEnabled(boolean value);

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

@ -335,6 +335,7 @@ function webAPIForAddon(addon) {
// A few properties are computed for a nicer API
result.isEnabled = !addon.userDisabled;
result.canUninstall = Boolean(addon.permissions & AddonManager.PERM_CAN_UNINSTALL);
return result;
}

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

@ -17,7 +17,7 @@ function testWithAPI(task) {
let gProvider = new MockProvider();
gProvider.createAddons([{
let addons = gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "Test add-on 1",
version: "2.1",
@ -41,8 +41,18 @@ gProvider.createAddons([{
type: "extension",
userDisabled: true,
isActive: false,
}, {
id: "addon4@tests.mozilla.org",
name: "Test add-on 4",
version: "1",
description: "Longer description",
type: "extension",
userDisabled: false,
isActive: true,
}]);
addons[3].permissions &= ~AddonManager.PERM_CAN_UNINSTALL;
function API_getAddonByID(browser, id) {
return ContentTask.spawn(browser, id, function*(id) {
let addon = yield content.navigator.mozAddonManager.getAddonByID(id);
@ -67,6 +77,10 @@ add_task(testWithAPI(function*(browser) {
case "isEnabled":
realVal = !real.userDisabled;
break;
case "canUninstall":
realVal = Boolean(real.permissions & AddonManager.PERM_CAN_UNINSTALL);
break;
}
// null and undefined don't compare well so stringify them first