Bug 1447903: Part 11c - Fold test_checkcompatibility.js into test_strictcompatibility and update to use bootstrapped extensions. r?aswan
MozReview-Commit-ID: GxL9e9ZW6LX
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -75,17 +75,16 @@ const LEGACY_NON_RESTARTLESS_TESTS = new
"test_bug397778.js",
"test_bug425657.js",
"test_bug455906.js",
"test_bug470377_1.js",
"test_bug470377_2.js",
"test_bug470377_3.js",
"test_bug470377_4.js",
"test_bug655254.js",
- "test_checkcompatibility.js",
"test_signed_verify.js",
"test_syncGUID.js",
"test_upgrade.js",
]);
if (LEGACY_NON_RESTARTLESS_TESTS.has(_TEST_FILE[0].replace(/.*\//, ""))) {
Services.prefs.setBoolPref("extensions.legacy.non-restartless.enabled", true);
}
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_checkcompatibility.js
+++ /dev/null
@@ -1,196 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that the extensions.checkCompatibility.* preferences work.
-
-var ADDONS = [{
- // Cannot be enabled as it has no target app info for the applciation
- id: "addon1@tests.mozilla.org",
- version: "1.0",
- name: "Test 1",
- targetApplications: [{
- id: "unknown@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-}, {
- // Always appears incompatible but can be enabled if compatibility checking is
- // disabled
- id: "addon2@tests.mozilla.org",
- version: "1.0",
- name: "Test 2",
- targetApplications: [{
- id: "toolkit@mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-}, {
- // Always appears incompatible but can be enabled if compatibility checking is
- // disabled
- id: "addon3@tests.mozilla.org",
- version: "1.0",
- name: "Test 3",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-}, { // Always compatible and enabled
- id: "addon4@tests.mozilla.org",
- version: "1.0",
- name: "Test 4",
- targetApplications: [{
- id: "toolkit@mozilla.org",
- minVersion: "1",
- maxVersion: "2"
- }]
-}, { // Always compatible and enabled
- id: "addon5@tests.mozilla.org",
- version: "1.0",
- name: "Test 5",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "3"
- }]
-}];
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-var gIsNightly = false;
-
-function run_test() {
- do_test_pending("checkcompatibility.js");
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2");
-
- ADDONS.forEach(function(a) {
- writeInstallRDFForExtension(a, profileDir);
- });
-
- gIsNightly = isNightlyChannel();
-
- startupManager();
-
- run_test_1();
-}
-
-/**
- * Checks that the add-ons are enabled as expected.
- * @param overridden
- * A boolean indicating that compatibility checking is overridden
- * @param a1
- * The Addon for addon1@tests.mozilla.org
- * @param a2
- * The Addon for addon2@tests.mozilla.org
- * @param a3
- * The Addon for addon3@tests.mozilla.org
- * @param a4
- * The Addon for addon4@tests.mozilla.org
- * @param a5
- * The Addon for addon5@tests.mozilla.org
- */
-function check_state(overridden, a1, a2, a3, a4, a5) {
- Assert.notEqual(a1, null);
- Assert.ok(!a1.isActive);
- Assert.ok(!a1.isCompatible);
-
- Assert.notEqual(a2, null);
- if (overridden)
- Assert.ok(a2.isActive);
- else
- Assert.ok(!a2.isActive);
- Assert.ok(!a2.isCompatible);
-
- Assert.notEqual(a3, null);
- if (overridden)
- Assert.ok(a3.isActive);
- else
- Assert.ok(!a3.isActive);
- Assert.ok(!a3.isCompatible);
-
- Assert.notEqual(a4, null);
- Assert.ok(a4.isActive);
- Assert.ok(a4.isCompatible);
-
- Assert.notEqual(a5, null);
- Assert.ok(a5.isActive);
- Assert.ok(a5.isCompatible);
-}
-
-// Tests that with compatibility checking enabled we see the incompatible
-// add-ons disabled
-function run_test_1() {
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org",
- "addon3@tests.mozilla.org",
- "addon4@tests.mozilla.org",
- "addon5@tests.mozilla.org"],
- function([a1, a2, a3, a4, a5]) {
- check_state(false, a1, a2, a3, a4, a5);
-
- executeSoon(run_test_2);
- });
-}
-
-// Tests that with compatibility checking disabled we see the incompatible
-// add-ons enabled
-function run_test_2() {
- if (gIsNightly)
- Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
- else
- Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false);
- restartManager();
-
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org",
- "addon3@tests.mozilla.org",
- "addon4@tests.mozilla.org",
- "addon5@tests.mozilla.org"],
- function([a1, a2, a3, a4, a5]) {
- check_state(true, a1, a2, a3, a4, a5);
-
- executeSoon(run_test_3);
- });
-}
-
-// Tests that with compatibility checking disabled we see the incompatible
-// add-ons enabled.
-function run_test_3() {
- if (!gIsNightly)
- Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false);
- restartManager("2.1a4");
-
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org",
- "addon3@tests.mozilla.org",
- "addon4@tests.mozilla.org",
- "addon5@tests.mozilla.org"],
- function([a1, a2, a3, a4, a5]) {
- check_state(true, a1, a2, a3, a4, a5);
-
- executeSoon(run_test_4);
- });
-}
-
-// Tests that with compatibility checking enabled we see the incompatible
-// add-ons disabled.
-function run_test_4() {
- if (gIsNightly)
- Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", true);
- else
- Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true);
- restartManager();
-
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org",
- "addon3@tests.mozilla.org",
- "addon4@tests.mozilla.org",
- "addon5@tests.mozilla.org"],
- function([a1, a2, a3, a4, a5]) {
- check_state(false, a1, a2, a3, a4, a5);
-
- executeSoon(do_test_finished);
- });
-}
--- a/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
@@ -200,8 +200,165 @@ add_task(async function test_2() {
});
add_task(async function test_3() {
info("Test 3");
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0.4");
await checkCompatStatus(false, 3);
});
+
+const CHECK_COMPAT_ADDONS = {
+ "cc-addon1@tests.mozilla.org": {
+ "install.rdf": {
+ // Cannot be enabled as it has no target app info for the applciation
+ id: "cc-addon1@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 1",
+ bootstrap: true,
+ targetApplications: [{
+ id: "unknown@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+ },
+ compatible: false,
+ canOverride: false,
+ },
+
+ "cc-addon2@tests.mozilla.org": {
+ "install.rdf": {
+ // Always appears incompatible but can be enabled if compatibility checking is
+ // disabled
+ id: "cc-addon2@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 2",
+ bootstrap: true,
+ targetApplications: [{
+ id: "toolkit@mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+ },
+ compatible: false,
+ canOverride: true,
+ },
+
+ "cc-addon3@tests.mozilla.org": {
+ "install.rdf": {
+ // Always appears incompatible but can be enabled if compatibility checking is
+ // disabled
+ id: "cc-addon3@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 3",
+ bootstrap: true,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+ },
+ compatible: false,
+ canOverride: true,
+ },
+
+ "cc-addon4@tests.mozilla.org": {
+ "install.rdf": {
+ // Always compatible and enabled
+ id: "cc-addon4@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 4",
+ bootstrap: true,
+ targetApplications: [{
+ id: "toolkit@mozilla.org",
+ minVersion: "1",
+ maxVersion: "2"
+ }]
+ },
+ compatible: true,
+ },
+
+ "cc-addon5@tests.mozilla.org": {
+ "install.rdf": {
+ // Always compatible and enabled
+ id: "cc-addon5@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 5",
+ bootstrap: true,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "3"
+ }]
+ },
+ compatible: true,
+ },
+};
+
+const CHECK_COMPAT_IDS = Object.keys(CHECK_COMPAT_ADDONS);
+
+async function checkCompatOverrides(overridden) {
+ let addons = await getAddons(CHECK_COMPAT_IDS);
+
+ for (let [id, addon] of Object.entries(CHECK_COMPAT_ADDONS)) {
+ checkAddon(id, addons.get(id), {
+ isCompatible: addon.compatible,
+ isActive: addon.compatible || (overridden && addon.canOverride),
+ });
+ }
+}
+
+var gIsNightly;
+
+add_task(async function setupCheckCompat() {
+ gIsNightly = isNightlyChannel();
+
+ Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
+
+ Object.assign(AddonTestUtils.appInfo,
+ {version: "2.2.3", platformVersion: "2"});
+
+ for (let addon of Object.values(CHECK_COMPAT_ADDONS)) {
+ writeInstallRDFForExtension(addon["install.rdf"], profileDir);
+ }
+ await promiseRestartManager("2.2.3");
+});
+
+// Tests that with compatibility checking enabled we see the incompatible
+// add-ons disabled
+add_task(async function test_compat_overrides_1() {
+ await checkCompatOverrides(false);
+});
+
+// Tests that with compatibility checking disabled we see the incompatible
+// add-ons enabled
+add_task(async function test_compat_overrides_2() {
+ if (gIsNightly)
+ Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
+ else
+ Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false);
+
+ await promiseRestartManager();
+
+ await checkCompatOverrides(true);
+});
+
+// Tests that with compatibility checking disabled we see the incompatible
+// add-ons enabled.
+add_task(async function test_compat_overrides_3() {
+ if (!gIsNightly)
+ Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false);
+ await promiseRestartManager("2.1a4");
+
+ await checkCompatOverrides(true);
+});
+
+// Tests that with compatibility checking enabled we see the incompatible
+// add-ons disabled.
+add_task(async function test_compat_overrides_4() {
+ if (gIsNightly)
+ Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", true);
+ else
+ Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true);
+ await promiseRestartManager();
+
+ await checkCompatOverrides(false);
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -177,17 +177,16 @@ tags = blocklist
[test_bug620837.js]
tags = blocklist
[test_bug655254.js]
[test_bug675371.js]
[test_bug740612.js]
[test_bug753900.js]
[test_bug757663.js]
[test_bug953156.js]
-[test_checkcompatibility.js]
[test_childprocess.js]
[test_compatoverrides.js]
[test_corrupt.js]
[test_corruptfile.js]
[test_db_path.js]
head =
[test_default_providers_pref.js]
[test_dictionary.js]