--- a/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_uninstalling.js
@@ -2,656 +2,413 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var gManagerWindow;
var gDocument;
var gCategoryUtilities;
var gProvider;
-function test() {
+add_task(async function setup() {
requestLongerTimeout(2);
- waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
- name: "Uninstall needs restart",
+ name: "Test addon 1",
type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL
+ operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon2@tests.mozilla.org",
- name: "Uninstall doesn't need restart 1",
+ name: "Test addon 2",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon3@tests.mozilla.org",
- name: "Uninstall doesn't need restart 2",
+ name: "Test addon 3",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}, {
id: "addon4@tests.mozilla.org",
- name: "Uninstall doesn't need restart 3",
- type: "extension",
- operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
- }, {
- id: "addon5@tests.mozilla.org",
- 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",
+ name: "Test addon 4",
type: "extension",
operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
}]);
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gDocument = gManagerWindow.document;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- run_next_test();
- });
-}
-
-function end_test() {
- close_manager(gManagerWindow, function() {
- finish();
- });
-}
+ gManagerWindow = await open_manager(null);
+ gDocument = gManagerWindow.document;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+});
function get_item_in_list(aId, aList) {
var item = aList.firstChild;
while (item) {
if ("mAddon" in item && item.mAddon.id == aId) {
aList.ensureElementIsVisible(item);
return item;
}
item = item.nextSibling;
}
return null;
}
-// Tests that uninstalling a normal add-on from the list view can be undone
-add_test(function() {
+// Tests that uninstalling a restartless add-on from the list view can be undone
+add_task(async function() {
var ID = "addon1@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall");
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ let addon = await AddonManager.getAddonByID(ID);
+ ok(addon.isActive, "Add-on should be active");
+ ok(!(addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
-
- 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");
- isnot(button, null, "Should have an undo button");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- // Force XBL to apply
- item.clientTop;
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- run_next_test();
- });
- });
-});
+ // Force XBL to apply
+ item.clientTop;
-// Tests that uninstalling a restartless add-on from the list view can be undone
-add_test(function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ ok(addon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!addon.isActive, "Add-on should be inactive");
- // Force XBL to apply
- item.clientTop;
-
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ 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");
- ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- 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");
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- ok(aAddon.isActive, "Add-on should be active");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- run_next_test();
- });
- });
+ ok(addon.isActive, "Add-on should be active");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
});
// Tests that uninstalling a disabled restartless add-on from the list view can
// be undone and doesn't re-enable
-add_test(function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
-
- AddonManager.getAddonByID(ID, function(aAddon) {
- aAddon.userDisabled = true;
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
-
- ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- 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");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- aAddon.userDisabled = false;
- ok(aAddon.isActive, "Add-on should be active");
-
- run_next_test();
- });
- });
-});
-
-// Tests that uninstalling a normal add-on from the details view switches back
-// to the list view and can be undone
-add_test(function() {
+add_task(async function() {
var ID = "addon1@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall");
+ let addon = await AddonManager.getAddonByID(ID);
+ addon.userDisabled = true;
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ ok(!addon.isActive, "Add-on should be inactive");
+ ok(!(addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ // Force XBL to apply
+ item.clientTop;
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ ok(addon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!addon.isActive, "Add-on should be inactive");
- // Force XBL to apply
- item.clientTop;
-
- var 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");
- isnot(button, null, "Should have an undo button");
+ 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");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ ok(!addon.isActive, "Add-on should be inactive");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- run_next_test();
- });
- });
- });
- });
+ addon.userDisabled = false;
+ ok(addon.isActive, "Add-on should be active");
});
// Tests that uninstalling a restartless add-on from the details view switches
// back to the list view and can be undone
-add_test(function() {
- var ID = "addon2@tests.mozilla.org";
+add_task(async function() {
+ var ID = "addon1@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let addon = await AddonManager.getAddonByID(ID);
+ ok(addon.isActive, "Add-on should be active");
+ ok(!(addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
+ await promiseViewLoaded(gManagerWindow);
+ is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getElementById("detail-uninstall-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await promiseViewLoaded(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
-
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
- ok(!aAddon.isActive, "Add-on should be inactive");
+ item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
+ is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
- // Force XBL to apply
- item.clientTop;
+ ok(!!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ ok(!addon.isActive, "Add-on should be inactive");
- var 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");
+ // Force XBL to apply
+ item.clientTop;
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ 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");
- // Force XBL to apply
- item.clientTop;
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- ok(aAddon.isActive, "Add-on should be active");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ // Force XBL to apply
+ item.clientTop;
- run_next_test();
- });
- });
- });
- });
+ ok(addon.isActive, "Add-on should be active");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
});
// Tests that uninstalling a restartless add-on from the details view switches
// back to the list view and can be undone and doesn't re-enable
-add_test(function() {
- var ID = "addon2@tests.mozilla.org";
- var list = gDocument.getElementById("addon-list");
-
- // Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
-
- AddonManager.getAddonByID(ID, function(aAddon) {
- aAddon.userDisabled = true;
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
- EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
- wait_for_view_load(gManagerWindow, function() {
- is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
-
- var button = gDocument.getElementById("detail-uninstall-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- wait_for_view_load(gManagerWindow, function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
-
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
-
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
- ok(!aAddon.isActive, "Add-on should be inactive");
-
- // Force XBL to apply
- item.clientTop;
-
- var 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");
-
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- ok(!aAddon.isActive, "Add-on should be inactive");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
-
- aAddon.userDisabled = false;
- ok(aAddon.isActive, "Add-on should be active");
-
- run_next_test();
- });
- });
- });
- });
-});
-
-// Tests that a normal add-on pending uninstall shows up in the list view
-add_test(function() {
+add_task(async function() {
var ID = "addon1@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall");
+ let addon = await AddonManager.getAddonByID(ID);
+ addon.userDisabled = true;
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ ok(!addon.isActive, "Add-on should be inactive");
+ ok(!(addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
-
- // Force XBL to apply
- item.clientTop;
-
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
+ await promiseViewLoaded(gManagerWindow);
+ is(get_current_view(gManagerWindow).id, "detail-view", "Should be in the detail view");
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ var button = gDocument.getElementById("detail-uninstall-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- 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");
- isnot(button, null, "Should have an undo button");
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+
+ await promiseViewLoaded(gManagerWindow);
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- gCategoryUtilities.openType("plugin", function() {
- is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin");
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
+ is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ ok(!!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ ok(!addon.isActive, "Add-on should be inactive");
- ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
+ // Force XBL to apply
+ item.clientTop;
- var 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");
- isnot(button, null, "Should have an undo button");
+ 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");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ // Force XBL to apply
+ item.clientTop;
- run_next_test();
- });
- });
- });
- });
+ ok(!addon.isActive, "Add-on should be inactive");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
+
+ addon.userDisabled = false;
+ ok(addon.isActive, "Add-on should be active");
});
// 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";
+add_task(async function() {
+ var ID = "addon1@tests.mozilla.org";
+ var ID2 = "addon3@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let addon = await AddonManager.getAddonByID(ID);
+ ok(addon.isActive, "Add-on should be active");
+ ok(!(addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
-
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- // Force XBL to apply
- item.clientTop;
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
- ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
- ok(!aAddon.isActive, "Add-on should be inactive");
+ // Force XBL to apply
+ item.clientTop;
- 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");
+ is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ ok(addon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!addon.isActive, "Add-on should be inactive");
- item = get_item_in_list(ID2, list);
- isnot(item, null, "Should have found the add-on in the list");
+ 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");
- button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ item = get_item_in_list(ID2, list);
+ isnot(item, null, "Should have found the add-on in the list");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- gCategoryUtilities.openType("plugin", function() {
- is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension");
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- 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");
+ await gCategoryUtilities.openType("plugin");
+ is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin");
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ let addon2;
+ [addon, addon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
+ is(addon, null, "Add-on should no longer be installed");
+ is(addon2, null, "Second add-on should no longer be installed");
- 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");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- run_next_test();
- });
- });
- });
- });
- });
+ 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");
});
// Tests that closing the manager from the list view finalises the uninstall of
// multiple restartless add-ons
-add_test(function() {
- var ID = "addon4@tests.mozilla.org";
- var ID2 = "addon8@tests.mozilla.org";
+add_task(async function() {
+ var ID = "addon2@tests.mozilla.org";
+ var ID2 = "addon4@tests.mozilla.org";
var list = gDocument.getElementById("addon-list");
// Select the extensions category
- gCategoryUtilities.openType("extension", function() {
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ await gCategoryUtilities.openType("extension");
+ is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
- AddonManager.getAddonByID(ID, function(aAddon) {
- ok(aAddon.isActive, "Add-on should be active");
- ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
- ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
+ let addon = await AddonManager.getAddonByID(ID);
+ ok(addon.isActive, "Add-on should be active");
+ ok(!(addon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
+ ok(!(addon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
- var item = get_item_in_list(ID, list);
- isnot(item, null, "Should have found the add-on in the list");
+ var item = get_item_in_list(ID, list);
+ isnot(item, null, "Should have found the add-on in the list");
- var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
- isnot(button, null, "Should have a remove button");
- ok(!button.disabled, "Button should not be disabled");
+ var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
- // Force XBL to apply
- item.clientTop;
+ // Force XBL to apply
+ item.clientTop;
- is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
+ is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
- ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
- ok(!aAddon.isActive, "Add-on should be inactive");
+ ok(addon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
+ ok(!addon.isActive, "Add-on should be inactive");
- 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");
+ 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");
+ 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");
+ button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
+ isnot(button, null, "Should have a remove button");
+ ok(!button.disabled, "Button should not be disabled");
- EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+ EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
+
+ await close_manager(gManagerWindow);
- close_manager(gManagerWindow, function() {
- 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");
+ let addon2;
+ [addon, addon2] = await AddonManager.getAddonsByIDs([ID, ID2]);
+ is(addon, null, "Add-on should no longer be installed");
+ is(addon2, null, "Second add-on should no longer be installed");
- open_manager(null, function(aWindow) {
- gManagerWindow = aWindow;
- gDocument = gManagerWindow.document;
- gCategoryUtilities = new CategoryUtilities(gManagerWindow);
- var list = gDocument.getElementById("addon-list");
+ gManagerWindow = await open_manager(null);
+ gDocument = gManagerWindow.document;
+ gCategoryUtilities = new CategoryUtilities(gManagerWindow);
+ list = gDocument.getElementById("addon-list");
- is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
+ 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");
+ 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();
- });
- });
- });
- });
- });
+add_task(function finish() {
+ return close_manager(gManagerWindow);
});