1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_bug608316.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,65 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// Bug 608316 - Test that cancelling an uninstall during the onUninstalling 1.9 +// event doesn't confuse the UI 1.10 + 1.11 +var gProvider; 1.12 + 1.13 +function test() { 1.14 + waitForExplicitFinish(); 1.15 + 1.16 + gProvider = new MockProvider(); 1.17 + 1.18 + gProvider.createAddons([{ 1.19 + id: "addon1@tests.mozilla.org", 1.20 + name: "addon 1", 1.21 + version: "1.0" 1.22 + }]); 1.23 + 1.24 + run_next_test(); 1.25 +} 1.26 + 1.27 + 1.28 +function end_test() { 1.29 + finish(); 1.30 +} 1.31 + 1.32 + 1.33 +add_test(function() { 1.34 + var sawUninstall = false; 1.35 + var listener = { 1.36 + onUninstalling: function(aAddon, aRestartRequired) { 1.37 + if (aAddon.id != "addon1@tests.mozilla.org") 1.38 + return; 1.39 + sawUninstall = true; 1.40 + aAddon.cancelUninstall(); 1.41 + } 1.42 + } 1.43 + 1.44 + // Important to add this before opening the UI so it gets its events first 1.45 + AddonManager.addAddonListener(listener); 1.46 + registerCleanupFunction(function() { 1.47 + AddonManager.removeAddonListener(listener); 1.48 + }); 1.49 + 1.50 + open_manager("addons://list/extension", function(aManager) { 1.51 + var addon = get_addon_element(aManager, "addon1@tests.mozilla.org"); 1.52 + isnot(addon, null, "Should see the add-on in the list"); 1.53 + 1.54 + var removeBtn = aManager.document.getAnonymousElementByAttribute(addon, "anonid", "remove-btn"); 1.55 + EventUtils.synthesizeMouseAtCenter(removeBtn, { }, aManager); 1.56 + 1.57 + ok(sawUninstall, "Should have seen the uninstall event"); 1.58 + sawUninstall = false; 1.59 + 1.60 + is(addon.getAttribute("pending"), "", "Add-on should not be uninstalling"); 1.61 + 1.62 + close_manager(aManager, function() { 1.63 + ok(!sawUninstall, "Should not have seen another uninstall event"); 1.64 + 1.65 + run_next_test(); 1.66 + }); 1.67 + }); 1.68 +});