toolkit/mozapps/extensions/test/browser/browser_bug608316.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:2144c2d7c7b3
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 // Bug 608316 - Test that cancelling an uninstall during the onUninstalling
6 // event doesn't confuse the UI
7
8 var gProvider;
9
10 function test() {
11 waitForExplicitFinish();
12
13 gProvider = new MockProvider();
14
15 gProvider.createAddons([{
16 id: "addon1@tests.mozilla.org",
17 name: "addon 1",
18 version: "1.0"
19 }]);
20
21 run_next_test();
22 }
23
24
25 function end_test() {
26 finish();
27 }
28
29
30 add_test(function() {
31 var sawUninstall = false;
32 var listener = {
33 onUninstalling: function(aAddon, aRestartRequired) {
34 if (aAddon.id != "addon1@tests.mozilla.org")
35 return;
36 sawUninstall = true;
37 aAddon.cancelUninstall();
38 }
39 }
40
41 // Important to add this before opening the UI so it gets its events first
42 AddonManager.addAddonListener(listener);
43 registerCleanupFunction(function() {
44 AddonManager.removeAddonListener(listener);
45 });
46
47 open_manager("addons://list/extension", function(aManager) {
48 var addon = get_addon_element(aManager, "addon1@tests.mozilla.org");
49 isnot(addon, null, "Should see the add-on in the list");
50
51 var removeBtn = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn");
52 EventUtils.synthesizeMouseAtCenter(removeBtn, { }, aManager);
53
54 ok(sawUninstall, "Should have seen the uninstall event");
55 sawUninstall = false;
56
57 is(addon.getAttribute("pending"), "", "Add-on should not be uninstalling");
58
59 close_manager(aManager, function() {
60 ok(!sawUninstall, "Should not have seen another uninstall event");
61
62 run_next_test();
63 });
64 });
65 });

mercurial