toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.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_hasbinarycomponents.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     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 +// Tests detection of binary components via parsing of chrome manifests.
     1.9 +
    1.10 +const profileDir = gProfD.clone();
    1.11 +profileDir.append("extensions");
    1.12 +
    1.13 +function run_test() {
    1.14 +  do_test_pending();
    1.15 +  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
    1.16 +
    1.17 +  startupManager();
    1.18 +  
    1.19 +  installAllFiles([do_get_addon("test_chromemanifest_1"),
    1.20 +                   do_get_addon("test_chromemanifest_2"),
    1.21 +                   do_get_addon("test_chromemanifest_3"),
    1.22 +                   do_get_addon("test_chromemanifest_4"),
    1.23 +                   do_get_addon("test_chromemanifest_5")],
    1.24 +                  function() {
    1.25 +
    1.26 +    restartManager();
    1.27 +
    1.28 +    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
    1.29 +                                 "addon2@tests.mozilla.org",
    1.30 +                                 "addon3@tests.mozilla.org",
    1.31 +                                 "addon4@tests.mozilla.org",
    1.32 +                                 "addon5@tests.mozilla.org"],
    1.33 +                                function([a1, a2, a3, a4, a5]) {
    1.34 +      // addon1 has no binary components
    1.35 +      do_check_neq(a1, null);
    1.36 +      do_check_false(a1.userDisabled);
    1.37 +      do_check_false(a1.hasBinaryComponents);
    1.38 +      do_check_true(a1.isCompatible);
    1.39 +      do_check_false(a1.appDisabled);
    1.40 +      do_check_true(a1.isActive);
    1.41 +      do_check_true(isExtensionInAddonsList(profileDir, a1.id));
    1.42 +
    1.43 +      // addon2 has a binary component, is compatible
    1.44 +      do_check_neq(a2, null);
    1.45 +      do_check_false(a2.userDisabled);
    1.46 +      do_check_true(a2.hasBinaryComponents);
    1.47 +      do_check_true(a2.isCompatible);
    1.48 +      do_check_false(a2.appDisabled);
    1.49 +      do_check_true(a2.isActive);
    1.50 +      do_check_true(isExtensionInAddonsList(profileDir, a2.id));
    1.51 +
    1.52 +      // addon3 has a binary component, is incompatible
    1.53 +      do_check_neq(a3, null);
    1.54 +      do_check_false(a3.userDisabled);
    1.55 +      do_check_true(a2.hasBinaryComponents);
    1.56 +      do_check_false(a3.isCompatible);
    1.57 +      do_check_true(a3.appDisabled);
    1.58 +      do_check_false(a3.isActive);
    1.59 +      do_check_false(isExtensionInAddonsList(profileDir, a3.id));
    1.60 +
    1.61 +      // addon4 has a binary component listed in a sub-manifest, is incompatible
    1.62 +      do_check_neq(a4, null);
    1.63 +      do_check_false(a4.userDisabled);
    1.64 +      do_check_true(a2.hasBinaryComponents);
    1.65 +      do_check_false(a4.isCompatible);
    1.66 +      do_check_true(a4.appDisabled);
    1.67 +      do_check_false(a4.isActive);
    1.68 +      do_check_false(isExtensionInAddonsList(profileDir, a4.id));
    1.69 +
    1.70 +      // addon5 has a binary component, but is set to not unpack
    1.71 +      do_check_neq(a5, null);
    1.72 +      do_check_false(a5.userDisabled);
    1.73 +      if (TEST_UNPACKED)
    1.74 +        do_check_true(a5.hasBinaryComponents);
    1.75 +      else
    1.76 +        do_check_false(a5.hasBinaryComponents);
    1.77 +      do_check_true(a5.isCompatible);
    1.78 +      do_check_false(a5.appDisabled);
    1.79 +      do_check_true(a5.isActive);
    1.80 +      do_check_true(isExtensionInAddonsList(profileDir, a5.id));
    1.81 +
    1.82 +      do_execute_soon(do_test_finished);
    1.83 +    });
    1.84 +  });
    1.85 +}

mercurial