toolkit/mozapps/extensions/test/xpcshell/test_targetPlatforms.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_targetPlatforms.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,146 @@
     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 verifies that the targetPlatform entries are checked when deciding
     1.9 +// if an add-on is incompatible.
    1.10 +
    1.11 +// No targetPlatforms so should be compatible
    1.12 +var addon1 = {
    1.13 +  id: "addon1@tests.mozilla.org",
    1.14 +  version: "1.0",
    1.15 +  name: "Test 1",
    1.16 +  targetApplications: [{
    1.17 +    id: "xpcshell@tests.mozilla.org",
    1.18 +    minVersion: "1",
    1.19 +    maxVersion: "1"
    1.20 +  }]
    1.21 +};
    1.22 +
    1.23 +// Matches the OS
    1.24 +var addon2 = {
    1.25 +  id: "addon2@tests.mozilla.org",
    1.26 +  version: "1.0",
    1.27 +  name: "Test 2",
    1.28 +  targetPlatforms: [
    1.29 +    "XPCShell",
    1.30 +    "WINNT_x86",
    1.31 +    "XPCShell"
    1.32 +  ],
    1.33 +  targetApplications: [{
    1.34 +    id: "xpcshell@tests.mozilla.org",
    1.35 +    minVersion: "1",
    1.36 +    maxVersion: "1"
    1.37 +  }]
    1.38 +};
    1.39 +
    1.40 +// Matches the OS and ABI
    1.41 +var addon3 = {
    1.42 +  id: "addon3@tests.mozilla.org",
    1.43 +  version: "1.0",
    1.44 +  name: "Test 3",
    1.45 +  targetPlatforms: [
    1.46 +    "WINNT",
    1.47 +    "XPCShell_noarch-spidermonkey"
    1.48 +  ],
    1.49 +  targetApplications: [{
    1.50 +    id: "xpcshell@tests.mozilla.org",
    1.51 +    minVersion: "1",
    1.52 +    maxVersion: "1"
    1.53 +  }]
    1.54 +};
    1.55 +
    1.56 +// Doesn't match
    1.57 +var addon4 = {
    1.58 +  id: "addon4@tests.mozilla.org",
    1.59 +  version: "1.0",
    1.60 +  name: "Test 4",
    1.61 +  targetPlatforms: [
    1.62 +    "WINNT_noarch-spidermonkey",
    1.63 +    "Darwin",
    1.64 +    "WINNT_noarch-spidermonkey"
    1.65 +  ],
    1.66 +  targetApplications: [{
    1.67 +    id: "xpcshell@tests.mozilla.org",
    1.68 +    minVersion: "1",
    1.69 +    maxVersion: "1"
    1.70 +  }]
    1.71 +};
    1.72 +
    1.73 +// Matches the OS but since a different entry specifies ABI this doesn't match.
    1.74 +var addon5 = {
    1.75 +  id: "addon5@tests.mozilla.org",
    1.76 +  version: "1.0",
    1.77 +  name: "Test 5",
    1.78 +  targetPlatforms: [
    1.79 +    "XPCShell",
    1.80 +    "XPCShell_foo"
    1.81 +  ],
    1.82 +  targetApplications: [{
    1.83 +    id: "xpcshell@tests.mozilla.org",
    1.84 +    minVersion: "1",
    1.85 +    maxVersion: "1"
    1.86 +  }]
    1.87 +};
    1.88 +
    1.89 +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
    1.90 +
    1.91 +const profileDir = gProfD.clone();
    1.92 +profileDir.append("extensions");
    1.93 +
    1.94 +// Set up the profile
    1.95 +function run_test() {
    1.96 +  do_test_pending();
    1.97 +
    1.98 +  writeInstallRDFForExtension(addon1, profileDir);
    1.99 +  writeInstallRDFForExtension(addon2, profileDir);
   1.100 +  writeInstallRDFForExtension(addon3, profileDir);
   1.101 +  writeInstallRDFForExtension(addon4, profileDir);
   1.102 +  writeInstallRDFForExtension(addon5, profileDir);
   1.103 +
   1.104 +  restartManager();
   1.105 +  AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
   1.106 +                               "addon2@tests.mozilla.org",
   1.107 +                               "addon3@tests.mozilla.org",
   1.108 +                               "addon4@tests.mozilla.org",
   1.109 +                               "addon5@tests.mozilla.org"],
   1.110 +                               function([a1, a2, a3, a4, a5]) {
   1.111 +
   1.112 +    do_check_neq(a1, null);
   1.113 +    do_check_false(a1.appDisabled);
   1.114 +    do_check_true(a1.isPlatformCompatible);
   1.115 +    do_check_true(a1.isActive);
   1.116 +    do_check_true(isExtensionInAddonsList(profileDir, a1.id));
   1.117 +    do_check_in_crash_annotation(addon1.id, addon1.version);
   1.118 +
   1.119 +    do_check_neq(a2, null);
   1.120 +    do_check_false(a2.appDisabled);
   1.121 +    do_check_true(a2.isPlatformCompatible);
   1.122 +    do_check_true(a2.isActive);
   1.123 +    do_check_true(isExtensionInAddonsList(profileDir, a2.id));
   1.124 +    do_check_in_crash_annotation(addon2.id, addon2.version);
   1.125 +
   1.126 +    do_check_neq(a3, null);
   1.127 +    do_check_false(a3.appDisabled);
   1.128 +    do_check_true(a3.isPlatformCompatible);
   1.129 +    do_check_true(a3.isActive);
   1.130 +    do_check_true(isExtensionInAddonsList(profileDir, a3.id));
   1.131 +    do_check_in_crash_annotation(addon3.id, addon3.version);
   1.132 +
   1.133 +    do_check_neq(a4, null);
   1.134 +    do_check_true(a4.appDisabled);
   1.135 +    do_check_false(a4.isPlatformCompatible);
   1.136 +    do_check_false(a4.isActive);
   1.137 +    do_check_false(isExtensionInAddonsList(profileDir, a4.id));
   1.138 +    do_check_not_in_crash_annotation(addon4.id, addon4.version);
   1.139 +
   1.140 +    do_check_neq(a5, null);
   1.141 +    do_check_true(a5.appDisabled);
   1.142 +    do_check_false(a5.isPlatformCompatible);
   1.143 +    do_check_false(a5.isActive);
   1.144 +    do_check_false(isExtensionInAddonsList(profileDir, a5.id));
   1.145 +    do_check_not_in_crash_annotation(addon5.id, addon5.version);
   1.146 +
   1.147 +    do_execute_soon(do_test_finished);
   1.148 +  });
   1.149 +}

mercurial