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