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 updates that change an add-on's ID show up correctly in the UI michael@0: michael@0: var gProvider; michael@0: var gManagerWindow; michael@0: var gCategoryUtilities; michael@0: michael@0: var gApp = document.getElementById("bundle_brand").getString("brandShortName"); michael@0: michael@0: function test() { 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: "manually updating addon", michael@0: version: "1.0", michael@0: applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE michael@0: }]); michael@0: michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; 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: add_test(function() { michael@0: gCategoryUtilities.openType("extension", function() { michael@0: gProvider.createInstalls([{ michael@0: name: "updated add-on", michael@0: existingAddon: gProvider.addons[0], michael@0: version: "2.0" michael@0: }]); michael@0: var newAddon = new MockAddon("addon2@tests.mozilla.org"); michael@0: newAddon.name = "updated add-on"; michael@0: newAddon.version = "2.0"; michael@0: newAddon.pendingOperations = AddonManager.PENDING_INSTALL; michael@0: gProvider.installs[0]._addonToInstall = newAddon; michael@0: michael@0: var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); michael@0: is(item._version.value, "1.0", "Should still show the old version in the normal list"); michael@0: var name = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "name"); michael@0: is(name.value, "manually updating addon", "Should show the old name in the list"); michael@0: var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn"); michael@0: is_element_visible(update, "Update button should be visible"); michael@0: michael@0: item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); michael@0: is(item, null, "Should not show the new version in the list"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: add_test(function() { michael@0: var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); michael@0: var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn"); michael@0: EventUtils.synthesizeMouseAtCenter(update, { }, gManagerWindow); michael@0: michael@0: var pending = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "pending"); michael@0: is_element_visible(pending, "Pending message should be visible"); michael@0: is(pending.textContent, michael@0: get_string("notification.upgrade", "manually updating addon", gApp), michael@0: "Pending message should be correct"); michael@0: michael@0: item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); michael@0: is(item, null, "Should not show the new version in the list"); michael@0: michael@0: run_next_test(); michael@0: });