Bug 629521 - Extensions and themes which are marked to get removed are not grouped but remain at the original location; r,a=Mossop

This commit is contained in:
Mike Conley 2011-02-03 15:15:33 -05:00
Родитель 884fcc0eb4
Коммит d1532ce7c1
2 изменённых файлов: 86 добавлений и 33 удалений

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

@ -1206,7 +1206,28 @@ function sortElements(aElements, aSortBy, aAscending) {
const DATE_FIELDS = ["updateDate"];
const NUMERIC_FIELDS = ["size", "relevancescore", "purchaseAmount"];
const UISTATE_ORDER = ["enabled", "incompatible", "disabled", "blocked"]
// We're going to group add-ons into the following buckets:
//
// enabledInstalled
// * Enabled
// * Incompatible but enabled because compatibility checking is off
// * Waiting to be installed
// * Waiting to be enabled
//
// pendingDisable
// * Waiting to be disabled
//
// pendingUninstall
// * Waiting to be removed
//
// disabledIncompatibleBlocked
// * Disabled
// * Incompatible
// * Blocklisted
const UISTATE_ORDER = ["enabled", "pendingDisable", "pendingUninstall",
"disabled"];
function dateCompare(a, b) {
var aTime = a.getTime();
@ -1245,18 +1266,19 @@ function sortElements(aElements, aSortBy, aAscending) {
addon = aObj.mAddon || aObj.mInstall;
if (!addon)
return null;
if (aKey == "uiState") {
if (addon.isActive)
return "enabled";
else if (!addon.isCompatible)
return "incompatible";
else if (addon.blocklistState == Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
return "disabled";
else if (addon.isCompatible &&
addon.blocklistState != Ci.nsIBlocklistService.STATE_NOT_BLOCKED)
return "blocked";
}
if (aKey == "uiState") {
if (addon.pendingOperations == AddonManager.PENDING_DISABLE)
return "pendingDisable";
if (addon.pendingOperations == AddonManager.PENDING_UNINSTALL)
return "pendingUninstall";
if (!addon.isActive &&
(addon.pendingOperations != AddonManager.PENDING_ENABLE &&
addon.pendingOperations != AddonManager.PENDING_INSTALL))
return "disabled";
else
return "enabled";
}
return addon[aKey];
}

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

@ -13,67 +13,81 @@ function test() {
gProvider = new MockProvider();
gProvider.createAddons([{
// Enabled extensions
// enabledInstalled group
// * Enabled
// * Incompatible but enabled because compatibility checking is off
// * Waiting to be installed
// * Waiting to be enabled
id: "test1@tests.mozilla.org",
name: "Test add-on",
description: "foo",
updateDate: new Date(2010, 04, 02, 00, 00, 00),
size: 1
size: 1,
pendingOperations: AddonManager.PENDING_NONE,
}, {
id: "test2@tests.mozilla.org",
name: "a first add-on",
description: "foo",
updateDate: new Date(2010, 04, 01, 23, 59, 59),
size: 0265
size: 0265,
pendingOperations: AddonManager.PENDING_UPGRADE,
isActive: true,
isCompatible: false,
}, {
id: "test3@tests.mozilla.org",
name: "\u010Cesk\u00FD slovn\u00EDk", // Český slovník
description: "foo",
updateDate: new Date(2010, 04, 02, 00, 00, 01),
size: 12
size: 12,
pendingOperations: AddonManager.PENDING_INSTALL,
isActive: false,
}, {
id: "test4@tests.mozilla.org",
name: "canadian dictionary",
updateDate: new Date(1970, 0, 01, 00, 00, 00),
description: "foo",
isActive: true,
}, {
id: "test5@tests.mozilla.org",
name: "croatian dictionary",
description: "foo",
updateDate: new Date(2012, 12, 12, 00, 00, 00),
size: 5
size: 5,
pendingOperations: AddonManager.PENDING_ENABLE,
isActive: false,
}, {
// Incompatible, disabled extensions
// pendingDisable group
// * Waiting to be disabled
id: "test6@tests.mozilla.org",
name: "orange Add-on",
description: "foo",
updateDate: new Date(2010, 04, 02, 00, 00, 00),
size: 142,
isCompatible: false,
isActive: false,
isActive: true,
pendingOperations: AddonManager.PENDING_DISABLE,
}, {
id: "test7@tests.mozilla.org",
name: "Blue Add-on",
description: "foo",
updateDate: new Date(2010, 04, 01, 23, 59, 59),
size: 65,
isCompatible: false,
isActive: false,
isActive: true,
pendingOperations: AddonManager.PENDING_DISABLE,
}, {
id: "test8@tests.mozilla.org",
name: "Green Add-on",
description: "foo",
updateDate: new Date(2010, 04, 03, 00, 00, 01),
size: 125,
isCompatible: false,
isActive: false,
pendingOperations: AddonManager.PENDING_DISABLE,
}, {
id: "test9@tests.mozilla.org",
name: "red Add-on",
updateDate: new Date(2011, 04, 01, 00, 00, 00),
description: "foo",
isCompatible: false,
isActive: false,
pendingOperations: AddonManager.PENDING_DISABLE,
}, {
id: "test10@tests.mozilla.org",
name: "Purple Add-on",
@ -81,22 +95,26 @@ function test() {
updateDate: new Date(2012, 12, 12, 00, 00, 00),
size: 56,
isCompatible: false,
isActive: false,
pendingOperations: AddonManager.PENDING_DISABLE,
}, {
// Disabled, compatible extensions
// pendingUninstall group
// * Waiting to be removed
id: "test11@tests.mozilla.org",
name: "amber Add-on",
description: "foo",
updateDate: new Date(1978, 04, 02, 00, 00, 00),
size: 142,
isActive: false,
appDisabled: true,
pendingOperations: AddonManager.PENDING_UNINSTALL,
}, {
id: "test12@tests.mozilla.org",
name: "Salmon Add-on",
name: "Salmon Add-on - pending disable",
description: "foo",
updateDate: new Date(2054, 04, 01, 23, 59, 59),
size: 65,
isActive: false,
isActive: true,
pendingOperations: AddonManager.PENDING_UNINSTALL,
}, {
id: "test13@tests.mozilla.org",
name: "rose Add-on",
@ -104,12 +122,16 @@ function test() {
updateDate: new Date(2010, 04, 02, 00, 00, 01),
size: 125,
isActive: false,
userDisabled: true,
pendingOperations: AddonManager.PENDING_UNINSTALL,
}, {
id: "test14@tests.mozilla.org",
name: "Violet Add-on",
updateDate: new Date(2010, 05, 01, 00, 00, 00),
description: "foo",
isActive: false,
appDisabled: true,
pendingOperations: AddonManager.PENDING_UNINSTALL,
}, {
id: "test15@tests.mozilla.org",
name: "white Add-on",
@ -117,15 +139,20 @@ function test() {
updateDate: new Date(2010, 04, 12, 00, 00, 00),
size: 56,
isActive: false,
userDisabled: true,
pendingOperations: AddonManager.PENDING_UNINSTALL,
}, {
// Blocked extensions
// disabledIncompatibleBlocked group
// * Disabled
// * Incompatible
// * Blocklisted
id: "test16@tests.mozilla.org",
name: "grimsby Add-on",
description: "foo",
updateDate: new Date(2010, 04, 01, 00, 00, 00),
size: 142,
isActive: false,
blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
appDisabled: true,
}, {
id: "test17@tests.mozilla.org",
name: "beamsville Add-on",
@ -133,7 +160,7 @@ function test() {
updateDate: new Date(2010, 04, 8, 23, 59, 59),
size: 65,
isActive: false,
blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
userDisabled: true,
}, {
id: "test18@tests.mozilla.org",
name: "smithville Add-on",
@ -141,6 +168,7 @@ function test() {
updateDate: new Date(2010, 04, 03, 00, 00, 01),
size: 125,
isActive: false,
userDisabled: true,
blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED,
}, {
id: "test19@tests.mozilla.org",
@ -148,7 +176,9 @@ function test() {
updateDate: new Date(2010, 04, 02, 00, 00, 00),
description: "foo",
isActive: false,
blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED,
appDisabled: true,
isCompatible: false,
blocklistState: Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
}, {
id: "test20@tests.mozilla.org",
name: "silverdale Add-on",
@ -156,9 +186,11 @@ function test() {
updateDate: new Date(2010, 04, 12, 00, 00, 00),
size: 56,
isActive: false,
appDisabled: true,
blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
}]);
open_manager("addons://list/extension", function(aWindow) {
gManagerWindow = aWindow;
run_next_test();
@ -224,7 +256,6 @@ add_test(function() {
"test20@tests.mozilla.org",
"test18@tests.mozilla.org",
]);
run_next_test();
});