1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.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 +// Verify that API functions fail if the Add-ons Manager isn't initialised. 1.9 + 1.10 +const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges", 1.11 + "addTypeListener", "removeTypeListener", 1.12 + "addAddonListener", "removeAddonListener", 1.13 + "addInstallListener", "removeInstallListener", 1.14 + "addManagerListener", "removeManagerListener", 1.15 + "mapURIToAddonID"]; 1.16 + 1.17 +const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride", 1.18 + "AddonScreenshot", "AddonType", "startup", "shutdown", 1.19 + "registerProvider", "unregisterProvider", 1.20 + "addStartupChange", "removeStartupChange", 1.21 + "recordTimestamp", "recordSimpleMeasure", 1.22 + "recordException", "getSimpleMeasures", "simpleTimer", 1.23 + "setTelemetryDetails", "getTelemetryDetails", 1.24 + "callNoUpdateListeners"]; 1.25 + 1.26 +function test_functions() { 1.27 + for (let prop in AddonManager) { 1.28 + if (typeof AddonManager[prop] != "function") 1.29 + continue; 1.30 + if (IGNORE.indexOf(prop) != -1) 1.31 + continue; 1.32 + 1.33 + try { 1.34 + do_print("AddonManager." + prop); 1.35 + AddonManager[prop](); 1.36 + do_throw(prop + " did not throw an exception"); 1.37 + } 1.38 + catch (e) { 1.39 + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) 1.40 + do_throw(prop + " threw an unexpected exception: " + e); 1.41 + } 1.42 + } 1.43 + 1.44 + for (let prop in AddonManagerPrivate) { 1.45 + if (typeof AddonManagerPrivate[prop] != "function") 1.46 + continue; 1.47 + if (IGNORE_PRIVATE.indexOf(prop) != -1) 1.48 + continue; 1.49 + 1.50 + try { 1.51 + do_print("AddonManagerPrivate." + prop); 1.52 + AddonManagerPrivate[prop](); 1.53 + do_throw(prop + " did not throw an exception"); 1.54 + } 1.55 + catch (e) { 1.56 + if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) 1.57 + do_throw(prop + " threw an unexpected exception: " + e); 1.58 + } 1.59 + } 1.60 +} 1.61 + 1.62 +function run_test() { 1.63 + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); 1.64 + test_functions(); 1.65 + startupManager(); 1.66 + shutdownManager(); 1.67 + test_functions(); 1.68 +}