1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 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.1a4", "2"); 1.12 + 1.13 + // inject the add-ons into the profile 1.14 + var profileDir = gProfD.clone(); 1.15 + profileDir.append("extensions"); 1.16 + var dest = profileDir.clone(); 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 = profileDir.clone(); 1.22 + dest.append("bug470377_2@tests.mozilla.org"); 1.23 + dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); 1.24 + source = do_get_file("data/test_bug470377/install_2.rdf"); 1.25 + source.copyTo(dest, "install.rdf"); 1.26 + dest = profileDir.clone(); 1.27 + dest.append("bug470377_3@tests.mozilla.org"); 1.28 + dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); 1.29 + source = do_get_file("data/test_bug470377/install_3.rdf"); 1.30 + source.copyTo(dest, "install.rdf"); 1.31 + dest = profileDir.clone(); 1.32 + dest.append("bug470377_4@tests.mozilla.org"); 1.33 + dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); 1.34 + source = do_get_file("data/test_bug470377/install_4.rdf"); 1.35 + source.copyTo(dest, "install.rdf"); 1.36 + dest = profileDir.clone(); 1.37 + dest.append("bug470377_5@tests.mozilla.org"); 1.38 + dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755); 1.39 + source = do_get_file("data/test_bug470377/install_5.rdf"); 1.40 + source.copyTo(dest, "install.rdf"); 1.41 + 1.42 + run_test_1(); 1.43 +} 1.44 + 1.45 +function run_test_1() { 1.46 + startupManager(); 1.47 + AddonManager.checkCompatibility = false; 1.48 + restartManager(); 1.49 + 1.50 + AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", 1.51 + "bug470377_2@tests.mozilla.org", 1.52 + "bug470377_3@tests.mozilla.org", 1.53 + "bug470377_4@tests.mozilla.org", 1.54 + "bug470377_5@tests.mozilla.org"], 1.55 + function([a1, a2, a3, a4, a5]) { 1.56 + do_check_neq(a1, null); 1.57 + do_check_false(a1.isActive); 1.58 + do_check_neq(a2, null); 1.59 + do_check_true(a2.isActive); 1.60 + do_check_neq(a3, null); 1.61 + do_check_true(a3.isActive); 1.62 + do_check_neq(a4, null); 1.63 + do_check_true(a4.isActive); 1.64 + do_check_neq(a5, null); 1.65 + do_check_true(a5.isActive); 1.66 + 1.67 + do_execute_soon(run_test_2); 1.68 + }); 1.69 +} 1.70 + 1.71 +function run_test_2() { 1.72 + AddonManager.checkCompatibility = true; 1.73 + 1.74 + restartManager(); 1.75 + 1.76 + AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org", 1.77 + "bug470377_2@tests.mozilla.org", 1.78 + "bug470377_3@tests.mozilla.org", 1.79 + "bug470377_4@tests.mozilla.org", 1.80 + "bug470377_5@tests.mozilla.org"], 1.81 + function([a1, a2, a3, a4, a5]) { 1.82 + do_check_neq(a1, null); 1.83 + do_check_false(a1.isActive); 1.84 + do_check_neq(a2, null); 1.85 + do_check_false(a2.isActive); 1.86 + do_check_neq(a3, null); 1.87 + do_check_false(a3.isActive); 1.88 + do_check_neq(a4, null); 1.89 + do_check_true(a4.isActive); 1.90 + do_check_neq(a5, null); 1.91 + do_check_true(a5.isActive); 1.92 + 1.93 + do_execute_soon(do_test_finished); 1.94 + }); 1.95 +}