|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Tests that searching for add-ons works correctly |
|
6 |
|
7 var gManagerWindow; |
|
8 var gDocument; |
|
9 var gCategoryUtilities; |
|
10 var gProvider; |
|
11 |
|
12 function test() { |
|
13 requestLongerTimeout(2); |
|
14 waitForExplicitFinish(); |
|
15 |
|
16 gProvider = new MockProvider(); |
|
17 |
|
18 gProvider.createAddons([{ |
|
19 id: "addon1@tests.mozilla.org", |
|
20 name: "Uninstall needs restart", |
|
21 type: "extension", |
|
22 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL |
|
23 }, { |
|
24 id: "addon2@tests.mozilla.org", |
|
25 name: "Uninstall doesn't need restart 1", |
|
26 type: "extension", |
|
27 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
28 }, { |
|
29 id: "addon3@tests.mozilla.org", |
|
30 name: "Uninstall doesn't need restart 2", |
|
31 type: "extension", |
|
32 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
33 }, { |
|
34 id: "addon4@tests.mozilla.org", |
|
35 name: "Uninstall doesn't need restart 3", |
|
36 type: "extension", |
|
37 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
38 }, { |
|
39 id: "addon5@tests.mozilla.org", |
|
40 name: "Uninstall doesn't need restart 4", |
|
41 type: "extension", |
|
42 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
43 }, { |
|
44 id: "addon6@tests.mozilla.org", |
|
45 name: "Uninstall doesn't need restart 5", |
|
46 type: "extension", |
|
47 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
48 }, { |
|
49 id: "addon7@tests.mozilla.org", |
|
50 name: "Uninstall doesn't need restart 6", |
|
51 type: "extension", |
|
52 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
53 }, { |
|
54 id: "addon8@tests.mozilla.org", |
|
55 name: "Uninstall doesn't need restart 7", |
|
56 type: "extension", |
|
57 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
58 }, { |
|
59 id: "addon9@tests.mozilla.org", |
|
60 name: "Uninstall doesn't need restart 8", |
|
61 type: "extension", |
|
62 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
|
63 }]); |
|
64 |
|
65 open_manager(null, function(aWindow) { |
|
66 gManagerWindow = aWindow; |
|
67 gDocument = gManagerWindow.document; |
|
68 gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
|
69 run_next_test(); |
|
70 }); |
|
71 } |
|
72 |
|
73 function end_test() { |
|
74 close_manager(gManagerWindow, function() { |
|
75 finish(); |
|
76 }); |
|
77 } |
|
78 |
|
79 function get_item_in_list(aId, aList) { |
|
80 var item = aList.firstChild; |
|
81 while (item) { |
|
82 if ("mAddon" in item && item.mAddon.id == aId) { |
|
83 aList.ensureElementIsVisible(item); |
|
84 return item; |
|
85 } |
|
86 item = item.nextSibling; |
|
87 } |
|
88 return null; |
|
89 } |
|
90 |
|
91 // Tests that uninstalling a normal add-on from the list view can be undone |
|
92 add_test(function() { |
|
93 var ID = "addon1@tests.mozilla.org"; |
|
94 var list = gDocument.getElementById("addon-list"); |
|
95 |
|
96 // Select the extensions category |
|
97 gCategoryUtilities.openType("extension", function() { |
|
98 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
99 |
|
100 AddonManager.getAddonByID(ID, function(aAddon) { |
|
101 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
102 ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
|
103 |
|
104 var item = get_item_in_list(ID, list); |
|
105 isnot(item, null, "Should have found the add-on in the list"); |
|
106 |
|
107 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
108 isnot(button, null, "Should have a remove button"); |
|
109 ok(!button.disabled, "Button should not be disabled"); |
|
110 |
|
111 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
112 |
|
113 // Force XBL to apply |
|
114 item.clientTop; |
|
115 |
|
116 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
117 |
|
118 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
119 |
|
120 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
121 isnot(button, null, "Should have a restart button"); |
|
122 ok(!button.hidden, "Restart button should not be hidden"); |
|
123 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
124 isnot(button, null, "Should have an undo button"); |
|
125 |
|
126 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
127 |
|
128 // Force XBL to apply |
|
129 item.clientTop; |
|
130 |
|
131 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
132 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
133 isnot(button, null, "Should have a remove button"); |
|
134 ok(!button.disabled, "Button should not be disabled"); |
|
135 |
|
136 run_next_test(); |
|
137 }); |
|
138 }); |
|
139 }); |
|
140 |
|
141 // Tests that uninstalling a restartless add-on from the list view can be undone |
|
142 add_test(function() { |
|
143 var ID = "addon2@tests.mozilla.org"; |
|
144 var list = gDocument.getElementById("addon-list"); |
|
145 |
|
146 // Select the extensions category |
|
147 gCategoryUtilities.openType("extension", function() { |
|
148 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
149 |
|
150 AddonManager.getAddonByID(ID, function(aAddon) { |
|
151 ok(aAddon.isActive, "Add-on should be active"); |
|
152 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
153 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
154 |
|
155 var item = get_item_in_list(ID, list); |
|
156 isnot(item, null, "Should have found the add-on in the list"); |
|
157 |
|
158 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
159 isnot(button, null, "Should have a remove button"); |
|
160 ok(!button.disabled, "Button should not be disabled"); |
|
161 |
|
162 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
163 |
|
164 // Force XBL to apply |
|
165 item.clientTop; |
|
166 |
|
167 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
168 |
|
169 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
170 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
171 |
|
172 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
173 isnot(button, null, "Should have a restart button"); |
|
174 ok(button.hidden, "Restart button should be hidden"); |
|
175 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
176 isnot(button, null, "Should have an undo button"); |
|
177 |
|
178 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
179 |
|
180 // Force XBL to apply |
|
181 item.clientTop; |
|
182 |
|
183 ok(aAddon.isActive, "Add-on should be active"); |
|
184 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
185 isnot(button, null, "Should have a remove button"); |
|
186 ok(!button.disabled, "Button should not be disabled"); |
|
187 |
|
188 run_next_test(); |
|
189 }); |
|
190 }); |
|
191 }); |
|
192 |
|
193 // Tests that uninstalling a disabled restartless add-on from the list view can |
|
194 // be undone and doesn't re-enable |
|
195 add_test(function() { |
|
196 var ID = "addon2@tests.mozilla.org"; |
|
197 var list = gDocument.getElementById("addon-list"); |
|
198 |
|
199 // Select the extensions category |
|
200 gCategoryUtilities.openType("extension", function() { |
|
201 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
202 |
|
203 AddonManager.getAddonByID(ID, function(aAddon) { |
|
204 aAddon.userDisabled = true; |
|
205 |
|
206 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
207 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
208 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
209 |
|
210 var item = get_item_in_list(ID, list); |
|
211 isnot(item, null, "Should have found the add-on in the list"); |
|
212 |
|
213 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
214 isnot(button, null, "Should have a remove button"); |
|
215 ok(!button.disabled, "Button should not be disabled"); |
|
216 |
|
217 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
218 |
|
219 // Force XBL to apply |
|
220 item.clientTop; |
|
221 |
|
222 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
223 |
|
224 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
225 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
226 |
|
227 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
228 isnot(button, null, "Should have a restart button"); |
|
229 ok(button.hidden, "Restart button should be hidden"); |
|
230 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
231 isnot(button, null, "Should have an undo button"); |
|
232 |
|
233 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
234 |
|
235 // Force XBL to apply |
|
236 item.clientTop; |
|
237 |
|
238 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
239 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
240 isnot(button, null, "Should have a remove button"); |
|
241 ok(!button.disabled, "Button should not be disabled"); |
|
242 |
|
243 aAddon.userDisabled = false; |
|
244 ok(aAddon.isActive, "Add-on should be active"); |
|
245 |
|
246 run_next_test(); |
|
247 }); |
|
248 }); |
|
249 }); |
|
250 |
|
251 // Tests that uninstalling a normal add-on from the search view can be undone |
|
252 add_test(function() { |
|
253 var ID = "addon1@tests.mozilla.org"; |
|
254 var list = gDocument.getElementById("search-list"); |
|
255 |
|
256 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
257 searchBox.value = "Uninstall"; |
|
258 |
|
259 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
260 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
261 |
|
262 wait_for_view_load(gManagerWindow, function() { |
|
263 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
264 |
|
265 // Make sure to show local add-ons |
|
266 EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
|
267 |
|
268 AddonManager.getAddonByID(ID, function(aAddon) { |
|
269 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
270 ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
|
271 |
|
272 var item = get_item_in_list(ID, list); |
|
273 isnot(item, null, "Should have found the add-on in the list"); |
|
274 |
|
275 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
276 isnot(button, null, "Should have a remove button"); |
|
277 ok(!button.disabled, "Button should not be disabled"); |
|
278 |
|
279 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
280 |
|
281 // Force XBL to apply |
|
282 item.clientTop; |
|
283 |
|
284 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
285 |
|
286 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
287 |
|
288 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
289 isnot(button, null, "Should have a restart button"); |
|
290 ok(!button.hidden, "Restart button should not be hidden"); |
|
291 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
292 isnot(button, null, "Should have an undo button"); |
|
293 |
|
294 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
295 |
|
296 // Force XBL to apply |
|
297 item.clientTop; |
|
298 |
|
299 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
300 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
301 isnot(button, null, "Should have a remove button"); |
|
302 ok(!button.disabled, "Button should not be disabled"); |
|
303 |
|
304 run_next_test(); |
|
305 }); |
|
306 }); |
|
307 }); |
|
308 |
|
309 // Tests that uninstalling a restartless add-on from the search view can be undone |
|
310 add_test(function() { |
|
311 var ID = "addon2@tests.mozilla.org"; |
|
312 var list = gDocument.getElementById("search-list"); |
|
313 |
|
314 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
315 searchBox.value = "Uninstall"; |
|
316 |
|
317 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
318 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
319 |
|
320 wait_for_view_load(gManagerWindow, function() { |
|
321 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
322 |
|
323 // Make sure to show local add-ons |
|
324 EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
|
325 |
|
326 AddonManager.getAddonByID(ID, function(aAddon) { |
|
327 ok(aAddon.isActive, "Add-on should be active"); |
|
328 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
329 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
330 |
|
331 var item = get_item_in_list(ID, list); |
|
332 isnot(item, null, "Should have found the add-on in the list"); |
|
333 |
|
334 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
335 isnot(button, null, "Should have a remove button"); |
|
336 ok(!button.disabled, "Button should not be disabled"); |
|
337 |
|
338 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
339 |
|
340 // Force XBL to apply |
|
341 item.clientTop; |
|
342 |
|
343 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
344 |
|
345 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
346 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
347 |
|
348 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
349 isnot(button, null, "Should have a restart button"); |
|
350 ok(button.hidden, "Restart button should be hidden"); |
|
351 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
352 isnot(button, null, "Should have an undo button"); |
|
353 |
|
354 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
355 |
|
356 // Force XBL to apply |
|
357 item.clientTop; |
|
358 |
|
359 ok(aAddon.isActive, "Add-on should be active"); |
|
360 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
361 isnot(button, null, "Should have a remove button"); |
|
362 ok(!button.disabled, "Button should not be disabled"); |
|
363 |
|
364 run_next_test(); |
|
365 }); |
|
366 }); |
|
367 }); |
|
368 |
|
369 // Tests that uninstalling a disabled restartless add-on from the search view can |
|
370 // be undone and doesn't re-enable |
|
371 add_test(function() { |
|
372 var ID = "addon2@tests.mozilla.org"; |
|
373 var list = gDocument.getElementById("search-list"); |
|
374 |
|
375 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
376 searchBox.value = "Uninstall"; |
|
377 |
|
378 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
379 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
380 |
|
381 wait_for_view_load(gManagerWindow, function() { |
|
382 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
383 |
|
384 // Make sure to show local add-ons |
|
385 EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
|
386 |
|
387 AddonManager.getAddonByID(ID, function(aAddon) { |
|
388 aAddon.userDisabled = true; |
|
389 |
|
390 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
391 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
392 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
393 |
|
394 var item = get_item_in_list(ID, list); |
|
395 isnot(item, null, "Should have found the add-on in the list"); |
|
396 |
|
397 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
398 isnot(button, null, "Should have a remove button"); |
|
399 ok(!button.disabled, "Button should not be disabled"); |
|
400 |
|
401 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
402 |
|
403 // Force XBL to apply |
|
404 item.clientTop; |
|
405 |
|
406 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
407 |
|
408 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
409 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
410 |
|
411 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
412 isnot(button, null, "Should have a restart button"); |
|
413 ok(button.hidden, "Restart button should be hidden"); |
|
414 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
415 isnot(button, null, "Should have an undo button"); |
|
416 |
|
417 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
418 |
|
419 // Force XBL to apply |
|
420 item.clientTop; |
|
421 |
|
422 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
423 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
424 isnot(button, null, "Should have a remove button"); |
|
425 ok(!button.disabled, "Button should not be disabled"); |
|
426 |
|
427 aAddon.userDisabled = false; |
|
428 ok(aAddon.isActive, "Add-on should be active"); |
|
429 |
|
430 run_next_test(); |
|
431 }); |
|
432 }); |
|
433 }); |
|
434 |
|
435 // Tests that uninstalling a normal add-on from the details view switches back |
|
436 // to the list view and can be undone |
|
437 add_test(function() { |
|
438 var ID = "addon1@tests.mozilla.org"; |
|
439 var list = gDocument.getElementById("addon-list"); |
|
440 |
|
441 // Select the extensions category |
|
442 gCategoryUtilities.openType("extension", function() { |
|
443 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
444 |
|
445 AddonManager.getAddonByID(ID, function(aAddon) { |
|
446 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
447 ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
|
448 |
|
449 var item = get_item_in_list(ID, list); |
|
450 isnot(item, null, "Should have found the add-on in the list"); |
|
451 |
|
452 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
|
453 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
|
454 wait_for_view_load(gManagerWindow, function() { |
|
455 is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); |
|
456 |
|
457 var button = gDocument.getElementById("detail-uninstall-btn"); |
|
458 isnot(button, null, "Should have a remove button"); |
|
459 ok(!button.disabled, "Button should not be disabled"); |
|
460 |
|
461 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
462 |
|
463 wait_for_view_load(gManagerWindow, function() { |
|
464 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
465 |
|
466 var item = get_item_in_list(ID, list); |
|
467 isnot(item, null, "Should have found the add-on in the list"); |
|
468 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
469 |
|
470 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
471 |
|
472 // Force XBL to apply |
|
473 item.clientTop; |
|
474 |
|
475 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
476 isnot(button, null, "Should have a restart button"); |
|
477 ok(!button.hidden, "Restart button should not be hidden"); |
|
478 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
479 isnot(button, null, "Should have an undo button"); |
|
480 |
|
481 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
482 |
|
483 // Force XBL to apply |
|
484 item.clientTop; |
|
485 |
|
486 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
487 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
488 isnot(button, null, "Should have a remove button"); |
|
489 ok(!button.disabled, "Button should not be disabled"); |
|
490 |
|
491 run_next_test(); |
|
492 }); |
|
493 }); |
|
494 }); |
|
495 }); |
|
496 }); |
|
497 |
|
498 // Tests that uninstalling a restartless add-on from the details view switches |
|
499 // back to the list view and can be undone |
|
500 add_test(function() { |
|
501 var ID = "addon2@tests.mozilla.org"; |
|
502 var list = gDocument.getElementById("addon-list"); |
|
503 |
|
504 // Select the extensions category |
|
505 gCategoryUtilities.openType("extension", function() { |
|
506 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
507 |
|
508 AddonManager.getAddonByID(ID, function(aAddon) { |
|
509 ok(aAddon.isActive, "Add-on should be active"); |
|
510 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
511 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
512 |
|
513 var item = get_item_in_list(ID, list); |
|
514 isnot(item, null, "Should have found the add-on in the list"); |
|
515 |
|
516 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
|
517 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
|
518 wait_for_view_load(gManagerWindow, function() { |
|
519 is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); |
|
520 |
|
521 var button = gDocument.getElementById("detail-uninstall-btn"); |
|
522 isnot(button, null, "Should have a remove button"); |
|
523 ok(!button.disabled, "Button should not be disabled"); |
|
524 |
|
525 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
526 |
|
527 wait_for_view_load(gManagerWindow, function() { |
|
528 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
529 |
|
530 var item = get_item_in_list(ID, list); |
|
531 isnot(item, null, "Should have found the add-on in the list"); |
|
532 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
533 |
|
534 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
535 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
536 |
|
537 // Force XBL to apply |
|
538 item.clientTop; |
|
539 |
|
540 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
541 isnot(button, null, "Should have a restart button"); |
|
542 ok(button.hidden, "Restart button should be hidden"); |
|
543 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
544 isnot(button, null, "Should have an undo button"); |
|
545 |
|
546 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
547 |
|
548 // Force XBL to apply |
|
549 item.clientTop; |
|
550 |
|
551 ok(aAddon.isActive, "Add-on should be active"); |
|
552 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
553 isnot(button, null, "Should have a remove button"); |
|
554 ok(!button.disabled, "Button should not be disabled"); |
|
555 |
|
556 run_next_test(); |
|
557 }); |
|
558 }); |
|
559 }); |
|
560 }); |
|
561 }); |
|
562 |
|
563 // Tests that uninstalling a restartless add-on from the details view switches |
|
564 // back to the list view and can be undone and doesn't re-enable |
|
565 add_test(function() { |
|
566 var ID = "addon2@tests.mozilla.org"; |
|
567 var list = gDocument.getElementById("addon-list"); |
|
568 |
|
569 // Select the extensions category |
|
570 gCategoryUtilities.openType("extension", function() { |
|
571 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
572 |
|
573 AddonManager.getAddonByID(ID, function(aAddon) { |
|
574 aAddon.userDisabled = true; |
|
575 |
|
576 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
577 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
578 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
579 |
|
580 var item = get_item_in_list(ID, list); |
|
581 isnot(item, null, "Should have found the add-on in the list"); |
|
582 |
|
583 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
|
584 EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
|
585 wait_for_view_load(gManagerWindow, function() { |
|
586 is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); |
|
587 |
|
588 var button = gDocument.getElementById("detail-uninstall-btn"); |
|
589 isnot(button, null, "Should have a remove button"); |
|
590 ok(!button.disabled, "Button should not be disabled"); |
|
591 |
|
592 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
593 |
|
594 wait_for_view_load(gManagerWindow, function() { |
|
595 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
596 |
|
597 var item = get_item_in_list(ID, list); |
|
598 isnot(item, null, "Should have found the add-on in the list"); |
|
599 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
600 |
|
601 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
602 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
603 |
|
604 // Force XBL to apply |
|
605 item.clientTop; |
|
606 |
|
607 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
608 isnot(button, null, "Should have a restart button"); |
|
609 ok(button.hidden, "Restart button should be hidden"); |
|
610 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
611 isnot(button, null, "Should have an undo button"); |
|
612 |
|
613 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
614 |
|
615 // Force XBL to apply |
|
616 item.clientTop; |
|
617 |
|
618 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
619 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
620 isnot(button, null, "Should have a remove button"); |
|
621 ok(!button.disabled, "Button should not be disabled"); |
|
622 |
|
623 aAddon.userDisabled = false; |
|
624 ok(aAddon.isActive, "Add-on should be active"); |
|
625 |
|
626 run_next_test(); |
|
627 }); |
|
628 }); |
|
629 }); |
|
630 }); |
|
631 }); |
|
632 |
|
633 // Tests that a normal add-on pending uninstall shows up in the list view |
|
634 add_test(function() { |
|
635 var ID = "addon1@tests.mozilla.org"; |
|
636 var list = gDocument.getElementById("addon-list"); |
|
637 |
|
638 // Select the extensions category |
|
639 gCategoryUtilities.openType("extension", function() { |
|
640 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
641 |
|
642 AddonManager.getAddonByID(ID, function(aAddon) { |
|
643 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
644 ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
|
645 |
|
646 var item = get_item_in_list(ID, list); |
|
647 isnot(item, null, "Should have found the add-on in the list"); |
|
648 |
|
649 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
650 isnot(button, null, "Should have a remove button"); |
|
651 ok(!button.disabled, "Button should not be disabled"); |
|
652 |
|
653 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
654 |
|
655 // Force XBL to apply |
|
656 item.clientTop; |
|
657 |
|
658 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
659 |
|
660 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
661 |
|
662 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
663 isnot(button, null, "Should have a restart button"); |
|
664 ok(!button.hidden, "Restart button should not be hidden"); |
|
665 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
666 isnot(button, null, "Should have an undo button"); |
|
667 |
|
668 gCategoryUtilities.openType("plugin", function() { |
|
669 is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin"); |
|
670 gCategoryUtilities.openType("extension", function() { |
|
671 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
672 |
|
673 var item = get_item_in_list(ID, list); |
|
674 isnot(item, null, "Should have found the add-on in the list"); |
|
675 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
676 |
|
677 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
678 |
|
679 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
680 isnot(button, null, "Should have a restart button"); |
|
681 ok(!button.hidden, "Restart button should not be hidden"); |
|
682 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
683 isnot(button, null, "Should have an undo button"); |
|
684 |
|
685 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
686 |
|
687 // Force XBL to apply |
|
688 item.clientTop; |
|
689 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
690 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
691 isnot(button, null, "Should have a remove button"); |
|
692 ok(!button.disabled, "Button should not be disabled"); |
|
693 |
|
694 run_next_test(); |
|
695 }); |
|
696 }); |
|
697 }); |
|
698 }); |
|
699 }); |
|
700 |
|
701 // Tests that a normal add-on pending uninstall shows up in the search view |
|
702 add_test(function() { |
|
703 var ID = "addon1@tests.mozilla.org"; |
|
704 var list = gDocument.getElementById("search-list"); |
|
705 |
|
706 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
707 searchBox.value = "Uninstall"; |
|
708 |
|
709 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
710 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
711 |
|
712 wait_for_view_load(gManagerWindow, function() { |
|
713 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
714 |
|
715 // Make sure to show local add-ons |
|
716 EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
|
717 |
|
718 AddonManager.getAddonByID(ID, function(aAddon) { |
|
719 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
720 ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
|
721 |
|
722 var item = get_item_in_list(ID, list); |
|
723 isnot(item, null, "Should have found the add-on in the list"); |
|
724 |
|
725 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
726 isnot(button, null, "Should have a remove button"); |
|
727 ok(!button.disabled, "Button should not be disabled"); |
|
728 |
|
729 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
730 |
|
731 // Force XBL to apply |
|
732 item.clientTop; |
|
733 |
|
734 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
735 |
|
736 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
737 |
|
738 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
739 isnot(button, null, "Should have a restart button"); |
|
740 ok(!button.hidden, "Restart button should not be hidden"); |
|
741 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
742 isnot(button, null, "Should have an undo button"); |
|
743 |
|
744 gCategoryUtilities.openType("plugin", function() { |
|
745 is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin"); |
|
746 searchBox.value = "Uninstall"; |
|
747 |
|
748 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
749 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
750 |
|
751 wait_for_view_load(gManagerWindow, function() { |
|
752 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
753 |
|
754 var item = get_item_in_list(ID, list); |
|
755 isnot(item, null, "Should have found the add-on in the list"); |
|
756 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
757 |
|
758 ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
|
759 |
|
760 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
761 isnot(button, null, "Should have a restart button"); |
|
762 ok(!button.hidden, "Restart button should not be hidden"); |
|
763 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
764 isnot(button, null, "Should have an undo button"); |
|
765 |
|
766 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
767 |
|
768 // Force XBL to apply |
|
769 item.clientTop; |
|
770 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
771 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
772 isnot(button, null, "Should have a remove button"); |
|
773 ok(!button.disabled, "Button should not be disabled"); |
|
774 |
|
775 run_next_test(); |
|
776 }); |
|
777 }); |
|
778 }); |
|
779 }); |
|
780 }); |
|
781 |
|
782 // Tests that switching away from the list view finalises the uninstall of |
|
783 // multiple restartless add-ons |
|
784 add_test(function() { |
|
785 var ID = "addon2@tests.mozilla.org"; |
|
786 var ID2 = "addon6@tests.mozilla.org"; |
|
787 var list = gDocument.getElementById("addon-list"); |
|
788 |
|
789 // Select the extensions category |
|
790 gCategoryUtilities.openType("extension", function() { |
|
791 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
792 |
|
793 AddonManager.getAddonByID(ID, function(aAddon) { |
|
794 ok(aAddon.isActive, "Add-on should be active"); |
|
795 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
796 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
797 |
|
798 var item = get_item_in_list(ID, list); |
|
799 isnot(item, null, "Should have found the add-on in the list"); |
|
800 |
|
801 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
802 isnot(button, null, "Should have a remove button"); |
|
803 ok(!button.disabled, "Button should not be disabled"); |
|
804 |
|
805 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
806 |
|
807 // Force XBL to apply |
|
808 item.clientTop; |
|
809 |
|
810 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
811 |
|
812 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
813 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
814 |
|
815 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
816 isnot(button, null, "Should have a restart button"); |
|
817 ok(button.hidden, "Restart button should be hidden"); |
|
818 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
819 isnot(button, null, "Should have an undo button"); |
|
820 |
|
821 item = get_item_in_list(ID2, list); |
|
822 isnot(item, null, "Should have found the add-on in the list"); |
|
823 |
|
824 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
825 isnot(button, null, "Should have a remove button"); |
|
826 ok(!button.disabled, "Button should not be disabled"); |
|
827 |
|
828 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
829 |
|
830 gCategoryUtilities.openType("plugin", function() { |
|
831 is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension"); |
|
832 |
|
833 AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
|
834 is(aAddon, null, "Add-on should no longer be installed"); |
|
835 is(aAddon2, null, "Second add-on should no longer be installed"); |
|
836 |
|
837 gCategoryUtilities.openType("extension", function() { |
|
838 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
839 |
|
840 var item = get_item_in_list(ID, list); |
|
841 is(item, null, "Should not have found the add-on in the list"); |
|
842 item = get_item_in_list(ID2, list); |
|
843 is(item, null, "Should not have found the second add-on in the list"); |
|
844 |
|
845 run_next_test(); |
|
846 }); |
|
847 }); |
|
848 }); |
|
849 }); |
|
850 }); |
|
851 }); |
|
852 |
|
853 // Tests that switching away from the search view finalises the uninstall of |
|
854 // multiple restartless add-ons |
|
855 add_test(function() { |
|
856 var ID = "addon3@tests.mozilla.org"; |
|
857 var ID2 = "addon7@tests.mozilla.org"; |
|
858 var list = gDocument.getElementById("search-list"); |
|
859 |
|
860 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
861 searchBox.value = "Uninstall"; |
|
862 |
|
863 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
864 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
865 |
|
866 wait_for_view_load(gManagerWindow, function() { |
|
867 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
868 |
|
869 // Make sure to show local add-ons |
|
870 EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
|
871 |
|
872 AddonManager.getAddonByID(ID, function(aAddon) { |
|
873 ok(aAddon.isActive, "Add-on should be active"); |
|
874 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
875 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
876 |
|
877 var item = get_item_in_list(ID, list); |
|
878 isnot(item, null, "Should have found the add-on in the list"); |
|
879 |
|
880 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
881 isnot(button, null, "Should have a remove button"); |
|
882 ok(!button.disabled, "Button should not be disabled"); |
|
883 |
|
884 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
885 |
|
886 // Force XBL to apply |
|
887 item.clientTop; |
|
888 |
|
889 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
890 |
|
891 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
892 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
893 |
|
894 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
895 isnot(button, null, "Should have a restart button"); |
|
896 ok(button.hidden, "Restart button should be hidden"); |
|
897 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
898 isnot(button, null, "Should have an undo button"); |
|
899 |
|
900 item = get_item_in_list(ID2, list); |
|
901 isnot(item, null, "Should have found the add-on in the list"); |
|
902 |
|
903 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
904 isnot(button, null, "Should have a remove button"); |
|
905 ok(!button.disabled, "Button should not be disabled"); |
|
906 |
|
907 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
908 |
|
909 gCategoryUtilities.openType("plugin", function() { |
|
910 is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension"); |
|
911 |
|
912 AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
|
913 is(aAddon, null, "Add-on should no longer be installed"); |
|
914 is(aAddon2, null, "Second add-on should no longer be installed"); |
|
915 |
|
916 searchBox.value = "Uninstall"; |
|
917 |
|
918 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
919 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
920 |
|
921 wait_for_view_load(gManagerWindow, function() { |
|
922 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
923 |
|
924 var item = get_item_in_list(ID, list); |
|
925 is(item, null, "Should not have found the add-on in the list"); |
|
926 item = get_item_in_list(ID2, list); |
|
927 is(item, null, "Should not have found the second add-on in the list"); |
|
928 |
|
929 run_next_test(); |
|
930 }); |
|
931 }); |
|
932 }); |
|
933 }); |
|
934 }); |
|
935 }); |
|
936 |
|
937 // Tests that closing the manager from the list view finalises the uninstall of |
|
938 // multiple restartless add-ons |
|
939 add_test(function() { |
|
940 var ID = "addon4@tests.mozilla.org"; |
|
941 var ID2 = "addon8@tests.mozilla.org"; |
|
942 var list = gDocument.getElementById("addon-list"); |
|
943 |
|
944 // Select the extensions category |
|
945 gCategoryUtilities.openType("extension", function() { |
|
946 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
947 |
|
948 AddonManager.getAddonByID(ID, function(aAddon) { |
|
949 ok(aAddon.isActive, "Add-on should be active"); |
|
950 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
951 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
952 |
|
953 var item = get_item_in_list(ID, list); |
|
954 isnot(item, null, "Should have found the add-on in the list"); |
|
955 |
|
956 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
957 isnot(button, null, "Should have a remove button"); |
|
958 ok(!button.disabled, "Button should not be disabled"); |
|
959 |
|
960 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
961 |
|
962 // Force XBL to apply |
|
963 item.clientTop; |
|
964 |
|
965 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
966 |
|
967 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
968 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
969 |
|
970 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
971 isnot(button, null, "Should have a restart button"); |
|
972 ok(button.hidden, "Restart button should be hidden"); |
|
973 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
974 isnot(button, null, "Should have an undo button"); |
|
975 |
|
976 item = get_item_in_list(ID2, list); |
|
977 isnot(item, null, "Should have found the add-on in the list"); |
|
978 |
|
979 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
980 isnot(button, null, "Should have a remove button"); |
|
981 ok(!button.disabled, "Button should not be disabled"); |
|
982 |
|
983 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
984 |
|
985 close_manager(gManagerWindow, function() { |
|
986 AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
|
987 is(aAddon, null, "Add-on should no longer be installed"); |
|
988 is(aAddon2, null, "Second add-on should no longer be installed"); |
|
989 |
|
990 open_manager(null, function(aWindow) { |
|
991 gManagerWindow = aWindow; |
|
992 gDocument = gManagerWindow.document; |
|
993 gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
|
994 var list = gDocument.getElementById("addon-list"); |
|
995 |
|
996 is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
|
997 |
|
998 var item = get_item_in_list(ID, list); |
|
999 is(item, null, "Should not have found the add-on in the list"); |
|
1000 item = get_item_in_list(ID2, list); |
|
1001 is(item, null, "Should not have found the second add-on in the list"); |
|
1002 |
|
1003 run_next_test(); |
|
1004 }); |
|
1005 }); |
|
1006 }); |
|
1007 }); |
|
1008 }); |
|
1009 }); |
|
1010 |
|
1011 // Tests that closing the manager from the search view finalises the uninstall |
|
1012 // of multiple restartless add-ons |
|
1013 add_test(function() { |
|
1014 var ID = "addon5@tests.mozilla.org"; |
|
1015 var ID2 = "addon9@tests.mozilla.org"; |
|
1016 var list = gDocument.getElementById("search-list"); |
|
1017 |
|
1018 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
1019 searchBox.value = "Uninstall"; |
|
1020 |
|
1021 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
1022 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
1023 |
|
1024 wait_for_view_load(gManagerWindow, function() { |
|
1025 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
1026 |
|
1027 // Make sure to show local add-ons |
|
1028 EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
|
1029 |
|
1030 AddonManager.getAddonByID(ID, function(aAddon) { |
|
1031 ok(aAddon.isActive, "Add-on should be active"); |
|
1032 ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
|
1033 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
1034 |
|
1035 var item = get_item_in_list(ID, list); |
|
1036 isnot(item, null, "Should have found the add-on in the list"); |
|
1037 |
|
1038 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
1039 isnot(button, null, "Should have a remove button"); |
|
1040 ok(!button.disabled, "Button should not be disabled"); |
|
1041 |
|
1042 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
1043 |
|
1044 // Force XBL to apply |
|
1045 item.clientTop; |
|
1046 |
|
1047 is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
|
1048 |
|
1049 ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
|
1050 ok(!aAddon.isActive, "Add-on should be inactive"); |
|
1051 |
|
1052 var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
|
1053 isnot(button, null, "Should have a restart button"); |
|
1054 ok(button.hidden, "Restart button should be hidden"); |
|
1055 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
|
1056 isnot(button, null, "Should have an undo button"); |
|
1057 |
|
1058 item = get_item_in_list(ID2, list); |
|
1059 isnot(item, null, "Should have found the add-on in the list"); |
|
1060 |
|
1061 button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
|
1062 isnot(button, null, "Should have a remove button"); |
|
1063 ok(!button.disabled, "Button should not be disabled"); |
|
1064 |
|
1065 EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
|
1066 |
|
1067 close_manager(gManagerWindow, function() { |
|
1068 AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
|
1069 is(aAddon, null, "Add-on should no longer be installed"); |
|
1070 is(aAddon2, null, "Second add-on should no longer be installed"); |
|
1071 |
|
1072 open_manager(null, function(aWindow) { |
|
1073 gManagerWindow = aWindow; |
|
1074 gDocument = gManagerWindow.document; |
|
1075 gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
|
1076 var list = gDocument.getElementById("search-list"); |
|
1077 var searchBox = gManagerWindow.document.getElementById("header-search"); |
|
1078 |
|
1079 searchBox.value = "Uninstall"; |
|
1080 |
|
1081 EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
|
1082 EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
|
1083 |
|
1084 wait_for_view_load(gManagerWindow, function() { |
|
1085 is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
|
1086 |
|
1087 var item = get_item_in_list(ID, list); |
|
1088 is(item, null, "Should not have found the add-on in the list"); |
|
1089 item = get_item_in_list(ID2, list); |
|
1090 is(item, null, "Should not have found the second add-on in the list"); |
|
1091 |
|
1092 run_next_test(); |
|
1093 }); |
|
1094 }); |
|
1095 }); |
|
1096 }); |
|
1097 }); |
|
1098 }); |
|
1099 }); |