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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 });

mercurial