toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b16c9f2c55dd
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 // Verify that API functions fail if the Add-ons Manager isn't initialised.
6
7 const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges",
8 "addTypeListener", "removeTypeListener",
9 "addAddonListener", "removeAddonListener",
10 "addInstallListener", "removeInstallListener",
11 "addManagerListener", "removeManagerListener",
12 "mapURIToAddonID"];
13
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"];
22
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;
29
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 }
40
41 for (let prop in AddonManagerPrivate) {
42 if (typeof AddonManagerPrivate[prop] != "function")
43 continue;
44 if (IGNORE_PRIVATE.indexOf(prop) != -1)
45 continue;
46
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 }
58
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