Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // This verifies that the extensions.checkCompatibility.* preferences work. |
michael@0 | 6 | |
michael@0 | 7 | var ADDONS = [{ |
michael@0 | 8 | // Cannot be enabled as it has no target app info for the applciation |
michael@0 | 9 | id: "addon1@tests.mozilla.org", |
michael@0 | 10 | version: "1.0", |
michael@0 | 11 | name: "Test 1", |
michael@0 | 12 | targetApplications: [{ |
michael@0 | 13 | id: "unknown@tests.mozilla.org", |
michael@0 | 14 | minVersion: "1", |
michael@0 | 15 | maxVersion: "1" |
michael@0 | 16 | }] |
michael@0 | 17 | }, { |
michael@0 | 18 | // Always appears incompatible but can be enabled if compatibility checking is |
michael@0 | 19 | // disabled |
michael@0 | 20 | id: "addon2@tests.mozilla.org", |
michael@0 | 21 | version: "1.0", |
michael@0 | 22 | name: "Test 2", |
michael@0 | 23 | targetApplications: [{ |
michael@0 | 24 | id: "toolkit@mozilla.org", |
michael@0 | 25 | minVersion: "1", |
michael@0 | 26 | maxVersion: "1" |
michael@0 | 27 | }] |
michael@0 | 28 | }, { |
michael@0 | 29 | // Always appears incompatible but can be enabled if compatibility checking is |
michael@0 | 30 | // disabled |
michael@0 | 31 | id: "addon3@tests.mozilla.org", |
michael@0 | 32 | version: "1.0", |
michael@0 | 33 | name: "Test 3", |
michael@0 | 34 | targetApplications: [{ |
michael@0 | 35 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 36 | minVersion: "1", |
michael@0 | 37 | maxVersion: "1" |
michael@0 | 38 | }] |
michael@0 | 39 | }, { // Always compatible and enabled |
michael@0 | 40 | id: "addon4@tests.mozilla.org", |
michael@0 | 41 | version: "1.0", |
michael@0 | 42 | name: "Test 4", |
michael@0 | 43 | targetApplications: [{ |
michael@0 | 44 | id: "toolkit@mozilla.org", |
michael@0 | 45 | minVersion: "1", |
michael@0 | 46 | maxVersion: "2" |
michael@0 | 47 | }] |
michael@0 | 48 | }, { // Always compatible and enabled |
michael@0 | 49 | id: "addon5@tests.mozilla.org", |
michael@0 | 50 | version: "1.0", |
michael@0 | 51 | name: "Test 5", |
michael@0 | 52 | targetApplications: [{ |
michael@0 | 53 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 54 | minVersion: "1", |
michael@0 | 55 | maxVersion: "3" |
michael@0 | 56 | }] |
michael@0 | 57 | }]; |
michael@0 | 58 | |
michael@0 | 59 | const profileDir = gProfD.clone(); |
michael@0 | 60 | profileDir.append("extensions"); |
michael@0 | 61 | |
michael@0 | 62 | var gIsNightly = false; |
michael@0 | 63 | |
michael@0 | 64 | function run_test() { |
michael@0 | 65 | do_test_pending("checkcompatibility.js"); |
michael@0 | 66 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2.2.3", "2"); |
michael@0 | 67 | |
michael@0 | 68 | ADDONS.forEach(function(a) { |
michael@0 | 69 | writeInstallRDFForExtension(a, profileDir); |
michael@0 | 70 | }); |
michael@0 | 71 | |
michael@0 | 72 | gIsNightly = isNightlyChannel(); |
michael@0 | 73 | |
michael@0 | 74 | startupManager(); |
michael@0 | 75 | |
michael@0 | 76 | run_test_1(); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | /** |
michael@0 | 80 | * Checks that the add-ons are enabled as expected. |
michael@0 | 81 | * @param overridden |
michael@0 | 82 | * A boolean indicating that compatibility checking is overridden |
michael@0 | 83 | * @param a1 |
michael@0 | 84 | * The Addon for addon1@tests.mozilla.org |
michael@0 | 85 | * @param a2 |
michael@0 | 86 | * The Addon for addon2@tests.mozilla.org |
michael@0 | 87 | * @param a3 |
michael@0 | 88 | * The Addon for addon3@tests.mozilla.org |
michael@0 | 89 | * @param a4 |
michael@0 | 90 | * The Addon for addon4@tests.mozilla.org |
michael@0 | 91 | * @param a5 |
michael@0 | 92 | * The Addon for addon5@tests.mozilla.org |
michael@0 | 93 | */ |
michael@0 | 94 | function check_state(overridden, a1, a2, a3, a4, a5) { |
michael@0 | 95 | do_check_neq(a1, null); |
michael@0 | 96 | do_check_false(a1.isActive); |
michael@0 | 97 | do_check_false(a1.isCompatible); |
michael@0 | 98 | |
michael@0 | 99 | do_check_neq(a2, null); |
michael@0 | 100 | if (overridden) |
michael@0 | 101 | do_check_true(a2.isActive); |
michael@0 | 102 | else |
michael@0 | 103 | do_check_false(a2.isActive); |
michael@0 | 104 | do_check_false(a2.isCompatible); |
michael@0 | 105 | |
michael@0 | 106 | do_check_neq(a3, null); |
michael@0 | 107 | if (overridden) |
michael@0 | 108 | do_check_true(a3.isActive); |
michael@0 | 109 | else |
michael@0 | 110 | do_check_false(a3.isActive); |
michael@0 | 111 | do_check_false(a3.isCompatible); |
michael@0 | 112 | |
michael@0 | 113 | do_check_neq(a4, null); |
michael@0 | 114 | do_check_true(a4.isActive); |
michael@0 | 115 | do_check_true(a4.isCompatible); |
michael@0 | 116 | |
michael@0 | 117 | do_check_neq(a5, null); |
michael@0 | 118 | do_check_true(a5.isActive); |
michael@0 | 119 | do_check_true(a5.isCompatible); |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | // Tests that with compatibility checking enabled we see the incompatible |
michael@0 | 123 | // add-ons disabled |
michael@0 | 124 | function run_test_1() { |
michael@0 | 125 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 126 | "addon2@tests.mozilla.org", |
michael@0 | 127 | "addon3@tests.mozilla.org", |
michael@0 | 128 | "addon4@tests.mozilla.org", |
michael@0 | 129 | "addon5@tests.mozilla.org"], |
michael@0 | 130 | function([a1, a2, a3, a4, a5]) { |
michael@0 | 131 | check_state(false, a1, a2, a3, a4, a5); |
michael@0 | 132 | |
michael@0 | 133 | do_execute_soon(run_test_2); |
michael@0 | 134 | }); |
michael@0 | 135 | } |
michael@0 | 136 | |
michael@0 | 137 | // Tests that with compatibility checking disabled we see the incompatible |
michael@0 | 138 | // add-ons enabled |
michael@0 | 139 | function run_test_2() { |
michael@0 | 140 | if (gIsNightly) |
michael@0 | 141 | Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false); |
michael@0 | 142 | else |
michael@0 | 143 | Services.prefs.setBoolPref("extensions.checkCompatibility.2.2", false); |
michael@0 | 144 | restartManager(); |
michael@0 | 145 | |
michael@0 | 146 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 147 | "addon2@tests.mozilla.org", |
michael@0 | 148 | "addon3@tests.mozilla.org", |
michael@0 | 149 | "addon4@tests.mozilla.org", |
michael@0 | 150 | "addon5@tests.mozilla.org"], |
michael@0 | 151 | function([a1, a2, a3, a4, a5]) { |
michael@0 | 152 | check_state(true, a1, a2, a3, a4, a5); |
michael@0 | 153 | |
michael@0 | 154 | do_execute_soon(run_test_3); |
michael@0 | 155 | }); |
michael@0 | 156 | } |
michael@0 | 157 | |
michael@0 | 158 | // Tests that with compatibility checking disabled we see the incompatible |
michael@0 | 159 | // add-ons enabled. |
michael@0 | 160 | function run_test_3() { |
michael@0 | 161 | if (!gIsNightly) |
michael@0 | 162 | Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", false); |
michael@0 | 163 | restartManager("2.1a4"); |
michael@0 | 164 | |
michael@0 | 165 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 166 | "addon2@tests.mozilla.org", |
michael@0 | 167 | "addon3@tests.mozilla.org", |
michael@0 | 168 | "addon4@tests.mozilla.org", |
michael@0 | 169 | "addon5@tests.mozilla.org"], |
michael@0 | 170 | function([a1, a2, a3, a4, a5]) { |
michael@0 | 171 | check_state(true, a1, a2, a3, a4, a5); |
michael@0 | 172 | |
michael@0 | 173 | do_execute_soon(run_test_4); |
michael@0 | 174 | }); |
michael@0 | 175 | } |
michael@0 | 176 | |
michael@0 | 177 | // Tests that with compatibility checking enabled we see the incompatible |
michael@0 | 178 | // add-ons disabled. |
michael@0 | 179 | function run_test_4() { |
michael@0 | 180 | if (gIsNightly) |
michael@0 | 181 | Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", true); |
michael@0 | 182 | else |
michael@0 | 183 | Services.prefs.setBoolPref("extensions.checkCompatibility.2.1a", true); |
michael@0 | 184 | restartManager(); |
michael@0 | 185 | |
michael@0 | 186 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 187 | "addon2@tests.mozilla.org", |
michael@0 | 188 | "addon3@tests.mozilla.org", |
michael@0 | 189 | "addon4@tests.mozilla.org", |
michael@0 | 190 | "addon5@tests.mozilla.org"], |
michael@0 | 191 | function([a1, a2, a3, a4, a5]) { |
michael@0 | 192 | check_state(false, a1, a2, a3, a4, a5); |
michael@0 | 193 | |
michael@0 | 194 | do_execute_soon(do_test_finished); |
michael@0 | 195 | }); |
michael@0 | 196 | } |