toolkit/mozapps/extensions/test/xpcshell/test_bug675371.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 function run_test() {
     6   do_test_pending();
     7   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
     8   startupManager();
    10   prepare_test({ }, [
    11     "onNewInstall"
    12   ]);
    14   AddonManager.getInstallForFile(do_get_addon("test_bug675371"), function(install) {
    15     ensure_test_completed();
    17     do_check_neq(install, null);
    19     prepare_test({
    20       "bug675371@tests.mozilla.org": [
    21         ["onInstalling", false],
    22         "onInstalled"
    23       ]
    24     }, [
    25       "onInstallStarted",
    26       "onInstallEnded",
    27     ], callback_soon(check_test));
    28     install.install();
    29   });
    30 }
    32 function check_test() {
    33   AddonManager.getAddonByID("bug675371@tests.mozilla.org", do_exception_wrap(function(addon) {
    34     do_check_neq(addon, null);
    35     do_check_true(addon.isActive);
    37     // Tests that chrome.manifest is registered when the addon is installed.
    38     var target = { active: false };
    39     Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
    40     do_check_true(target.active);
    42     prepare_test({
    43       "bug675371@tests.mozilla.org": [
    44         ["onDisabling", false],
    45         "onDisabled"
    46       ]
    47     });
    49     // Tests that chrome.manifest is unregistered when the addon is disabled.
    50     addon.userDisabled = true;
    51     target.active = false;
    52     try {
    53       Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
    54       do_throw("Chrome file should not have been found");
    55     } catch (e) {
    56       do_check_false(target.active);
    57     }
    59     prepare_test({
    60       "bug675371@tests.mozilla.org": [
    61         ["onEnabling", false],
    62         "onEnabled"
    63       ]
    64     });
    66     // Tests that chrome.manifest is registered when the addon is enabled.
    67     addon.userDisabled = false;
    68     target.active = false;
    69     Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
    70     do_check_true(target.active);
    72     prepare_test({
    73       "bug675371@tests.mozilla.org": [
    74         ["onUninstalling", false],
    75         "onUninstalled"
    76       ]
    77     });
    79     // Tests that chrome.manifest is unregistered when the addon is uninstalled.
    80     addon.uninstall();
    81     target.active = false;
    82     try {
    83       Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
    84       do_throw("Chrome file should not have been found");
    85     } catch (e) {
    86       do_check_false(target.active);
    87     }
    89     do_execute_soon(do_test_finished);
    90   }));
    91 }

mercurial