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