Bug 589777: Cannot remove several backgrounds in a row. r=Unfocused, a=blocking-betaN

This commit is contained in:
Dave Townsend 2010-09-13 10:36:12 -07:00
parent 65115f2377
commit c7e1377b69
2 changed files with 98 additions and 16 deletions

View File

@ -1445,13 +1445,18 @@ var gSearchView = {
},
hide: function() {
// Uninstalling add-ons can mutate the list so find the add-ons first then
// uninstall them
var items = [];
var listitem = this._listBox.firstChild;
while (listitem) {
if (listitem.getAttribute("pending") == "uninstall" &&
!listitem.isPending("uninstall"))
listitem.mAddon.uninstall();
items.push(listitem.mAddon);
listitem = listitem.nextSibling;
}
items.forEach(function(aAddon) { aAddon.uninstall(); });
},
getMatchScore: function(aObj, aQuery) {
@ -1611,13 +1616,18 @@ var gListView = {
hide: function() {
gEventManager.unregisterInstallListener(this);
// Uninstalling add-ons can mutate the list so find the add-ons first then
// uninstall them
var items = [];
var listitem = this._listBox.firstChild;
while (listitem) {
if (listitem.getAttribute("pending") == "uninstall" &&
!listitem.isPending("uninstall"))
listitem.mAddon.uninstall();
items.push(listitem.mAddon);
listitem = listitem.nextSibling;
}
items.forEach(function(aAddon) { aAddon.uninstall(); });
},
showEmptyNotice: function(aShow) {

View File

@ -40,6 +40,26 @@ function test() {
name: "Uninstall doesn't need restart 4",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon6@tests.mozilla.org",
name: "Uninstall doesn't need restart 5",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon7@tests.mozilla.org",
name: "Uninstall doesn't need restart 6",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon8@tests.mozilla.org",
name: "Uninstall doesn't need restart 7",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon9@tests.mozilla.org",
name: "Uninstall doesn't need restart 8",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}]);
open_manager(null, function(aWindow) {
@ -712,7 +732,7 @@ add_test(function() {
ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
isnot(button, null, "Should have a restart button");
ok(!button.hidden, "Restart button should not be hidden");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
@ -756,10 +776,11 @@ add_test(function() {
});
});
// Tests that switching away from the list view finalises the uninstall of a
// restartless add-on
// Tests that switching away from the list view finalises the uninstall of
// multiple restartless add-ons
add_test(function() {
var ID = "addon2@tests.mozilla.org";
var ID2 = "addon6@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
@ -788,23 +809,35 @@ add_test(function() {
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
ok(!aAddon.isActive, "Add-on should be inactive");
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
isnot(button, null, "Should have a restart button");
ok(button.hidden, "Restart button should be hidden");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
isnot(button, null, "Should have an undo button");
item = get_item_in_list(ID2, list);
isnot(item, null, "Should have found the add-on in the list");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
isnot(button, null, "Should have a remove button");
ok(!button.disabled, "Button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, gManagerWindow);
gCategoryUtilities.openType("plugin", function() {
is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension");
AddonManager.getAddonByID(ID, function(aAddon) {
AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) {
is(aAddon, null, "Add-on should no longer be installed");
is(aAddon2, null, "Second add-on should no longer be installed");
gCategoryUtilities.openType("extension", function() {
is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
var item = get_item_in_list(ID, list);
is(item, null, "Should not have found the add-on in the list");
item = get_item_in_list(ID2, list);
is(item, null, "Should not have found the second add-on in the list");
run_next_test();
});
@ -814,10 +847,11 @@ add_test(function() {
});
});
// Tests that switching away from the search view finalises the uninstall of a
// restartless add-on
// Tests that switching away from the search view finalises the uninstall of
// multiple restartless add-ons
add_test(function() {
var ID = "addon3@tests.mozilla.org";
var ID2 = "addon7@tests.mozilla.org";
var list = gDocument.getElementById("search-list");
var searchBox = gManagerWindow.document.getElementById("header-search");
@ -854,17 +888,27 @@ add_test(function() {
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
ok(!aAddon.isActive, "Add-on should be inactive");
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
isnot(button, null, "Should have a restart button");
ok(button.hidden, "Restart button should be hidden");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
isnot(button, null, "Should have an undo button");
item = get_item_in_list(ID2, list);
isnot(item, null, "Should have found the add-on in the list");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
isnot(button, null, "Should have a remove button");
ok(!button.disabled, "Button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, gManagerWindow);
gCategoryUtilities.openType("plugin", function() {
is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension");
AddonManager.getAddonByID(ID, function(aAddon) {
AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) {
is(aAddon, null, "Add-on should no longer be installed");
is(aAddon2, null, "Second add-on should no longer be installed");
searchBox.value = "Uninstall";
@ -876,6 +920,8 @@ add_test(function() {
var item = get_item_in_list(ID, list);
is(item, null, "Should not have found the add-on in the list");
item = get_item_in_list(ID2, list);
is(item, null, "Should not have found the second add-on in the list");
run_next_test();
});
@ -886,9 +932,10 @@ add_test(function() {
});
// Tests that closing the manager from the list view finalises the uninstall of
// a restartless add-on
// multiple restartless add-ons
add_test(function() {
var ID = "addon4@tests.mozilla.org";
var ID2 = "addon8@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
@ -917,15 +964,25 @@ add_test(function() {
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
ok(!aAddon.isActive, "Add-on should be inactive");
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
isnot(button, null, "Should have a restart button");
ok(button.hidden, "Restart button should be hidden");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
isnot(button, null, "Should have an undo button");
item = get_item_in_list(ID2, list);
isnot(item, null, "Should have found the add-on in the list");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
isnot(button, null, "Should have a remove button");
ok(!button.disabled, "Button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, gManagerWindow);
close_manager(gManagerWindow, function() {
AddonManager.getAddonByID(ID, function(aAddon) {
AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) {
is(aAddon, null, "Add-on should no longer be installed");
is(aAddon2, null, "Second add-on should no longer be installed");
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
@ -937,6 +994,8 @@ add_test(function() {
var item = get_item_in_list(ID, list);
is(item, null, "Should not have found the add-on in the list");
item = get_item_in_list(ID2, list);
is(item, null, "Should not have found the second add-on in the list");
run_next_test();
});
@ -947,9 +1006,10 @@ add_test(function() {
});
// Tests that closing the manager from the search view finalises the uninstall
// of a restartless add-on
// of multiple restartless add-ons
add_test(function() {
var ID = "addon5@tests.mozilla.org";
var ID2 = "addon9@tests.mozilla.org";
var list = gDocument.getElementById("search-list");
var searchBox = gManagerWindow.document.getElementById("header-search");
@ -992,9 +1052,19 @@ add_test(function() {
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
isnot(button, null, "Should have an undo button");
item = get_item_in_list(ID2, list);
isnot(item, null, "Should have found the add-on in the list");
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
isnot(button, null, "Should have a remove button");
ok(!button.disabled, "Button should not be disabled");
EventUtils.synthesizeMouse(button, 2, 2, { }, gManagerWindow);
close_manager(gManagerWindow, function() {
AddonManager.getAddonByID(ID, function(aAddon) {
AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) {
is(aAddon, null, "Add-on should no longer be installed");
is(aAddon2, null, "Second add-on should no longer be installed");
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
@ -1013,6 +1083,8 @@ add_test(function() {
var item = get_item_in_list(ID, list);
is(item, null, "Should not have found the add-on in the list");
item = get_item_in_list(ID2, list);
is(item, null, "Should not have found the second add-on in the list");
run_next_test();
});