toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.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_checkCompatibility_themeOverride.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     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 (temporary)
     1.9 +// extensions.checkCompatibility.temporaryThemeOverride_minAppVersion
    1.10 +// preference works.
    1.11 +
    1.12 +var ADDONS = [{
    1.13 +  id: "addon1@tests.mozilla.org",
    1.14 +  type: 4,
    1.15 +  internalName: "theme1/1.0",
    1.16 +  version: "1.0",
    1.17 +  name: "Test 1",
    1.18 +  targetApplications: [{
    1.19 +    id: "xpcshell@tests.mozilla.org",
    1.20 +    minVersion: "1.0",
    1.21 +    maxVersion: "1.0"
    1.22 +  }]
    1.23 +}, {
    1.24 +  id: "addon2@tests.mozilla.org",
    1.25 +  type: 4,
    1.26 +  internalName: "theme2/1.0",
    1.27 +  version: "1.0",
    1.28 +  name: "Test 2",
    1.29 +  targetApplications: [{
    1.30 +    id: "xpcshell@tests.mozilla.org",
    1.31 +    minVersion: "2.0",
    1.32 +    maxVersion: "2.0"
    1.33 +  }]
    1.34 +}];
    1.35 +
    1.36 +const profileDir = gProfD.clone();
    1.37 +profileDir.append("extensions");
    1.38 +
    1.39 +
    1.40 +function run_test() {
    1.41 +  do_test_pending();
    1.42 +  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3.0", "1");
    1.43 +
    1.44 +  for (let a of ADDONS) {
    1.45 +    writeInstallRDFForExtension(a, profileDir);
    1.46 +  }
    1.47 +
    1.48 +  startupManager();
    1.49 +
    1.50 +  run_test_1();
    1.51 +}
    1.52 +
    1.53 +function run_test_1() {
    1.54 +  AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
    1.55 +                               "addon2@tests.mozilla.org"],
    1.56 +                               function([a1, a2]) {
    1.57 +
    1.58 +    do_check_neq(a1, null);
    1.59 +    do_check_false(a1.isActive);
    1.60 +    do_check_false(a1.isCompatible);
    1.61 +    do_check_true(a1.appDisabled);
    1.62 +
    1.63 +    do_check_neq(a2, null);
    1.64 +    do_check_false(a2.isActive);
    1.65 +    do_check_false(a2.isCompatible);
    1.66 +    do_check_true(a1.appDisabled);
    1.67 +
    1.68 +    do_execute_soon(run_test_2);
    1.69 +  });
    1.70 +}
    1.71 +
    1.72 +function run_test_2() {
    1.73 +  Services.prefs.setCharPref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "2.0");
    1.74 +  if (isNightlyChannel())
    1.75 +    Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
    1.76 +  else
    1.77 +    Services.prefs.setBoolPref("extensions.checkCompatibility.3.0", false);
    1.78 +  restartManager();
    1.79 +
    1.80 +  AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
    1.81 +                               "addon2@tests.mozilla.org"],
    1.82 +                               function([a1, a2]) {
    1.83 +
    1.84 +    do_check_neq(a1, null);
    1.85 +    do_check_false(a1.isActive);
    1.86 +    do_check_false(a1.isCompatible);
    1.87 +    do_check_true(a1.appDisabled);
    1.88 +
    1.89 +    do_check_neq(a2, null);
    1.90 +    do_check_false(a2.isActive);
    1.91 +    do_check_false(a2.isCompatible);
    1.92 +    do_check_false(a2.appDisabled);
    1.93 +
    1.94 +    do_execute_soon(do_test_finished);
    1.95 +  });
    1.96 +}

mercurial