Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // Tests that updates that change an add-on's ID show up correctly in the UI |
michael@0 | 6 | |
michael@0 | 7 | var gProvider; |
michael@0 | 8 | var gManagerWindow; |
michael@0 | 9 | var gCategoryUtilities; |
michael@0 | 10 | |
michael@0 | 11 | var gApp = document.getElementById("bundle_brand").getString("brandShortName"); |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | waitForExplicitFinish(); |
michael@0 | 15 | |
michael@0 | 16 | gProvider = new MockProvider(); |
michael@0 | 17 | |
michael@0 | 18 | gProvider.createAddons([{ |
michael@0 | 19 | id: "addon1@tests.mozilla.org", |
michael@0 | 20 | name: "manually updating addon", |
michael@0 | 21 | version: "1.0", |
michael@0 | 22 | applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE |
michael@0 | 23 | }]); |
michael@0 | 24 | |
michael@0 | 25 | open_manager("addons://list/extension", function(aWindow) { |
michael@0 | 26 | gManagerWindow = aWindow; |
michael@0 | 27 | gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
michael@0 | 28 | run_next_test(); |
michael@0 | 29 | }); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function end_test() { |
michael@0 | 33 | close_manager(gManagerWindow, function() { |
michael@0 | 34 | finish(); |
michael@0 | 35 | }); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | add_test(function() { |
michael@0 | 39 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 40 | gProvider.createInstalls([{ |
michael@0 | 41 | name: "updated add-on", |
michael@0 | 42 | existingAddon: gProvider.addons[0], |
michael@0 | 43 | version: "2.0" |
michael@0 | 44 | }]); |
michael@0 | 45 | var newAddon = new MockAddon("addon2@tests.mozilla.org"); |
michael@0 | 46 | newAddon.name = "updated add-on"; |
michael@0 | 47 | newAddon.version = "2.0"; |
michael@0 | 48 | newAddon.pendingOperations = AddonManager.PENDING_INSTALL; |
michael@0 | 49 | gProvider.installs[0]._addonToInstall = newAddon; |
michael@0 | 50 | |
michael@0 | 51 | var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); |
michael@0 | 52 | is(item._version.value, "1.0", "Should still show the old version in the normal list"); |
michael@0 | 53 | var name = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "name"); |
michael@0 | 54 | is(name.value, "manually updating addon", "Should show the old name in the list"); |
michael@0 | 55 | var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn"); |
michael@0 | 56 | is_element_visible(update, "Update button should be visible"); |
michael@0 | 57 | |
michael@0 | 58 | item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); |
michael@0 | 59 | is(item, null, "Should not show the new version in the list"); |
michael@0 | 60 | |
michael@0 | 61 | run_next_test(); |
michael@0 | 62 | }); |
michael@0 | 63 | }); |
michael@0 | 64 | |
michael@0 | 65 | add_test(function() { |
michael@0 | 66 | var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); |
michael@0 | 67 | var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn"); |
michael@0 | 68 | EventUtils.synthesizeMouseAtCenter(update, { }, gManagerWindow); |
michael@0 | 69 | |
michael@0 | 70 | var pending = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "pending"); |
michael@0 | 71 | is_element_visible(pending, "Pending message should be visible"); |
michael@0 | 72 | is(pending.textContent, |
michael@0 | 73 | get_string("notification.upgrade", "manually updating addon", gApp), |
michael@0 | 74 | "Pending message should be correct"); |
michael@0 | 75 | |
michael@0 | 76 | item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); |
michael@0 | 77 | is(item, null, "Should not show the new version in the list"); |
michael@0 | 78 | |
michael@0 | 79 | run_next_test(); |
michael@0 | 80 | }); |