michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Tests that searching for add-ons works correctly michael@0: michael@0: var gManagerWindow; michael@0: var gDocument; michael@0: var gCategoryUtilities; michael@0: var gProvider; michael@0: michael@0: function test() { michael@0: requestLongerTimeout(2); michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: gProvider.createAddons([{ michael@0: id: "addon1@tests.mozilla.org", michael@0: name: "Uninstall needs restart", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL michael@0: }, { michael@0: id: "addon2@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 1", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon3@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 2", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon4@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 3", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon5@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 4", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon6@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 5", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon7@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 6", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon8@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 7", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon9@tests.mozilla.org", michael@0: name: "Uninstall doesn't need restart 8", michael@0: type: "extension", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }]); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gDocument = gManagerWindow.document; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: michael@0: function end_test() { michael@0: close_manager(gManagerWindow, function() { michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: function get_item_in_list(aId, aList) { michael@0: var item = aList.firstChild; michael@0: while (item) { michael@0: if ("mAddon" in item && item.mAddon.id == aId) { michael@0: aList.ensureElementIsVisible(item); michael@0: return item; michael@0: } michael@0: item = item.nextSibling; michael@0: } michael@0: return null; michael@0: } michael@0: michael@0: // Tests that uninstalling a normal add-on from the list view can be undone michael@0: add_test(function() { michael@0: var ID = "addon1@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a restartless add-on from the list view can be undone michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a disabled restartless add-on from the list view can michael@0: // be undone and doesn't re-enable michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: aAddon.userDisabled = true; michael@0: michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: aAddon.userDisabled = false; michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a normal add-on from the search view can be undone michael@0: add_test(function() { michael@0: var ID = "addon1@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("search-list"); michael@0: michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: // Make sure to show local add-ons michael@0: EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a restartless add-on from the search view can be undone michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("search-list"); michael@0: michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: // Make sure to show local add-ons michael@0: EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a disabled restartless add-on from the search view can michael@0: // be undone and doesn't re-enable michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("search-list"); michael@0: michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: // Make sure to show local add-ons michael@0: EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: aAddon.userDisabled = true; michael@0: michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: aAddon.userDisabled = false; michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a normal add-on from the details view switches back michael@0: // to the list view and can be undone michael@0: add_test(function() { michael@0: var ID = "addon1@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); michael@0: michael@0: var button = gDocument.getElementById("detail-uninstall-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a restartless add-on from the details view switches michael@0: // back to the list view and can be undone michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); michael@0: michael@0: var button = gDocument.getElementById("detail-uninstall-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that uninstalling a restartless add-on from the details view switches michael@0: // back to the list view and can be undone and doesn't re-enable michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: aAddon.userDisabled = true; michael@0: michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); michael@0: michael@0: var button = gDocument.getElementById("detail-uninstall-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: aAddon.userDisabled = false; michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that a normal add-on pending uninstall shows up in the list view michael@0: add_test(function() { michael@0: var ID = "addon1@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: gCategoryUtilities.openType("plugin", function() { michael@0: is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin"); michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that a normal add-on pending uninstall shows up in the search view michael@0: add_test(function() { michael@0: var ID = "addon1@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("search-list"); michael@0: michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: // Make sure to show local add-ons michael@0: EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: gCategoryUtilities.openType("plugin", function() { michael@0: is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(!button.hidden, "Restart button should not be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that switching away from the list view finalises the uninstall of michael@0: // multiple restartless add-ons michael@0: add_test(function() { michael@0: var ID = "addon2@tests.mozilla.org"; michael@0: var ID2 = "addon6@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: item = get_item_in_list(ID2, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: gCategoryUtilities.openType("plugin", function() { michael@0: is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { michael@0: is(aAddon, null, "Add-on should no longer be installed"); michael@0: is(aAddon2, null, "Second add-on should no longer be installed"); michael@0: michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: is(item, null, "Should not have found the add-on in the list"); michael@0: item = get_item_in_list(ID2, list); michael@0: is(item, null, "Should not have found the second add-on in the list"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that switching away from the search view finalises the uninstall of michael@0: // multiple restartless add-ons michael@0: add_test(function() { michael@0: var ID = "addon3@tests.mozilla.org"; michael@0: var ID2 = "addon7@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("search-list"); michael@0: michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: // Make sure to show local add-ons michael@0: EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: item = get_item_in_list(ID2, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: gCategoryUtilities.openType("plugin", function() { michael@0: is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { michael@0: is(aAddon, null, "Add-on should no longer be installed"); michael@0: is(aAddon2, null, "Second add-on should no longer be installed"); michael@0: michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: is(item, null, "Should not have found the add-on in the list"); michael@0: item = get_item_in_list(ID2, list); michael@0: is(item, null, "Should not have found the second add-on in the list"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that closing the manager from the list view finalises the uninstall of michael@0: // multiple restartless add-ons michael@0: add_test(function() { michael@0: var ID = "addon4@tests.mozilla.org"; michael@0: var ID2 = "addon8@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: // Select the extensions category michael@0: gCategoryUtilities.openType("extension", function() { michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: item = get_item_in_list(ID2, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: close_manager(gManagerWindow, function() { michael@0: AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { michael@0: is(aAddon, null, "Add-on should no longer be installed"); michael@0: is(aAddon2, null, "Second add-on should no longer be installed"); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gDocument = gManagerWindow.document; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: var list = gDocument.getElementById("addon-list"); michael@0: michael@0: is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: is(item, null, "Should not have found the add-on in the list"); michael@0: item = get_item_in_list(ID2, list); michael@0: is(item, null, "Should not have found the second add-on in the list"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that closing the manager from the search view finalises the uninstall michael@0: // of multiple restartless add-ons michael@0: add_test(function() { michael@0: var ID = "addon5@tests.mozilla.org"; michael@0: var ID2 = "addon9@tests.mozilla.org"; michael@0: var list = gDocument.getElementById("search-list"); michael@0: michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: // Make sure to show local add-ons michael@0: EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); michael@0: michael@0: AddonManager.getAddonByID(ID, function(aAddon) { michael@0: ok(aAddon.isActive, "Add-on should be active"); michael@0: ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: // Force XBL to apply michael@0: item.clientTop; michael@0: michael@0: is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); michael@0: michael@0: ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); michael@0: ok(!aAddon.isActive, "Add-on should be inactive"); michael@0: michael@0: var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); michael@0: isnot(button, null, "Should have a restart button"); michael@0: ok(button.hidden, "Restart button should be hidden"); michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); michael@0: isnot(button, null, "Should have an undo button"); michael@0: michael@0: item = get_item_in_list(ID2, list); michael@0: isnot(item, null, "Should have found the add-on in the list"); michael@0: michael@0: button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); michael@0: isnot(button, null, "Should have a remove button"); michael@0: ok(!button.disabled, "Button should not be disabled"); michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); michael@0: michael@0: close_manager(gManagerWindow, function() { michael@0: AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { michael@0: is(aAddon, null, "Add-on should no longer be installed"); michael@0: is(aAddon2, null, "Second add-on should no longer be installed"); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gDocument = gManagerWindow.document; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: var list = gDocument.getElementById("search-list"); michael@0: var searchBox = gManagerWindow.document.getElementById("header-search"); michael@0: michael@0: searchBox.value = "Uninstall"; michael@0: michael@0: EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); michael@0: EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); michael@0: michael@0: var item = get_item_in_list(ID, list); michael@0: is(item, null, "Should not have found the add-on in the list"); michael@0: item = get_item_in_list(ID2, list); michael@0: is(item, null, "Should not have found the second add-on in the list"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: });