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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/test/xpcshell/test_general.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     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 +// This just verifies that the EM can actually startup and shutdown a few times
     1.9 +// without any errors
    1.10 +
    1.11 +// We have to look up how many add-ons are present since there will be plugins
    1.12 +// etc. detected
    1.13 +var gCount;
    1.14 +
    1.15 +function run_test() {
    1.16 +  do_test_pending();
    1.17 +  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
    1.18 +
    1.19 +  var count = 0;
    1.20 +  startupManager();
    1.21 +  AddonManager.getAddonsByTypes(null, function(list) {
    1.22 +    gCount = list.length;
    1.23 +
    1.24 +    do_execute_soon(run_test_1);
    1.25 +  });
    1.26 +}
    1.27 +
    1.28 +function run_test_1() {
    1.29 +  restartManager();
    1.30 +
    1.31 +  AddonManager.getAddonsByTypes(null, function(addons) {
    1.32 +    do_check_eq(gCount, addons.length);
    1.33 +
    1.34 +    AddonManager.getAddonsWithOperationsByTypes(null, function(pendingAddons) {
    1.35 +      do_check_eq(0, pendingAddons.length);
    1.36 +
    1.37 +      do_execute_soon(run_test_2);
    1.38 +    });
    1.39 +  });
    1.40 +}
    1.41 +
    1.42 +function run_test_2() {
    1.43 +  shutdownManager();
    1.44 +
    1.45 +  startupManager(false);
    1.46 +
    1.47 +  AddonManager.getAddonsByTypes(null, function(addons) {
    1.48 +    do_check_eq(gCount, addons.length);
    1.49 +
    1.50 +    do_execute_soon(run_test_3);
    1.51 +  });
    1.52 +}
    1.53 +
    1.54 +function run_test_3() {
    1.55 +  restartManager();
    1.56 +
    1.57 +  AddonManager.getAddonsByTypes(null, callback_soon(function(addons) {
    1.58 +    do_check_eq(gCount, addons.length);
    1.59 +    do_test_finished();
    1.60 +  }));
    1.61 +}

mercurial