toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.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_bug470377_3_strictcompat.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,94 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 + */
     1.8 +
     1.9 +function run_test() {
    1.10 +  do_test_pending();
    1.11 +  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2");
    1.12 +  Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
    1.13 +
    1.14 +  // inject the add-ons into the profile
    1.15 +  var dest = gProfD.clone();
    1.16 +  dest.append("extensions");
    1.17 +  dest.append("bug470377_1@tests.mozilla.org");
    1.18 +  dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
    1.19 +  var source = do_get_file("data/test_bug470377/install_1.rdf");
    1.20 +  source.copyTo(dest, "install.rdf");
    1.21 +  dest = gProfD.clone();
    1.22 +  dest.append("extensions");
    1.23 +  dest.append("bug470377_2@tests.mozilla.org");
    1.24 +  dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
    1.25 +  source = do_get_file("data/test_bug470377/install_2.rdf");
    1.26 +  source.copyTo(dest, "install.rdf");
    1.27 +  dest = gProfD.clone();
    1.28 +  dest.append("extensions");
    1.29 +  dest.append("bug470377_3@tests.mozilla.org");
    1.30 +  dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
    1.31 +  source = do_get_file("data/test_bug470377/install_3.rdf");
    1.32 +  source.copyTo(dest, "install.rdf");
    1.33 +  dest = gProfD.clone();
    1.34 +  dest.append("extensions");
    1.35 +  dest.append("bug470377_4@tests.mozilla.org");
    1.36 +  dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
    1.37 +  source = do_get_file("data/test_bug470377/install_4.rdf");
    1.38 +  source.copyTo(dest, "install.rdf");
    1.39 +  dest = gProfD.clone();
    1.40 +  dest.append("extensions");
    1.41 +  dest.append("bug470377_5@tests.mozilla.org");
    1.42 +  dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
    1.43 +  source = do_get_file("data/test_bug470377/install_5.rdf");
    1.44 +  source.copyTo(dest, "install.rdf");
    1.45 +
    1.46 +  startupManager();
    1.47 +
    1.48 +  run_test_1();
    1.49 +}
    1.50 +
    1.51 +function run_test_1() {
    1.52 +  AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
    1.53 +                               "bug470377_2@tests.mozilla.org",
    1.54 +                               "bug470377_3@tests.mozilla.org",
    1.55 +                               "bug470377_4@tests.mozilla.org",
    1.56 +                               "bug470377_5@tests.mozilla.org"],
    1.57 +                               function([a1, a2, a3, a4, a5]) {
    1.58 +    do_check_neq(a1, null);
    1.59 +    do_check_false(a1.isActive);
    1.60 +    do_check_neq(a2, null);
    1.61 +    do_check_false(a2.isActive);
    1.62 +    do_check_neq(a3, null);
    1.63 +    do_check_false(a3.isActive);
    1.64 +    do_check_neq(a4, null);
    1.65 +    do_check_true(a4.isActive);
    1.66 +    do_check_neq(a5, null);
    1.67 +    do_check_true(a5.isActive);
    1.68 +
    1.69 +    do_execute_soon(run_test_2);
    1.70 +  });
    1.71 +}
    1.72 +
    1.73 +function run_test_2() {
    1.74 +  AddonManager.checkCompatibility = false;
    1.75 +
    1.76 +  restartManager();
    1.77 +
    1.78 +  AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
    1.79 +                               "bug470377_2@tests.mozilla.org",
    1.80 +                               "bug470377_3@tests.mozilla.org",
    1.81 +                               "bug470377_4@tests.mozilla.org",
    1.82 +                               "bug470377_5@tests.mozilla.org"],
    1.83 +                               function([a1, a2, a3, a4, a5]) {
    1.84 +    do_check_neq(a1, null);
    1.85 +    do_check_false(a1.isActive);
    1.86 +    do_check_neq(a2, null);
    1.87 +    do_check_true(a2.isActive);
    1.88 +    do_check_neq(a3, null);
    1.89 +    do_check_true(a3.isActive);
    1.90 +    do_check_neq(a4, null);
    1.91 +    do_check_true(a4.isActive);
    1.92 +    do_check_neq(a5, null);
    1.93 +    do_check_true(a5.isActive);
    1.94 +
    1.95 +    do_execute_soon(do_test_finished);
    1.96 +  });
    1.97 +}

mercurial