Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
5 // Bug 608316 - Test that cancelling an uninstall during the onUninstalling
6 // event doesn't confuse the UI
8 var gProvider;
10 function test() {
11 waitForExplicitFinish();
13 gProvider = new MockProvider();
15 gProvider.createAddons([{
16 id: "addon1@tests.mozilla.org",
17 name: "addon 1",
18 version: "1.0"
19 }]);
21 run_next_test();
22 }
25 function end_test() {
26 finish();
27 }
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 }
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 });
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");
51 var removeBtn = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn");
52 EventUtils.synthesizeMouseAtCenter(removeBtn, { }, aManager);
54 ok(sawUninstall, "Should have seen the uninstall event");
55 sawUninstall = false;
57 is(addon.getAttribute("pending"), "", "Add-on should not be uninstalling");
59 close_manager(aManager, function() {
60 ok(!sawUninstall, "Should not have seen another uninstall event");
62 run_next_test();
63 });
64 });
65 });