michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Verify that API functions fail if the Add-ons Manager isn't initialised. michael@0: michael@0: const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges", michael@0: "addTypeListener", "removeTypeListener", michael@0: "addAddonListener", "removeAddonListener", michael@0: "addInstallListener", "removeInstallListener", michael@0: "addManagerListener", "removeManagerListener", michael@0: "mapURIToAddonID"]; michael@0: michael@0: const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride", michael@0: "AddonScreenshot", "AddonType", "startup", "shutdown", michael@0: "registerProvider", "unregisterProvider", michael@0: "addStartupChange", "removeStartupChange", michael@0: "recordTimestamp", "recordSimpleMeasure", michael@0: "recordException", "getSimpleMeasures", "simpleTimer", michael@0: "setTelemetryDetails", "getTelemetryDetails", michael@0: "callNoUpdateListeners"]; michael@0: michael@0: function test_functions() { michael@0: for (let prop in AddonManager) { michael@0: if (typeof AddonManager[prop] != "function") michael@0: continue; michael@0: if (IGNORE.indexOf(prop) != -1) michael@0: continue; michael@0: michael@0: try { michael@0: do_print("AddonManager." + prop); michael@0: AddonManager[prop](); michael@0: do_throw(prop + " did not throw an exception"); michael@0: } michael@0: catch (e) { michael@0: if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) michael@0: do_throw(prop + " threw an unexpected exception: " + e); michael@0: } michael@0: } michael@0: michael@0: for (let prop in AddonManagerPrivate) { michael@0: if (typeof AddonManagerPrivate[prop] != "function") michael@0: continue; michael@0: if (IGNORE_PRIVATE.indexOf(prop) != -1) michael@0: continue; michael@0: michael@0: try { michael@0: do_print("AddonManagerPrivate." + prop); michael@0: AddonManagerPrivate[prop](); michael@0: do_throw(prop + " did not throw an exception"); michael@0: } michael@0: catch (e) { michael@0: if (e.result != Components.results.NS_ERROR_NOT_INITIALIZED) michael@0: do_throw(prop + " threw an unexpected exception: " + e); michael@0: } michael@0: } michael@0: } michael@0: michael@0: function run_test() { michael@0: createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); michael@0: test_functions(); michael@0: startupManager(); michael@0: shutdownManager(); michael@0: test_functions(); michael@0: }