|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Tests that updates that change an add-on's ID show up correctly in the UI |
|
6 |
|
7 var gProvider; |
|
8 var gManagerWindow; |
|
9 var gCategoryUtilities; |
|
10 |
|
11 var gApp = document.getElementById("bundle_brand").getString("brandShortName"); |
|
12 |
|
13 function test() { |
|
14 waitForExplicitFinish(); |
|
15 |
|
16 gProvider = new MockProvider(); |
|
17 |
|
18 gProvider.createAddons([{ |
|
19 id: "addon1@tests.mozilla.org", |
|
20 name: "manually updating addon", |
|
21 version: "1.0", |
|
22 applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE |
|
23 }]); |
|
24 |
|
25 open_manager("addons://list/extension", function(aWindow) { |
|
26 gManagerWindow = aWindow; |
|
27 gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
|
28 run_next_test(); |
|
29 }); |
|
30 } |
|
31 |
|
32 function end_test() { |
|
33 close_manager(gManagerWindow, function() { |
|
34 finish(); |
|
35 }); |
|
36 } |
|
37 |
|
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; |
|
50 |
|
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"); |
|
57 |
|
58 item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); |
|
59 is(item, null, "Should not show the new version in the list"); |
|
60 |
|
61 run_next_test(); |
|
62 }); |
|
63 }); |
|
64 |
|
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); |
|
69 |
|
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"); |
|
75 |
|
76 item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); |
|
77 is(item, null, "Should not show the new version in the list"); |
|
78 |
|
79 run_next_test(); |
|
80 }); |