|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 function test() { |
|
6 waitForExplicitFinish(); |
|
7 |
|
8 var gProvider = new MockProvider(); |
|
9 let perms = AddonManager.PERM_CAN_UNINSTALL | |
|
10 AddonManager.PERM_CAN_ENABLE | AddonManager.PERM_CAN_DISABLE; |
|
11 |
|
12 gProvider.createAddons([{ |
|
13 id: "restart-enable-disable@tests.mozilla.org", |
|
14 name: "restart-enable-disable", |
|
15 description: "foo", |
|
16 permissions: perms, |
|
17 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_ENABLE | |
|
18 AddonManager.OP_NEEDS_RESTART_DISABLE |
|
19 }, |
|
20 { |
|
21 id: "restart-uninstall@tests.mozilla.org", |
|
22 name: "restart-uninstall", |
|
23 description: "foo", |
|
24 permissions: perms, |
|
25 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL |
|
26 }, |
|
27 { |
|
28 id: "no-restart-required@tests.mozilla.org", |
|
29 name: "no-restart-required", |
|
30 description: "bar", |
|
31 permissions: perms, |
|
32 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
33 }]); |
|
34 |
|
35 open_manager("addons://list/extension", function(aWindow) { |
|
36 let addonList = aWindow.document.getElementById("addon-list"); |
|
37 let ed_r_Item, un_r_Item, no_r_Item; |
|
38 for (let addonItem of addonList.childNodes) { |
|
39 let name = addonItem.getAttribute("name"); |
|
40 switch (name) { |
|
41 case "restart-enable-disable": |
|
42 ed_r_Item = addonItem; |
|
43 break; |
|
44 case "restart-uninstall": |
|
45 un_r_Item = addonItem; |
|
46 break; |
|
47 case "no-restart-required": |
|
48 no_r_Item = addonItem; |
|
49 break; |
|
50 } |
|
51 } |
|
52 |
|
53 // Check the buttons in the list view. |
|
54 function checkTooltips(aItem, aEnable, aDisable, aRemove) { |
|
55 ok(aItem._enableBtn.getAttribute("tooltiptext") == aEnable); |
|
56 ok(aItem._disableBtn.getAttribute("tooltiptext") == aDisable); |
|
57 ok(aItem._removeBtn.getAttribute("tooltiptext") == aRemove); |
|
58 } |
|
59 |
|
60 let strs = aWindow.gStrings.ext; |
|
61 addonList.selectedItem = ed_r_Item; |
|
62 let ed_args = [ed_r_Item, |
|
63 strs.GetStringFromName("enableAddonRestartRequiredTooltip"), |
|
64 strs.GetStringFromName("disableAddonRestartRequiredTooltip"), |
|
65 strs.GetStringFromName("uninstallAddonTooltip")]; |
|
66 checkTooltips.apply(null, ed_args); |
|
67 |
|
68 addonList.selectedItem = un_r_Item; |
|
69 let un_args = [un_r_Item, |
|
70 strs.GetStringFromName("enableAddonTooltip"), |
|
71 strs.GetStringFromName("disableAddonTooltip"), |
|
72 strs.GetStringFromName("uninstallAddonRestartRequiredTooltip")]; |
|
73 checkTooltips.apply(null, un_args); |
|
74 |
|
75 addonList.selectedItem = no_r_Item; |
|
76 let no_args = [no_r_Item, |
|
77 strs.GetStringFromName("enableAddonTooltip"), |
|
78 strs.GetStringFromName("disableAddonTooltip"), |
|
79 strs.GetStringFromName("uninstallAddonTooltip")]; |
|
80 checkTooltips.apply(null, no_args) |
|
81 |
|
82 // Check the buttons in the details view. |
|
83 function checkTooltips2(aItem, aEnable, aDisable, aRemove) { |
|
84 let detailEnable = aWindow.document.getElementById("detail-enable-btn"); |
|
85 let detailDisable = aWindow.document.getElementById("detail-disable-btn"); |
|
86 let detailUninstall = aWindow.document.getElementById("detail-uninstall-btn"); |
|
87 ok(detailEnable.getAttribute("tooltiptext") == aEnable); |
|
88 ok(detailDisable.getAttribute("tooltiptext") == aDisable); |
|
89 ok(detailUninstall.getAttribute("tooltiptext") == aRemove); |
|
90 } |
|
91 |
|
92 function showInDetailView(aAddonId) { |
|
93 aWindow.gViewController.loadView("addons://detail/" + |
|
94 aWindow.encodeURIComponent(aAddonId)); |
|
95 } |
|
96 |
|
97 // enable-disable: |
|
98 showInDetailView("restart-enable-disable@tests.mozilla.org"); |
|
99 wait_for_view_load(aWindow, function() { |
|
100 checkTooltips2.apply(null, ed_args); |
|
101 // uninstall: |
|
102 showInDetailView("restart-uninstall@tests.mozilla.org"); |
|
103 wait_for_view_load(aWindow, function() { |
|
104 checkTooltips2.apply(null, un_args); |
|
105 // no restart: |
|
106 showInDetailView("no-restart-required@tests.mozilla.org"); |
|
107 wait_for_view_load(aWindow, function() { |
|
108 checkTooltips2.apply(null, no_args); |
|
109 aWindow.close(); |
|
110 finish(); |
|
111 }); |
|
112 }); |
|
113 }); |
|
114 |
|
115 }); |
|
116 } |