michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // This verifies that the extensions.checkCompatibility.* preferences work. michael@0: michael@0: var ADDONS = [{ michael@0: // Cannot be enabled as it has no target app info for the applciation michael@0: id: "addon1@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Test 1", michael@0: targetApplications: [{ michael@0: id: "unknown@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "1" michael@0: }] michael@0: }, { michael@0: // Always appears incompatible but can be enabled if compatibility checking is michael@0: // disabled michael@0: id: "addon2@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Test 2", michael@0: targetApplications: [{ michael@0: id: "toolkit@mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "1" michael@0: }] michael@0: }, { michael@0: // Always appears incompatible but can be enabled if compatibility checking is michael@0: // disabled michael@0: id: "addon3@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Test 3", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "1" michael@0: }] michael@0: }, { // Always compatible and enabled michael@0: id: "addon4@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Test 4", michael@0: targetApplications: [{ michael@0: id: "toolkit@mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "2" michael@0: }] michael@0: }, { // Always compatible and enabled michael@0: id: "addon5@tests.mozilla.org", michael@0: version: "1.0", michael@0: name: "Test 5", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "3" michael@0: }] michael@0: }]; michael@0: michael@0: const profileDir = gProfD.clone(); michael@0: profileDir.append("extensions"); michael@0: michael@0: var gIsNightly = false; michael@0: michael@0: function run_test() { michael@0: do_test_pending("checkcompatibility.js"); michael@0: createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2"); michael@0: michael@0: ADDONS.forEach(function(a) { michael@0: writeInstallRDFForExtension(a, profileDir); michael@0: }); michael@0: michael@0: gIsNightly = isNightlyChannel(); michael@0: michael@0: startupManager(); michael@0: michael@0: run_test_1(); michael@0: } michael@0: michael@0: /** michael@0: * Checks that the add-ons are enabled as expected. michael@0: * @param overridden michael@0: * A boolean indicating that compatibility checking is overridden michael@0: * @param a1 michael@0: * The Addon for addon1@tests.mozilla.org michael@0: * @param a2 michael@0: * The Addon for addon2@tests.mozilla.org michael@0: * @param a3 michael@0: * The Addon for addon3@tests.mozilla.org michael@0: * @param a4 michael@0: * The Addon for addon4@tests.mozilla.org michael@0: * @param a5 michael@0: * The Addon for addon5@tests.mozilla.org michael@0: */ michael@0: function check_state(overridden, a1, a2, a3, a4, a5) { michael@0: do_check_neq(a1, null); michael@0: do_check_false(a1.isActive); michael@0: do_check_false(a1.isCompatible); michael@0: michael@0: do_check_neq(a2, null); michael@0: if (overridden) michael@0: do_check_true(a2.isActive); michael@0: else michael@0: do_check_false(a2.isActive); michael@0: do_check_false(a2.isCompatible); michael@0: michael@0: do_check_neq(a3, null); michael@0: if (overridden) michael@0: do_check_true(a3.isActive); michael@0: else michael@0: do_check_false(a3.isActive); michael@0: do_check_false(a3.isCompatible); michael@0: michael@0: do_check_neq(a4, null); michael@0: do_check_true(a4.isActive); michael@0: do_check_true(a4.isCompatible); michael@0: michael@0: do_check_neq(a5, null); michael@0: do_check_true(a5.isActive); michael@0: do_check_true(a5.isCompatible); michael@0: } michael@0: michael@0: // Tests that with compatibility checking enabled we see the incompatible michael@0: // add-ons disabled michael@0: function run_test_1() { michael@0: AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", michael@0: "addon2@tests.mozilla.org", michael@0: "addon3@tests.mozilla.org", michael@0: "addon4@tests.mozilla.org", michael@0: "addon5@tests.mozilla.org"], michael@0: function([a1, a2, a3, a4, a5]) { michael@0: check_state(false, a1, a2, a3, a4, a5); michael@0: michael@0: do_execute_soon(run_test_2); michael@0: }); michael@0: } michael@0: michael@0: // Tests that with compatibility checking disabled we see the incompatible michael@0: // add-ons enabled michael@0: function run_test_2() { michael@0: if (gIsNightly) michael@0: Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); michael@0: else michael@0: Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", michael@0: "addon2@tests.mozilla.org", michael@0: "addon3@tests.mozilla.org", michael@0: "addon4@tests.mozilla.org", michael@0: "addon5@tests.mozilla.org"], michael@0: function([a1, a2, a3, a4, a5]) { michael@0: check_state(true, a1, a2, a3, a4, a5); michael@0: michael@0: do_execute_soon(run_test_3); michael@0: }); michael@0: } michael@0: michael@0: // Tests that with compatibility checking disabled we see the incompatible michael@0: // add-ons enabled. michael@0: function run_test_3() { michael@0: if (!gIsNightly) michael@0: Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false); michael@0: restartManager("2.1a4"); michael@0: michael@0: AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", michael@0: "addon2@tests.mozilla.org", michael@0: "addon3@tests.mozilla.org", michael@0: "addon4@tests.mozilla.org", michael@0: "addon5@tests.mozilla.org"], michael@0: function([a1, a2, a3, a4, a5]) { michael@0: check_state(true, a1, a2, a3, a4, a5); michael@0: michael@0: do_execute_soon(run_test_4); michael@0: }); michael@0: } michael@0: michael@0: // Tests that with compatibility checking enabled we see the incompatible michael@0: // add-ons disabled. michael@0: function run_test_4() { michael@0: if (gIsNightly) michael@0: Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", true); michael@0: else michael@0: Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true); michael@0: restartManager(); michael@0: michael@0: AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", michael@0: "addon2@tests.mozilla.org", michael@0: "addon3@tests.mozilla.org", michael@0: "addon4@tests.mozilla.org", michael@0: "addon5@tests.mozilla.org"], michael@0: function([a1, a2, a3, a4, a5]) { michael@0: check_state(false, a1, a2, a3, a4, a5); michael@0: michael@0: do_execute_soon(do_test_finished); michael@0: }); michael@0: }