Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
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 app upgrades produce the expected behaviours, |
michael@0 | 6 | // with strict compatibility checking enabled. |
michael@0 | 7 | |
michael@0 | 8 | // Enable loading extensions from the application scope |
michael@0 | 9 | Services.prefs.setIntPref("extensions.enabledScopes", |
michael@0 | 10 | AddonManager.SCOPE_PROFILE + |
michael@0 | 11 | AddonManager.SCOPE_APPLICATION); |
michael@0 | 12 | |
michael@0 | 13 | const profileDir = gProfD.clone(); |
michael@0 | 14 | profileDir.append("extensions"); |
michael@0 | 15 | |
michael@0 | 16 | const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsIFile); |
michael@0 | 17 | globalDir.append("extensions"); |
michael@0 | 18 | |
michael@0 | 19 | var gGlobalExisted = globalDir.exists(); |
michael@0 | 20 | var gInstallTime = Date.now(); |
michael@0 | 21 | |
michael@0 | 22 | function run_test() { |
michael@0 | 23 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); |
michael@0 | 24 | |
michael@0 | 25 | // Will be enabled in the first version and disabled in subsequent versions |
michael@0 | 26 | writeInstallRDFForExtension({ |
michael@0 | 27 | id: "addon1@tests.mozilla.org", |
michael@0 | 28 | version: "1.0", |
michael@0 | 29 | targetApplications: [{ |
michael@0 | 30 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 31 | minVersion: "1", |
michael@0 | 32 | maxVersion: "1" |
michael@0 | 33 | }], |
michael@0 | 34 | name: "Test Addon 1", |
michael@0 | 35 | targetPlatforms: [ |
michael@0 | 36 | "XPCShell", |
michael@0 | 37 | "WINNT_x86", |
michael@0 | 38 | ] |
michael@0 | 39 | }, profileDir); |
michael@0 | 40 | |
michael@0 | 41 | // Works in all tested versions |
michael@0 | 42 | writeInstallRDFForExtension({ |
michael@0 | 43 | id: "addon2@tests.mozilla.org", |
michael@0 | 44 | version: "1.0", |
michael@0 | 45 | targetApplications: [{ |
michael@0 | 46 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 47 | minVersion: "1", |
michael@0 | 48 | maxVersion: "2" |
michael@0 | 49 | }], |
michael@0 | 50 | name: "Test Addon 2", |
michael@0 | 51 | targetPlatforms: [ |
michael@0 | 52 | "XPCShell_noarch-spidermonkey" |
michael@0 | 53 | ] |
michael@0 | 54 | }, profileDir); |
michael@0 | 55 | |
michael@0 | 56 | // Will be disabled in the first version and enabled in the second. |
michael@0 | 57 | writeInstallRDFForExtension({ |
michael@0 | 58 | id: "addon3@tests.mozilla.org", |
michael@0 | 59 | version: "1.0", |
michael@0 | 60 | targetApplications: [{ |
michael@0 | 61 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 62 | minVersion: "2", |
michael@0 | 63 | maxVersion: "2" |
michael@0 | 64 | }], |
michael@0 | 65 | name: "Test Addon 3", |
michael@0 | 66 | }, profileDir); |
michael@0 | 67 | |
michael@0 | 68 | // Will be enabled in both versions but will change version in between |
michael@0 | 69 | var dest = writeInstallRDFForExtension({ |
michael@0 | 70 | id: "addon4@tests.mozilla.org", |
michael@0 | 71 | version: "1.0", |
michael@0 | 72 | targetApplications: [{ |
michael@0 | 73 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 74 | minVersion: "1", |
michael@0 | 75 | maxVersion: "1" |
michael@0 | 76 | }], |
michael@0 | 77 | name: "Test Addon 4", |
michael@0 | 78 | }, globalDir); |
michael@0 | 79 | setExtensionModifiedTime(dest, gInstallTime); |
michael@0 | 80 | |
michael@0 | 81 | do_test_pending(); |
michael@0 | 82 | |
michael@0 | 83 | Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true); |
michael@0 | 84 | |
michael@0 | 85 | run_test_1(); |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function end_test() { |
michael@0 | 89 | if (!gGlobalExisted) { |
michael@0 | 90 | globalDir.remove(true); |
michael@0 | 91 | } |
michael@0 | 92 | else { |
michael@0 | 93 | globalDir.append(do_get_expected_addon_name("addon4@tests.mozilla.org")); |
michael@0 | 94 | globalDir.remove(true); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | Services.prefs.clearUserPref(PREF_EM_STRICT_COMPATIBILITY); |
michael@0 | 98 | |
michael@0 | 99 | do_execute_soon(do_test_finished); |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | // Test that the test extensions are all installed |
michael@0 | 103 | function run_test_1() { |
michael@0 | 104 | startupManager(); |
michael@0 | 105 | |
michael@0 | 106 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 107 | "addon2@tests.mozilla.org", |
michael@0 | 108 | "addon3@tests.mozilla.org", |
michael@0 | 109 | "addon4@tests.mozilla.org"], |
michael@0 | 110 | function([a1, a2, a3, a4]) { |
michael@0 | 111 | |
michael@0 | 112 | do_check_neq(a1, null); |
michael@0 | 113 | do_check_true(isExtensionInAddonsList(profileDir, a1.id)); |
michael@0 | 114 | |
michael@0 | 115 | do_check_neq(a2, null); |
michael@0 | 116 | do_check_true(isExtensionInAddonsList(profileDir, a2.id)); |
michael@0 | 117 | |
michael@0 | 118 | do_check_neq(a3, null); |
michael@0 | 119 | do_check_false(isExtensionInAddonsList(profileDir, a3.id)); |
michael@0 | 120 | |
michael@0 | 121 | do_check_neq(a4, null); |
michael@0 | 122 | do_check_true(isExtensionInAddonsList(globalDir, a4.id)); |
michael@0 | 123 | do_check_eq(a4.version, "1.0"); |
michael@0 | 124 | |
michael@0 | 125 | do_execute_soon(run_test_2); |
michael@0 | 126 | }); |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | // Test that upgrading the application disables now incompatible add-ons |
michael@0 | 130 | function run_test_2() { |
michael@0 | 131 | // Upgrade the extension |
michael@0 | 132 | var dest = writeInstallRDFForExtension({ |
michael@0 | 133 | id: "addon4@tests.mozilla.org", |
michael@0 | 134 | version: "2.0", |
michael@0 | 135 | targetApplications: [{ |
michael@0 | 136 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 137 | minVersion: "2", |
michael@0 | 138 | maxVersion: "2" |
michael@0 | 139 | }], |
michael@0 | 140 | name: "Test Addon 4", |
michael@0 | 141 | }, globalDir); |
michael@0 | 142 | setExtensionModifiedTime(dest, gInstallTime); |
michael@0 | 143 | |
michael@0 | 144 | restartManager("2"); |
michael@0 | 145 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 146 | "addon2@tests.mozilla.org", |
michael@0 | 147 | "addon3@tests.mozilla.org", |
michael@0 | 148 | "addon4@tests.mozilla.org"], |
michael@0 | 149 | function([a1, a2, a3, a4]) { |
michael@0 | 150 | |
michael@0 | 151 | do_check_neq(a1, null); |
michael@0 | 152 | do_check_false(isExtensionInAddonsList(profileDir, a1.id)); |
michael@0 | 153 | |
michael@0 | 154 | do_check_neq(a2, null); |
michael@0 | 155 | do_check_true(isExtensionInAddonsList(profileDir, a2.id)); |
michael@0 | 156 | |
michael@0 | 157 | do_check_neq(a3, null); |
michael@0 | 158 | do_check_true(isExtensionInAddonsList(profileDir, a3.id)); |
michael@0 | 159 | |
michael@0 | 160 | do_check_neq(a4, null); |
michael@0 | 161 | do_check_true(isExtensionInAddonsList(globalDir, a4.id)); |
michael@0 | 162 | do_check_eq(a4.version, "2.0"); |
michael@0 | 163 | |
michael@0 | 164 | do_execute_soon(run_test_3); |
michael@0 | 165 | }); |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | // Test that nothing changes when only the build ID changes. |
michael@0 | 169 | function run_test_3() { |
michael@0 | 170 | // Upgrade the extension |
michael@0 | 171 | var dest = writeInstallRDFForExtension({ |
michael@0 | 172 | id: "addon4@tests.mozilla.org", |
michael@0 | 173 | version: "3.0", |
michael@0 | 174 | targetApplications: [{ |
michael@0 | 175 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 176 | minVersion: "3", |
michael@0 | 177 | maxVersion: "3" |
michael@0 | 178 | }], |
michael@0 | 179 | name: "Test Addon 4", |
michael@0 | 180 | }, globalDir); |
michael@0 | 181 | setExtensionModifiedTime(dest, gInstallTime); |
michael@0 | 182 | |
michael@0 | 183 | // Simulates a simple Build ID change, the platform deletes extensions.ini |
michael@0 | 184 | // whenever the application is changed. |
michael@0 | 185 | gExtensionsINI.remove(true); |
michael@0 | 186 | restartManager(); |
michael@0 | 187 | |
michael@0 | 188 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 189 | "addon2@tests.mozilla.org", |
michael@0 | 190 | "addon3@tests.mozilla.org", |
michael@0 | 191 | "addon4@tests.mozilla.org"], |
michael@0 | 192 | function([a1, a2, a3, a4]) { |
michael@0 | 193 | |
michael@0 | 194 | do_check_neq(a1, null); |
michael@0 | 195 | do_check_false(isExtensionInAddonsList(profileDir, a1.id)); |
michael@0 | 196 | |
michael@0 | 197 | do_check_neq(a2, null); |
michael@0 | 198 | do_check_true(isExtensionInAddonsList(profileDir, a2.id)); |
michael@0 | 199 | |
michael@0 | 200 | do_check_neq(a3, null); |
michael@0 | 201 | do_check_true(isExtensionInAddonsList(profileDir, a3.id)); |
michael@0 | 202 | |
michael@0 | 203 | do_check_neq(a4, null); |
michael@0 | 204 | do_check_true(isExtensionInAddonsList(globalDir, a4.id)); |
michael@0 | 205 | do_check_eq(a4.version, "2.0"); |
michael@0 | 206 | |
michael@0 | 207 | end_test(); |
michael@0 | 208 | }); |
michael@0 | 209 | } |