toolkit/mozapps/extensions/test/xpcshell/test_shutdown.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 // Verify that API functions fail if the Add-ons Manager isn't initialised.
     7 const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges",
     8                 "addTypeListener", "removeTypeListener",
     9                 "addAddonListener", "removeAddonListener",
    10                 "addInstallListener", "removeInstallListener",
    11                 "addManagerListener", "removeManagerListener",
    12                 "mapURIToAddonID"];
    14 const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride",
    15                         "AddonScreenshot", "AddonType", "startup", "shutdown",
    16                         "registerProvider", "unregisterProvider",
    17                         "addStartupChange", "removeStartupChange",
    18                         "recordTimestamp", "recordSimpleMeasure",
    19                         "recordException", "getSimpleMeasures", "simpleTimer",
    20                         "setTelemetryDetails", "getTelemetryDetails",
    21                         "callNoUpdateListeners"];
    23 function test_functions() {
    24   for (let prop in AddonManager) {
    25     if (typeof AddonManager[prop] != "function")
    26       continue;
    27     if (IGNORE.indexOf(prop) != -1)
    28       continue;
    30     try {
    31       do_print("AddonManager." + prop);
    32       AddonManager[prop]();
    33       do_throw(prop + " did not throw an exception");
    34     }
    35     catch (e) {
    36       if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED)
    37         do_throw(prop + " threw an unexpected exception: " + e);
    38     }
    39   }
    41   for (let prop in AddonManagerPrivate) {
    42     if (typeof AddonManagerPrivate[prop] != "function")
    43       continue;
    44     if (IGNORE_PRIVATE.indexOf(prop) != -1)
    45       continue;
    47     try {
    48       do_print("AddonManagerPrivate." + prop);
    49       AddonManagerPrivate[prop]();
    50       do_throw(prop + " did not throw an exception");
    51     }
    52     catch (e) {
    53       if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED)
    54         do_throw(prop + " threw an unexpected exception: " + e);
    55     }
    56   }
    57 }
    59 function run_test() {
    60   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
    61   test_functions();
    62   startupManager();
    63   shutdownManager();
    64   test_functions();
    65 }

mercurial