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.

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

mercurial