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 | // Checks that we rebuild something sensible from a database with a bad schema |
michael@0 | 6 | |
michael@0 | 7 | |
michael@0 | 8 | Components.utils.import("resource://testing-common/httpd.js"); |
michael@0 | 9 | var testserver = new HttpServer(); |
michael@0 | 10 | testserver.start(-1); |
michael@0 | 11 | gPort = testserver.identity.primaryPort; |
michael@0 | 12 | |
michael@0 | 13 | // register static files with server and interpolate port numbers in them |
michael@0 | 14 | mapFile("/data/test_corrupt.rdf", testserver); |
michael@0 | 15 | |
michael@0 | 16 | // The test extension uses an insecure update url. |
michael@0 | 17 | Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); |
michael@0 | 18 | |
michael@0 | 19 | // Will be enabled |
michael@0 | 20 | var addon1 = { |
michael@0 | 21 | id: "addon1@tests.mozilla.org", |
michael@0 | 22 | version: "1.0", |
michael@0 | 23 | name: "Test 1", |
michael@0 | 24 | targetApplications: [{ |
michael@0 | 25 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 26 | minVersion: "2", |
michael@0 | 27 | maxVersion: "2" |
michael@0 | 28 | }] |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | // Will be disabled |
michael@0 | 32 | var addon2 = { |
michael@0 | 33 | id: "addon2@tests.mozilla.org", |
michael@0 | 34 | version: "1.0", |
michael@0 | 35 | name: "Test 2", |
michael@0 | 36 | targetApplications: [{ |
michael@0 | 37 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 38 | minVersion: "2", |
michael@0 | 39 | maxVersion: "2" |
michael@0 | 40 | }] |
michael@0 | 41 | }; |
michael@0 | 42 | |
michael@0 | 43 | // Will get a compatibility update and be enabled |
michael@0 | 44 | var addon3 = { |
michael@0 | 45 | id: "addon3@tests.mozilla.org", |
michael@0 | 46 | version: "1.0", |
michael@0 | 47 | name: "Test 3", |
michael@0 | 48 | updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", |
michael@0 | 49 | targetApplications: [{ |
michael@0 | 50 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 51 | minVersion: "1", |
michael@0 | 52 | maxVersion: "1" |
michael@0 | 53 | }] |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | // Will get a compatibility update and be disabled |
michael@0 | 57 | var addon4 = { |
michael@0 | 58 | id: "addon4@tests.mozilla.org", |
michael@0 | 59 | version: "1.0", |
michael@0 | 60 | name: "Test 4", |
michael@0 | 61 | updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", |
michael@0 | 62 | targetApplications: [{ |
michael@0 | 63 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 64 | minVersion: "1", |
michael@0 | 65 | maxVersion: "1" |
michael@0 | 66 | }] |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | // Stays incompatible |
michael@0 | 70 | var addon5 = { |
michael@0 | 71 | id: "addon5@tests.mozilla.org", |
michael@0 | 72 | version: "1.0", |
michael@0 | 73 | name: "Test 5", |
michael@0 | 74 | targetApplications: [{ |
michael@0 | 75 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 76 | minVersion: "1", |
michael@0 | 77 | maxVersion: "1" |
michael@0 | 78 | }] |
michael@0 | 79 | }; |
michael@0 | 80 | |
michael@0 | 81 | // Enabled bootstrapped |
michael@0 | 82 | var addon6 = { |
michael@0 | 83 | id: "addon6@tests.mozilla.org", |
michael@0 | 84 | version: "1.0", |
michael@0 | 85 | name: "Test 6", |
michael@0 | 86 | bootstrap: "true", |
michael@0 | 87 | targetApplications: [{ |
michael@0 | 88 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 89 | minVersion: "2", |
michael@0 | 90 | maxVersion: "2" |
michael@0 | 91 | }] |
michael@0 | 92 | }; |
michael@0 | 93 | |
michael@0 | 94 | // Disabled bootstrapped |
michael@0 | 95 | var addon7 = { |
michael@0 | 96 | id: "addon7@tests.mozilla.org", |
michael@0 | 97 | version: "1.0", |
michael@0 | 98 | name: "Test 7", |
michael@0 | 99 | bootstrap: "true", |
michael@0 | 100 | targetApplications: [{ |
michael@0 | 101 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 102 | minVersion: "2", |
michael@0 | 103 | maxVersion: "2" |
michael@0 | 104 | }] |
michael@0 | 105 | }; |
michael@0 | 106 | |
michael@0 | 107 | // The default theme |
michael@0 | 108 | var theme1 = { |
michael@0 | 109 | id: "theme1@tests.mozilla.org", |
michael@0 | 110 | version: "1.0", |
michael@0 | 111 | name: "Theme 1", |
michael@0 | 112 | internalName: "classic/1.0", |
michael@0 | 113 | targetApplications: [{ |
michael@0 | 114 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 115 | minVersion: "2", |
michael@0 | 116 | maxVersion: "2" |
michael@0 | 117 | }] |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | // The selected theme |
michael@0 | 121 | var theme2 = { |
michael@0 | 122 | id: "theme2@tests.mozilla.org", |
michael@0 | 123 | version: "1.0", |
michael@0 | 124 | name: "Theme 2", |
michael@0 | 125 | internalName: "test/1.0", |
michael@0 | 126 | targetApplications: [{ |
michael@0 | 127 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 128 | minVersion: "2", |
michael@0 | 129 | maxVersion: "2" |
michael@0 | 130 | }] |
michael@0 | 131 | }; |
michael@0 | 132 | |
michael@0 | 133 | const profileDir = gProfD.clone(); |
michael@0 | 134 | profileDir.append("extensions"); |
michael@0 | 135 | |
michael@0 | 136 | function run_test() { |
michael@0 | 137 | do_test_pending(); |
michael@0 | 138 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2"); |
michael@0 | 139 | |
michael@0 | 140 | writeInstallRDFForExtension(addon1, profileDir); |
michael@0 | 141 | writeInstallRDFForExtension(addon2, profileDir); |
michael@0 | 142 | writeInstallRDFForExtension(addon3, profileDir); |
michael@0 | 143 | writeInstallRDFForExtension(addon4, profileDir); |
michael@0 | 144 | writeInstallRDFForExtension(addon5, profileDir); |
michael@0 | 145 | writeInstallRDFForExtension(addon6, profileDir); |
michael@0 | 146 | writeInstallRDFForExtension(addon7, profileDir); |
michael@0 | 147 | writeInstallRDFForExtension(theme1, profileDir); |
michael@0 | 148 | writeInstallRDFForExtension(theme2, profileDir); |
michael@0 | 149 | |
michael@0 | 150 | // Create and configure the HTTP server. |
michael@0 | 151 | testserver.registerDirectory("/addons/", do_get_file("addons")); |
michael@0 | 152 | |
michael@0 | 153 | // Startup the profile and setup the initial state |
michael@0 | 154 | startupManager(); |
michael@0 | 155 | |
michael@0 | 156 | AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org", |
michael@0 | 157 | "addon3@tests.mozilla.org", |
michael@0 | 158 | "addon4@tests.mozilla.org", |
michael@0 | 159 | "addon7@tests.mozilla.org", |
michael@0 | 160 | "theme2@tests.mozilla.org"], function([a2, a3, a4, |
michael@0 | 161 | a7, t2]) { |
michael@0 | 162 | // Set up the initial state |
michael@0 | 163 | a2.userDisabled = true; |
michael@0 | 164 | a4.userDisabled = true; |
michael@0 | 165 | a7.userDisabled = true; |
michael@0 | 166 | t2.userDisabled = false; |
michael@0 | 167 | a3.findUpdates({ |
michael@0 | 168 | onUpdateFinished: function() { |
michael@0 | 169 | a4.findUpdates({ |
michael@0 | 170 | onUpdateFinished: function() { |
michael@0 | 171 | do_execute_soon(run_test_1); |
michael@0 | 172 | } |
michael@0 | 173 | }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); |
michael@0 | 174 | } |
michael@0 | 175 | }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); |
michael@0 | 176 | }); |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | function end_test() { |
michael@0 | 180 | testserver.stop(do_test_finished); |
michael@0 | 181 | } |
michael@0 | 182 | |
michael@0 | 183 | function run_test_1() { |
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 | "addon6@tests.mozilla.org", |
michael@0 | 192 | "addon7@tests.mozilla.org", |
michael@0 | 193 | "theme1@tests.mozilla.org", |
michael@0 | 194 | "theme2@tests.mozilla.org"], function([a1, a2, a3, |
michael@0 | 195 | a4, a5, a6, |
michael@0 | 196 | a7, t1, t2]) { |
michael@0 | 197 | do_check_neq(a1, null); |
michael@0 | 198 | do_check_true(a1.isActive); |
michael@0 | 199 | do_check_false(a1.userDisabled); |
michael@0 | 200 | do_check_false(a1.appDisabled); |
michael@0 | 201 | do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 202 | |
michael@0 | 203 | do_check_neq(a2, null); |
michael@0 | 204 | do_check_false(a2.isActive); |
michael@0 | 205 | do_check_true(a2.userDisabled); |
michael@0 | 206 | do_check_false(a2.appDisabled); |
michael@0 | 207 | do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 208 | |
michael@0 | 209 | do_check_neq(a3, null); |
michael@0 | 210 | do_check_true(a3.isActive); |
michael@0 | 211 | do_check_false(a3.userDisabled); |
michael@0 | 212 | do_check_false(a3.appDisabled); |
michael@0 | 213 | do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 214 | |
michael@0 | 215 | do_check_neq(a4, null); |
michael@0 | 216 | do_check_false(a4.isActive); |
michael@0 | 217 | do_check_true(a4.userDisabled); |
michael@0 | 218 | do_check_false(a4.appDisabled); |
michael@0 | 219 | do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 220 | |
michael@0 | 221 | do_check_neq(a5, null); |
michael@0 | 222 | do_check_false(a5.isActive); |
michael@0 | 223 | do_check_false(a5.userDisabled); |
michael@0 | 224 | do_check_true(a5.appDisabled); |
michael@0 | 225 | do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 226 | |
michael@0 | 227 | do_check_neq(a6, null); |
michael@0 | 228 | do_check_true(a6.isActive); |
michael@0 | 229 | do_check_false(a6.userDisabled); |
michael@0 | 230 | do_check_false(a6.appDisabled); |
michael@0 | 231 | do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 232 | |
michael@0 | 233 | do_check_neq(a7, null); |
michael@0 | 234 | do_check_false(a7.isActive); |
michael@0 | 235 | do_check_true(a7.userDisabled); |
michael@0 | 236 | do_check_false(a7.appDisabled); |
michael@0 | 237 | do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 238 | |
michael@0 | 239 | do_check_neq(t1, null); |
michael@0 | 240 | do_check_false(t1.isActive); |
michael@0 | 241 | do_check_true(t1.userDisabled); |
michael@0 | 242 | do_check_false(t1.appDisabled); |
michael@0 | 243 | do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 244 | |
michael@0 | 245 | do_check_neq(t2, null); |
michael@0 | 246 | do_check_true(t2.isActive); |
michael@0 | 247 | do_check_false(t2.userDisabled); |
michael@0 | 248 | do_check_false(t2.appDisabled); |
michael@0 | 249 | do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 250 | |
michael@0 | 251 | do_execute_soon(run_test_1_modified_db); |
michael@0 | 252 | }); |
michael@0 | 253 | } |
michael@0 | 254 | |
michael@0 | 255 | |
michael@0 | 256 | function run_test_1_modified_db() { |
michael@0 | 257 | // After restarting the database won't be open so we can alter |
michael@0 | 258 | // the schema |
michael@0 | 259 | shutdownManager(); |
michael@0 | 260 | changeXPIDBVersion(100); |
michael@0 | 261 | startupManager(); |
michael@0 | 262 | |
michael@0 | 263 | // Accessing the add-ons should open and recover the database. Since |
michael@0 | 264 | // migration occurs everything should be recovered correctly |
michael@0 | 265 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 266 | "addon2@tests.mozilla.org", |
michael@0 | 267 | "addon3@tests.mozilla.org", |
michael@0 | 268 | "addon4@tests.mozilla.org", |
michael@0 | 269 | "addon5@tests.mozilla.org", |
michael@0 | 270 | "addon6@tests.mozilla.org", |
michael@0 | 271 | "addon7@tests.mozilla.org", |
michael@0 | 272 | "theme1@tests.mozilla.org", |
michael@0 | 273 | "theme2@tests.mozilla.org"], function([a1, a2, a3, |
michael@0 | 274 | a4, a5, a6, |
michael@0 | 275 | a7, t1, t2]) { |
michael@0 | 276 | do_check_neq(a1, null); |
michael@0 | 277 | do_check_true(a1.isActive); |
michael@0 | 278 | do_check_false(a1.userDisabled); |
michael@0 | 279 | do_check_false(a1.appDisabled); |
michael@0 | 280 | do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 281 | |
michael@0 | 282 | do_check_neq(a2, null); |
michael@0 | 283 | do_check_false(a2.isActive); |
michael@0 | 284 | do_check_true(a2.userDisabled); |
michael@0 | 285 | do_check_false(a2.appDisabled); |
michael@0 | 286 | do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 287 | |
michael@0 | 288 | do_check_neq(a3, null); |
michael@0 | 289 | do_check_true(a3.isActive); |
michael@0 | 290 | do_check_false(a3.userDisabled); |
michael@0 | 291 | do_check_false(a3.appDisabled); |
michael@0 | 292 | do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 293 | |
michael@0 | 294 | do_check_neq(a4, null); |
michael@0 | 295 | do_check_false(a4.isActive); |
michael@0 | 296 | do_check_true(a4.userDisabled); |
michael@0 | 297 | do_check_false(a4.appDisabled); |
michael@0 | 298 | do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 299 | |
michael@0 | 300 | do_check_neq(a5, null); |
michael@0 | 301 | do_check_false(a5.isActive); |
michael@0 | 302 | do_check_false(a5.userDisabled); |
michael@0 | 303 | do_check_true(a5.appDisabled); |
michael@0 | 304 | do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 305 | |
michael@0 | 306 | do_check_neq(a6, null); |
michael@0 | 307 | do_check_true(a6.isActive); |
michael@0 | 308 | do_check_false(a6.userDisabled); |
michael@0 | 309 | do_check_false(a6.appDisabled); |
michael@0 | 310 | do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 311 | |
michael@0 | 312 | do_check_neq(a7, null); |
michael@0 | 313 | do_check_false(a7.isActive); |
michael@0 | 314 | do_check_true(a7.userDisabled); |
michael@0 | 315 | do_check_false(a7.appDisabled); |
michael@0 | 316 | do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 317 | |
michael@0 | 318 | do_check_neq(t1, null); |
michael@0 | 319 | do_check_false(t1.isActive); |
michael@0 | 320 | do_check_true(t1.userDisabled); |
michael@0 | 321 | do_check_false(t1.appDisabled); |
michael@0 | 322 | do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 323 | |
michael@0 | 324 | do_check_neq(t2, null); |
michael@0 | 325 | do_check_true(t2.isActive); |
michael@0 | 326 | do_check_false(t2.userDisabled); |
michael@0 | 327 | do_check_false(t2.appDisabled); |
michael@0 | 328 | do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 329 | |
michael@0 | 330 | do_execute_soon(run_test_1_after_rebuild); |
michael@0 | 331 | }); |
michael@0 | 332 | } |
michael@0 | 333 | |
michael@0 | 334 | function run_test_1_after_rebuild() { |
michael@0 | 335 | restartManager(); |
michael@0 | 336 | |
michael@0 | 337 | AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", |
michael@0 | 338 | "addon2@tests.mozilla.org", |
michael@0 | 339 | "addon3@tests.mozilla.org", |
michael@0 | 340 | "addon4@tests.mozilla.org", |
michael@0 | 341 | "addon5@tests.mozilla.org", |
michael@0 | 342 | "addon6@tests.mozilla.org", |
michael@0 | 343 | "addon7@tests.mozilla.org", |
michael@0 | 344 | "theme1@tests.mozilla.org", |
michael@0 | 345 | "theme2@tests.mozilla.org"], function([a1, a2, a3, |
michael@0 | 346 | a4, a5, a6, |
michael@0 | 347 | a7, t1, t2]) { |
michael@0 | 348 | do_check_neq(a1, null); |
michael@0 | 349 | do_check_true(a1.isActive); |
michael@0 | 350 | do_check_false(a1.userDisabled); |
michael@0 | 351 | do_check_false(a1.appDisabled); |
michael@0 | 352 | do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 353 | |
michael@0 | 354 | do_check_neq(a2, null); |
michael@0 | 355 | do_check_false(a2.isActive); |
michael@0 | 356 | do_check_true(a2.userDisabled); |
michael@0 | 357 | do_check_false(a2.appDisabled); |
michael@0 | 358 | do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 359 | |
michael@0 | 360 | do_check_neq(a3, null); |
michael@0 | 361 | do_check_true(a3.isActive); |
michael@0 | 362 | do_check_false(a3.userDisabled); |
michael@0 | 363 | do_check_false(a3.appDisabled); |
michael@0 | 364 | do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 365 | |
michael@0 | 366 | do_check_neq(a4, null); |
michael@0 | 367 | do_check_false(a4.isActive); |
michael@0 | 368 | do_check_true(a4.userDisabled); |
michael@0 | 369 | do_check_false(a4.appDisabled); |
michael@0 | 370 | do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 371 | |
michael@0 | 372 | do_check_neq(a5, null); |
michael@0 | 373 | do_check_false(a5.isActive); |
michael@0 | 374 | do_check_false(a5.userDisabled); |
michael@0 | 375 | do_check_true(a5.appDisabled); |
michael@0 | 376 | do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 377 | |
michael@0 | 378 | do_check_neq(a6, null); |
michael@0 | 379 | do_check_true(a6.isActive); |
michael@0 | 380 | do_check_false(a6.userDisabled); |
michael@0 | 381 | do_check_false(a6.appDisabled); |
michael@0 | 382 | do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 383 | |
michael@0 | 384 | do_check_neq(a7, null); |
michael@0 | 385 | do_check_false(a7.isActive); |
michael@0 | 386 | do_check_true(a7.userDisabled); |
michael@0 | 387 | do_check_false(a7.appDisabled); |
michael@0 | 388 | do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 389 | |
michael@0 | 390 | do_check_neq(t1, null); |
michael@0 | 391 | do_check_false(t1.isActive); |
michael@0 | 392 | do_check_true(t1.userDisabled); |
michael@0 | 393 | do_check_false(t1.appDisabled); |
michael@0 | 394 | do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 395 | |
michael@0 | 396 | do_check_neq(t2, null); |
michael@0 | 397 | do_check_true(t2.isActive); |
michael@0 | 398 | do_check_false(t2.userDisabled); |
michael@0 | 399 | do_check_false(t2.appDisabled); |
michael@0 | 400 | do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE); |
michael@0 | 401 | |
michael@0 | 402 | end_test(); |
michael@0 | 403 | }); |
michael@0 | 404 | } |