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 | // Checks that changes that cause an add-on to become unblocked or blocked have |
michael@0 | 6 | // the right effect |
michael@0 | 7 | |
michael@0 | 8 | // The tests follow a mostly common pattern. First they start with the add-ons |
michael@0 | 9 | // unblocked, then they make a change that causes the add-ons to become blocked |
michael@0 | 10 | // then they make a similar change that keeps the add-ons blocked then they make |
michael@0 | 11 | // a change that unblocks the add-ons. Some tests skip the initial part and |
michael@0 | 12 | // start with add-ons detected as blocked. |
michael@0 | 13 | |
michael@0 | 14 | // softblock1 is enabled/disabled by the blocklist changes so its softDisabled |
michael@0 | 15 | // property should always match its userDisabled property |
michael@0 | 16 | |
michael@0 | 17 | // softblock2 gets manually enabled then disabled after it becomes blocked so |
michael@0 | 18 | // its softDisabled property should never become true after that |
michael@0 | 19 | |
michael@0 | 20 | // softblock3 does the same as softblock2 however it remains disabled |
michael@0 | 21 | |
michael@0 | 22 | // softblock4 is disabled while unblocked and so should never have softDisabled |
michael@0 | 23 | // set to true and stay userDisabled. This add-on is not used in tests that |
michael@0 | 24 | // start with add-ons blocked as it would be identical to softblock3 |
michael@0 | 25 | |
michael@0 | 26 | // softblock5 is a theme. Currently themes just get disabled when they become |
michael@0 | 27 | // softblocked and have to be manually re-enabled if they become completely |
michael@0 | 28 | // unblocked (bug 657520) |
michael@0 | 29 | |
michael@0 | 30 | const Cc = Components.classes; |
michael@0 | 31 | const Ci = Components.interfaces; |
michael@0 | 32 | const Cu = Components.utils; |
michael@0 | 33 | const Cr = Components.results; |
michael@0 | 34 | |
michael@0 | 35 | const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul"; |
michael@0 | 36 | |
michael@0 | 37 | Cu.import("resource://gre/modules/NetUtil.jsm"); |
michael@0 | 38 | |
michael@0 | 39 | // Allow insecure updates |
michael@0 | 40 | Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false) |
michael@0 | 41 | |
michael@0 | 42 | Cu.import("resource://testing-common/httpd.js"); |
michael@0 | 43 | var testserver = new HttpServer(); |
michael@0 | 44 | testserver.start(-1); |
michael@0 | 45 | gPort = testserver.identity.primaryPort; |
michael@0 | 46 | |
michael@0 | 47 | // register static files with server and interpolate port numbers in them |
michael@0 | 48 | mapFile("/data/blocklistchange/addon_update1.rdf", testserver); |
michael@0 | 49 | mapFile("/data/blocklistchange/addon_update2.rdf", testserver); |
michael@0 | 50 | mapFile("/data/blocklistchange/addon_update3.rdf", testserver); |
michael@0 | 51 | mapFile("/data/blocklistchange/addon_change.xml", testserver); |
michael@0 | 52 | mapFile("/data/blocklistchange/app_update.xml", testserver); |
michael@0 | 53 | mapFile("/data/blocklistchange/blocklist_update1.xml", testserver); |
michael@0 | 54 | mapFile("/data/blocklistchange/blocklist_update2.xml", testserver); |
michael@0 | 55 | mapFile("/data/blocklistchange/manual_update.xml", testserver); |
michael@0 | 56 | |
michael@0 | 57 | testserver.registerDirectory("/addons/", do_get_file("addons")); |
michael@0 | 58 | |
michael@0 | 59 | |
michael@0 | 60 | var default_theme = { |
michael@0 | 61 | id: "default@tests.mozilla.org", |
michael@0 | 62 | version: "1.0", |
michael@0 | 63 | name: "Softblocked add-on", |
michael@0 | 64 | internalName: "classic/1.0", |
michael@0 | 65 | targetApplications: [{ |
michael@0 | 66 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 67 | minVersion: "1", |
michael@0 | 68 | maxVersion: "3" |
michael@0 | 69 | }] |
michael@0 | 70 | }; |
michael@0 | 71 | |
michael@0 | 72 | var softblock1_1 = { |
michael@0 | 73 | id: "softblock1@tests.mozilla.org", |
michael@0 | 74 | version: "1.0", |
michael@0 | 75 | name: "Softblocked add-on", |
michael@0 | 76 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 77 | targetApplications: [{ |
michael@0 | 78 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 79 | minVersion: "1", |
michael@0 | 80 | maxVersion: "3" |
michael@0 | 81 | }] |
michael@0 | 82 | }; |
michael@0 | 83 | |
michael@0 | 84 | var softblock1_2 = { |
michael@0 | 85 | id: "softblock1@tests.mozilla.org", |
michael@0 | 86 | version: "2.0", |
michael@0 | 87 | name: "Softblocked add-on", |
michael@0 | 88 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 89 | targetApplications: [{ |
michael@0 | 90 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 91 | minVersion: "1", |
michael@0 | 92 | maxVersion: "3" |
michael@0 | 93 | }] |
michael@0 | 94 | }; |
michael@0 | 95 | |
michael@0 | 96 | var softblock1_3 = { |
michael@0 | 97 | id: "softblock1@tests.mozilla.org", |
michael@0 | 98 | version: "3.0", |
michael@0 | 99 | name: "Softblocked add-on", |
michael@0 | 100 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 101 | targetApplications: [{ |
michael@0 | 102 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 103 | minVersion: "1", |
michael@0 | 104 | maxVersion: "3" |
michael@0 | 105 | }] |
michael@0 | 106 | }; |
michael@0 | 107 | |
michael@0 | 108 | var softblock2_1 = { |
michael@0 | 109 | id: "softblock2@tests.mozilla.org", |
michael@0 | 110 | version: "1.0", |
michael@0 | 111 | name: "Softblocked add-on", |
michael@0 | 112 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 113 | targetApplications: [{ |
michael@0 | 114 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 115 | minVersion: "1", |
michael@0 | 116 | maxVersion: "3" |
michael@0 | 117 | }] |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | var softblock2_2 = { |
michael@0 | 121 | id: "softblock2@tests.mozilla.org", |
michael@0 | 122 | version: "2.0", |
michael@0 | 123 | name: "Softblocked add-on", |
michael@0 | 124 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 125 | targetApplications: [{ |
michael@0 | 126 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 127 | minVersion: "1", |
michael@0 | 128 | maxVersion: "3" |
michael@0 | 129 | }] |
michael@0 | 130 | }; |
michael@0 | 131 | |
michael@0 | 132 | var softblock2_3 = { |
michael@0 | 133 | id: "softblock2@tests.mozilla.org", |
michael@0 | 134 | version: "3.0", |
michael@0 | 135 | name: "Softblocked add-on", |
michael@0 | 136 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 137 | targetApplications: [{ |
michael@0 | 138 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 139 | minVersion: "1", |
michael@0 | 140 | maxVersion: "3" |
michael@0 | 141 | }] |
michael@0 | 142 | }; |
michael@0 | 143 | |
michael@0 | 144 | var softblock3_1 = { |
michael@0 | 145 | id: "softblock3@tests.mozilla.org", |
michael@0 | 146 | version: "1.0", |
michael@0 | 147 | name: "Softblocked add-on", |
michael@0 | 148 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 149 | targetApplications: [{ |
michael@0 | 150 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 151 | minVersion: "1", |
michael@0 | 152 | maxVersion: "3" |
michael@0 | 153 | }] |
michael@0 | 154 | }; |
michael@0 | 155 | |
michael@0 | 156 | var softblock3_2 = { |
michael@0 | 157 | id: "softblock3@tests.mozilla.org", |
michael@0 | 158 | version: "2.0", |
michael@0 | 159 | name: "Softblocked add-on", |
michael@0 | 160 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 161 | targetApplications: [{ |
michael@0 | 162 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 163 | minVersion: "1", |
michael@0 | 164 | maxVersion: "3" |
michael@0 | 165 | }] |
michael@0 | 166 | }; |
michael@0 | 167 | |
michael@0 | 168 | var softblock3_3 = { |
michael@0 | 169 | id: "softblock3@tests.mozilla.org", |
michael@0 | 170 | version: "3.0", |
michael@0 | 171 | name: "Softblocked add-on", |
michael@0 | 172 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 173 | targetApplications: [{ |
michael@0 | 174 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 175 | minVersion: "1", |
michael@0 | 176 | maxVersion: "3" |
michael@0 | 177 | }] |
michael@0 | 178 | }; |
michael@0 | 179 | |
michael@0 | 180 | var softblock4_1 = { |
michael@0 | 181 | id: "softblock4@tests.mozilla.org", |
michael@0 | 182 | version: "1.0", |
michael@0 | 183 | name: "Softblocked add-on", |
michael@0 | 184 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 185 | targetApplications: [{ |
michael@0 | 186 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 187 | minVersion: "1", |
michael@0 | 188 | maxVersion: "3" |
michael@0 | 189 | }] |
michael@0 | 190 | }; |
michael@0 | 191 | |
michael@0 | 192 | var softblock4_2 = { |
michael@0 | 193 | id: "softblock4@tests.mozilla.org", |
michael@0 | 194 | version: "2.0", |
michael@0 | 195 | name: "Softblocked add-on", |
michael@0 | 196 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 197 | targetApplications: [{ |
michael@0 | 198 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 199 | minVersion: "1", |
michael@0 | 200 | maxVersion: "3" |
michael@0 | 201 | }] |
michael@0 | 202 | }; |
michael@0 | 203 | |
michael@0 | 204 | var softblock4_3 = { |
michael@0 | 205 | id: "softblock4@tests.mozilla.org", |
michael@0 | 206 | version: "3.0", |
michael@0 | 207 | name: "Softblocked add-on", |
michael@0 | 208 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 209 | targetApplications: [{ |
michael@0 | 210 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 211 | minVersion: "1", |
michael@0 | 212 | maxVersion: "3" |
michael@0 | 213 | }] |
michael@0 | 214 | }; |
michael@0 | 215 | |
michael@0 | 216 | var softblock5_1 = { |
michael@0 | 217 | id: "softblock5@tests.mozilla.org", |
michael@0 | 218 | version: "1.0", |
michael@0 | 219 | name: "Softblocked add-on", |
michael@0 | 220 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 221 | internalName: "test/1.0", |
michael@0 | 222 | targetApplications: [{ |
michael@0 | 223 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 224 | minVersion: "1", |
michael@0 | 225 | maxVersion: "3" |
michael@0 | 226 | }] |
michael@0 | 227 | }; |
michael@0 | 228 | |
michael@0 | 229 | var softblock5_2 = { |
michael@0 | 230 | id: "softblock5@tests.mozilla.org", |
michael@0 | 231 | version: "2.0", |
michael@0 | 232 | name: "Softblocked add-on", |
michael@0 | 233 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 234 | internalName: "test/1.0", |
michael@0 | 235 | targetApplications: [{ |
michael@0 | 236 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 237 | minVersion: "1", |
michael@0 | 238 | maxVersion: "3" |
michael@0 | 239 | }] |
michael@0 | 240 | }; |
michael@0 | 241 | |
michael@0 | 242 | var softblock5_3 = { |
michael@0 | 243 | id: "softblock5@tests.mozilla.org", |
michael@0 | 244 | version: "3.0", |
michael@0 | 245 | name: "Softblocked add-on", |
michael@0 | 246 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 247 | internalName: "test/1.0", |
michael@0 | 248 | targetApplications: [{ |
michael@0 | 249 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 250 | minVersion: "1", |
michael@0 | 251 | maxVersion: "3" |
michael@0 | 252 | }] |
michael@0 | 253 | }; |
michael@0 | 254 | |
michael@0 | 255 | var hardblock_1 = { |
michael@0 | 256 | id: "hardblock@tests.mozilla.org", |
michael@0 | 257 | version: "1.0", |
michael@0 | 258 | name: "Hardblocked add-on", |
michael@0 | 259 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 260 | targetApplications: [{ |
michael@0 | 261 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 262 | minVersion: "1", |
michael@0 | 263 | maxVersion: "3" |
michael@0 | 264 | }] |
michael@0 | 265 | }; |
michael@0 | 266 | |
michael@0 | 267 | var hardblock_2 = { |
michael@0 | 268 | id: "hardblock@tests.mozilla.org", |
michael@0 | 269 | version: "2.0", |
michael@0 | 270 | name: "Hardblocked add-on", |
michael@0 | 271 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 272 | targetApplications: [{ |
michael@0 | 273 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 274 | minVersion: "1", |
michael@0 | 275 | maxVersion: "3" |
michael@0 | 276 | }] |
michael@0 | 277 | }; |
michael@0 | 278 | |
michael@0 | 279 | var hardblock_3 = { |
michael@0 | 280 | id: "hardblock@tests.mozilla.org", |
michael@0 | 281 | version: "3.0", |
michael@0 | 282 | name: "Hardblocked add-on", |
michael@0 | 283 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 284 | targetApplications: [{ |
michael@0 | 285 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 286 | minVersion: "1", |
michael@0 | 287 | maxVersion: "3" |
michael@0 | 288 | }] |
michael@0 | 289 | }; |
michael@0 | 290 | |
michael@0 | 291 | var regexpblock_1 = { |
michael@0 | 292 | id: "regexpblock@tests.mozilla.org", |
michael@0 | 293 | version: "1.0", |
michael@0 | 294 | name: "RegExp-blocked add-on", |
michael@0 | 295 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", |
michael@0 | 296 | targetApplications: [{ |
michael@0 | 297 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 298 | minVersion: "1", |
michael@0 | 299 | maxVersion: "3" |
michael@0 | 300 | }] |
michael@0 | 301 | }; |
michael@0 | 302 | |
michael@0 | 303 | var regexpblock_2 = { |
michael@0 | 304 | id: "regexpblock@tests.mozilla.org", |
michael@0 | 305 | version: "2.0", |
michael@0 | 306 | name: "RegExp-blocked add-on", |
michael@0 | 307 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", |
michael@0 | 308 | targetApplications: [{ |
michael@0 | 309 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 310 | minVersion: "1", |
michael@0 | 311 | maxVersion: "3" |
michael@0 | 312 | }] |
michael@0 | 313 | }; |
michael@0 | 314 | |
michael@0 | 315 | var regexpblock_3 = { |
michael@0 | 316 | id: "regexpblock@tests.mozilla.org", |
michael@0 | 317 | version: "3.0", |
michael@0 | 318 | name: "RegExp-blocked add-on", |
michael@0 | 319 | updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", |
michael@0 | 320 | targetApplications: [{ |
michael@0 | 321 | id: "xpcshell@tests.mozilla.org", |
michael@0 | 322 | minVersion: "1", |
michael@0 | 323 | maxVersion: "3" |
michael@0 | 324 | }] |
michael@0 | 325 | }; |
michael@0 | 326 | |
michael@0 | 327 | const ADDON_IDS = ["softblock1@tests.mozilla.org", |
michael@0 | 328 | "softblock2@tests.mozilla.org", |
michael@0 | 329 | "softblock3@tests.mozilla.org", |
michael@0 | 330 | "softblock4@tests.mozilla.org", |
michael@0 | 331 | "softblock5@tests.mozilla.org", |
michael@0 | 332 | "hardblock@tests.mozilla.org", |
michael@0 | 333 | "regexpblock@tests.mozilla.org"]; |
michael@0 | 334 | |
michael@0 | 335 | // Don't need the full interface, attempts to call other methods will just |
michael@0 | 336 | // throw which is just fine |
michael@0 | 337 | var WindowWatcher = { |
michael@0 | 338 | openWindow: function(parent, url, name, features, openArgs) { |
michael@0 | 339 | // Should be called to list the newly blocklisted items |
michael@0 | 340 | do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG); |
michael@0 | 341 | |
michael@0 | 342 | // Simulate auto-disabling any softblocks |
michael@0 | 343 | var list = openArgs.wrappedJSObject.list; |
michael@0 | 344 | list.forEach(function(aItem) { |
michael@0 | 345 | if (!aItem.blocked) |
michael@0 | 346 | aItem.disable = true; |
michael@0 | 347 | }); |
michael@0 | 348 | |
michael@0 | 349 | //run the code after the blocklist is closed |
michael@0 | 350 | Services.obs.notifyObservers(null, "addon-blocklist-closed", null); |
michael@0 | 351 | |
michael@0 | 352 | }, |
michael@0 | 353 | |
michael@0 | 354 | QueryInterface: function(iid) { |
michael@0 | 355 | if (iid.equals(Ci.nsIWindowWatcher) |
michael@0 | 356 | || iid.equals(Ci.nsISupports)) |
michael@0 | 357 | return this; |
michael@0 | 358 | |
michael@0 | 359 | throw Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 360 | } |
michael@0 | 361 | }; |
michael@0 | 362 | |
michael@0 | 363 | var WindowWatcherFactory = { |
michael@0 | 364 | createInstance: function createInstance(outer, iid) { |
michael@0 | 365 | if (outer != null) |
michael@0 | 366 | throw Components.results.NS_ERROR_NO_AGGREGATION; |
michael@0 | 367 | return WindowWatcher.QueryInterface(iid); |
michael@0 | 368 | } |
michael@0 | 369 | }; |
michael@0 | 370 | |
michael@0 | 371 | var InstallConfirm = { |
michael@0 | 372 | confirm: function(aWindow, aUrl, aInstalls, aInstallCount) { |
michael@0 | 373 | aInstalls.forEach(function(aInstall) { |
michael@0 | 374 | aInstall.install(); |
michael@0 | 375 | }); |
michael@0 | 376 | }, |
michael@0 | 377 | |
michael@0 | 378 | QueryInterface: function(iid) { |
michael@0 | 379 | if (iid.equals(Ci.amIWebInstallPrompt) |
michael@0 | 380 | || iid.equals(Ci.nsISupports)) |
michael@0 | 381 | return this; |
michael@0 | 382 | |
michael@0 | 383 | throw Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 384 | } |
michael@0 | 385 | }; |
michael@0 | 386 | |
michael@0 | 387 | var InstallConfirmFactory = { |
michael@0 | 388 | createInstance: function createInstance(outer, iid) { |
michael@0 | 389 | if (outer != null) |
michael@0 | 390 | throw Components.results.NS_ERROR_NO_AGGREGATION; |
michael@0 | 391 | return InstallConfirm.QueryInterface(iid); |
michael@0 | 392 | } |
michael@0 | 393 | }; |
michael@0 | 394 | |
michael@0 | 395 | var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); |
michael@0 | 396 | registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), |
michael@0 | 397 | "Fake Window Watcher", |
michael@0 | 398 | "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory); |
michael@0 | 399 | registrar.registerFactory(Components.ID("{f0863905-4dde-42e2-991c-2dc8209bc9ca}"), |
michael@0 | 400 | "Fake Install Prompt", |
michael@0 | 401 | "@mozilla.org/addons/web-install-prompt;1", InstallConfirmFactory); |
michael@0 | 402 | |
michael@0 | 403 | const profileDir = gProfD.clone(); |
michael@0 | 404 | profileDir.append("extensions"); |
michael@0 | 405 | |
michael@0 | 406 | function load_blocklist(aFile, aCallback) { |
michael@0 | 407 | Services.obs.addObserver(function() { |
michael@0 | 408 | Services.obs.removeObserver(arguments.callee, "blocklist-updated"); |
michael@0 | 409 | |
michael@0 | 410 | do_execute_soon(aCallback); |
michael@0 | 411 | }, "blocklist-updated", false); |
michael@0 | 412 | |
michael@0 | 413 | Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/blocklistchange/" + aFile); |
michael@0 | 414 | var blocklist = Cc["@mozilla.org/extensions/blocklist;1"]. |
michael@0 | 415 | getService(Ci.nsITimerCallback); |
michael@0 | 416 | blocklist.notify(null); |
michael@0 | 417 | } |
michael@0 | 418 | |
michael@0 | 419 | // Does a background update check for add-ons and waits for any started installs |
michael@0 | 420 | // to complete |
michael@0 | 421 | function background_update(aCallback) { |
michael@0 | 422 | var installCount = 0; |
michael@0 | 423 | var backgroundCheckCompleted = false; |
michael@0 | 424 | |
michael@0 | 425 | AddonManager.addInstallListener({ |
michael@0 | 426 | onNewInstall: function(aInstall) { |
michael@0 | 427 | installCount++; |
michael@0 | 428 | }, |
michael@0 | 429 | |
michael@0 | 430 | onInstallEnded: function(aInstall) { |
michael@0 | 431 | installCount--; |
michael@0 | 432 | // Wait until all started installs have completed |
michael@0 | 433 | if (installCount) |
michael@0 | 434 | return; |
michael@0 | 435 | |
michael@0 | 436 | AddonManager.removeInstallListener(this); |
michael@0 | 437 | |
michael@0 | 438 | // If the background check hasn't yet completed then let that call the |
michael@0 | 439 | // callback when it is done |
michael@0 | 440 | if (!backgroundCheckCompleted) |
michael@0 | 441 | return; |
michael@0 | 442 | |
michael@0 | 443 | do_execute_soon(aCallback); |
michael@0 | 444 | } |
michael@0 | 445 | }); |
michael@0 | 446 | |
michael@0 | 447 | Services.obs.addObserver(function() { |
michael@0 | 448 | Services.obs.removeObserver(arguments.callee, "addons-background-update-complete"); |
michael@0 | 449 | backgroundCheckCompleted = true; |
michael@0 | 450 | |
michael@0 | 451 | // If any new installs have started then we'll call the callback once they |
michael@0 | 452 | // are completed |
michael@0 | 453 | if (installCount) |
michael@0 | 454 | return; |
michael@0 | 455 | |
michael@0 | 456 | do_execute_soon(aCallback); |
michael@0 | 457 | }, "addons-background-update-complete", false); |
michael@0 | 458 | |
michael@0 | 459 | AddonManagerPrivate.backgroundUpdateCheck(); |
michael@0 | 460 | } |
michael@0 | 461 | |
michael@0 | 462 | // Manually updates the test add-ons to the given version |
michael@0 | 463 | function manual_update(aVersion, aCallback) { |
michael@0 | 464 | var installs = []; |
michael@0 | 465 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft1_" + aVersion + ".xpi", |
michael@0 | 466 | function(aInstall) { |
michael@0 | 467 | installs.push(aInstall); |
michael@0 | 468 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft2_" + aVersion + ".xpi", |
michael@0 | 469 | function(aInstall) { |
michael@0 | 470 | installs.push(aInstall); |
michael@0 | 471 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft3_" + aVersion + ".xpi", |
michael@0 | 472 | function(aInstall) { |
michael@0 | 473 | installs.push(aInstall); |
michael@0 | 474 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft4_" + aVersion + ".xpi", |
michael@0 | 475 | function(aInstall) { |
michael@0 | 476 | installs.push(aInstall); |
michael@0 | 477 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_soft5_" + aVersion + ".xpi", |
michael@0 | 478 | function(aInstall) { |
michael@0 | 479 | installs.push(aInstall); |
michael@0 | 480 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_hard1_" + aVersion + ".xpi", |
michael@0 | 481 | function(aInstall) { |
michael@0 | 482 | installs.push(aInstall); |
michael@0 | 483 | AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/blocklist_regexp1_" + aVersion + ".xpi", |
michael@0 | 484 | function(aInstall) { |
michael@0 | 485 | installs.push(aInstall); |
michael@0 | 486 | |
michael@0 | 487 | Services.obs.addObserver(function(aSubject, aTopic, aData) { |
michael@0 | 488 | Services.obs.removeObserver(arguments.callee, "addon-install-blocked"); |
michael@0 | 489 | |
michael@0 | 490 | aSubject.QueryInterface(Ci.amIWebInstallInfo); |
michael@0 | 491 | |
michael@0 | 492 | var installCount = aSubject.installs.length; |
michael@0 | 493 | |
michael@0 | 494 | var listener = { |
michael@0 | 495 | installComplete: function() { |
michael@0 | 496 | installCount--; |
michael@0 | 497 | if (installCount) |
michael@0 | 498 | return; |
michael@0 | 499 | |
michael@0 | 500 | do_execute_soon(aCallback); |
michael@0 | 501 | }, |
michael@0 | 502 | |
michael@0 | 503 | onDownloadCancelled: function(aInstall) { |
michael@0 | 504 | this.installComplete(); |
michael@0 | 505 | }, |
michael@0 | 506 | |
michael@0 | 507 | onInstallEnded: function(aInstall) { |
michael@0 | 508 | this.installComplete(); |
michael@0 | 509 | } |
michael@0 | 510 | }; |
michael@0 | 511 | |
michael@0 | 512 | aSubject.installs.forEach(function(aInstall) { |
michael@0 | 513 | aInstall.addListener(listener); |
michael@0 | 514 | }); |
michael@0 | 515 | |
michael@0 | 516 | aSubject.install(); |
michael@0 | 517 | }, "addon-install-blocked", false); |
michael@0 | 518 | |
michael@0 | 519 | AddonManager.installAddonsFromWebpage("application/x-xpinstall", null, |
michael@0 | 520 | NetUtil.newURI("http://localhost:" + gPort + "/"), |
michael@0 | 521 | installs); |
michael@0 | 522 | }, "application/x-xpinstall"); |
michael@0 | 523 | }, "application/x-xpinstall"); |
michael@0 | 524 | }, "application/x-xpinstall"); |
michael@0 | 525 | }, "application/x-xpinstall"); |
michael@0 | 526 | }, "application/x-xpinstall"); |
michael@0 | 527 | }, "application/x-xpinstall"); |
michael@0 | 528 | }, "application/x-xpinstall"); |
michael@0 | 529 | } |
michael@0 | 530 | |
michael@0 | 531 | // Checks that an add-ons properties match expected values |
michael@0 | 532 | function check_addon(aAddon, aExpectedVersion, aExpectedUserDisabled, |
michael@0 | 533 | aExpectedSoftDisabled, aExpectedState) { |
michael@0 | 534 | do_check_neq(aAddon, null); |
michael@0 | 535 | dump("Testing " + aAddon.id + " version " + aAddon.version + "\n"); |
michael@0 | 536 | dump(aAddon.userDisabled + " " + aAddon.softDisabled + "\n"); |
michael@0 | 537 | |
michael@0 | 538 | do_check_eq(aAddon.version, aExpectedVersion); |
michael@0 | 539 | do_check_eq(aAddon.blocklistState, aExpectedState); |
michael@0 | 540 | do_check_eq(aAddon.userDisabled, aExpectedUserDisabled); |
michael@0 | 541 | do_check_eq(aAddon.softDisabled, aExpectedSoftDisabled); |
michael@0 | 542 | if (aAddon.softDisabled) |
michael@0 | 543 | do_check_true(aAddon.userDisabled); |
michael@0 | 544 | |
michael@0 | 545 | if (aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED) { |
michael@0 | 546 | do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 547 | do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 548 | } |
michael@0 | 549 | else if (aAddon.userDisabled) { |
michael@0 | 550 | do_check_true(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 551 | do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 552 | } |
michael@0 | 553 | else { |
michael@0 | 554 | do_check_false(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_ENABLE)); |
michael@0 | 555 | if (aAddon.type != "theme") |
michael@0 | 556 | do_check_true(hasFlag(aAddon.permissions, AddonManager.PERM_CAN_DISABLE)); |
michael@0 | 557 | } |
michael@0 | 558 | do_check_eq(aAddon.appDisabled, aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 559 | |
michael@0 | 560 | let willBeActive = aAddon.isActive; |
michael@0 | 561 | if (hasFlag(aAddon.pendingOperations, AddonManager.PENDING_DISABLE)) |
michael@0 | 562 | willBeActive = false; |
michael@0 | 563 | else if (hasFlag(aAddon.pendingOperations, AddonManager.PENDING_ENABLE)) |
michael@0 | 564 | willBeActive = true; |
michael@0 | 565 | |
michael@0 | 566 | if (aExpectedUserDisabled || aExpectedState == Ci.nsIBlocklistService.STATE_BLOCKED) { |
michael@0 | 567 | do_check_false(willBeActive); |
michael@0 | 568 | } |
michael@0 | 569 | else { |
michael@0 | 570 | do_check_true(willBeActive); |
michael@0 | 571 | } |
michael@0 | 572 | } |
michael@0 | 573 | |
michael@0 | 574 | function run_test() { |
michael@0 | 575 | do_test_pending("test_blocklistchange main"); |
michael@0 | 576 | |
michael@0 | 577 | createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); |
michael@0 | 578 | writeInstallRDFForExtension(default_theme, profileDir); |
michael@0 | 579 | writeInstallRDFForExtension(softblock1_1, profileDir); |
michael@0 | 580 | writeInstallRDFForExtension(softblock2_1, profileDir); |
michael@0 | 581 | writeInstallRDFForExtension(softblock3_1, profileDir); |
michael@0 | 582 | writeInstallRDFForExtension(softblock4_1, profileDir); |
michael@0 | 583 | writeInstallRDFForExtension(softblock5_1, profileDir); |
michael@0 | 584 | writeInstallRDFForExtension(hardblock_1, profileDir); |
michael@0 | 585 | writeInstallRDFForExtension(regexpblock_1, profileDir); |
michael@0 | 586 | startupManager(); |
michael@0 | 587 | |
michael@0 | 588 | AddonManager.getAddonsByIDs(ADDON_IDS, do_exception_wrap(function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 589 | s4.userDisabled = true; |
michael@0 | 590 | s5.userDisabled = false; |
michael@0 | 591 | |
michael@0 | 592 | run_next_test(); |
michael@0 | 593 | })); |
michael@0 | 594 | } |
michael@0 | 595 | |
michael@0 | 596 | // Starts with add-ons unblocked and then switches application versions to |
michael@0 | 597 | // change add-ons to blocked and back |
michael@0 | 598 | add_test(function run_app_update_test() { |
michael@0 | 599 | do_print("Test: " + arguments.callee.name); |
michael@0 | 600 | restartManager(); |
michael@0 | 601 | load_blocklist("app_update.xml", function app_update_step_1() { |
michael@0 | 602 | restartManager(); |
michael@0 | 603 | |
michael@0 | 604 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 605 | |
michael@0 | 606 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 607 | check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 608 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 609 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 610 | check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 611 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 612 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 613 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); |
michael@0 | 614 | |
michael@0 | 615 | do_execute_soon(app_update_step_2); |
michael@0 | 616 | }) |
michael@0 | 617 | }); |
michael@0 | 618 | |
michael@0 | 619 | function app_update_step_2() { |
michael@0 | 620 | restartManager("2"); |
michael@0 | 621 | |
michael@0 | 622 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 623 | |
michael@0 | 624 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 625 | check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 626 | check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 627 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 628 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 629 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 630 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 631 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 632 | |
michael@0 | 633 | s2.userDisabled = false; |
michael@0 | 634 | s2.userDisabled = true; |
michael@0 | 635 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 636 | s3.userDisabled = false; |
michael@0 | 637 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 638 | |
michael@0 | 639 | do_execute_soon(app_update_step_3); |
michael@0 | 640 | }); |
michael@0 | 641 | } |
michael@0 | 642 | |
michael@0 | 643 | function app_update_step_3() { |
michael@0 | 644 | restartManager(); |
michael@0 | 645 | |
michael@0 | 646 | restartManager("2.5"); |
michael@0 | 647 | |
michael@0 | 648 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 649 | |
michael@0 | 650 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 651 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 652 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 653 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 654 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 655 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 656 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 657 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 658 | |
michael@0 | 659 | do_execute_soon(app_update_step_4); |
michael@0 | 660 | }); |
michael@0 | 661 | } |
michael@0 | 662 | |
michael@0 | 663 | function app_update_step_4() { |
michael@0 | 664 | restartManager("1"); |
michael@0 | 665 | |
michael@0 | 666 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 667 | |
michael@0 | 668 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 669 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 670 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 671 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 672 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 673 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 674 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 675 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 676 | |
michael@0 | 677 | s1.userDisabled = false; |
michael@0 | 678 | s2.userDisabled = false; |
michael@0 | 679 | s5.userDisabled = false; |
michael@0 | 680 | run_next_test(); |
michael@0 | 681 | }); |
michael@0 | 682 | } |
michael@0 | 683 | }); |
michael@0 | 684 | |
michael@0 | 685 | // Starts with add-ons unblocked and then switches application versions to |
michael@0 | 686 | // change add-ons to blocked and back. A DB schema change is faked to force a |
michael@0 | 687 | // rebuild when the application version changes |
michael@0 | 688 | add_test(function run_app_update_schema_test() { |
michael@0 | 689 | do_print("Test: " + arguments.callee.name); |
michael@0 | 690 | restartManager(); |
michael@0 | 691 | |
michael@0 | 692 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 693 | |
michael@0 | 694 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 695 | check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 696 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 697 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 698 | check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 699 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 700 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 701 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); |
michael@0 | 702 | |
michael@0 | 703 | do_execute_soon(update_schema_2); |
michael@0 | 704 | }); |
michael@0 | 705 | |
michael@0 | 706 | function update_schema_2() { |
michael@0 | 707 | shutdownManager(); |
michael@0 | 708 | |
michael@0 | 709 | changeXPIDBVersion(100); |
michael@0 | 710 | gAppInfo.version = "2"; |
michael@0 | 711 | startupManager(true); |
michael@0 | 712 | |
michael@0 | 713 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 714 | |
michael@0 | 715 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 716 | check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 717 | check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 718 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 719 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 720 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 721 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 722 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 723 | |
michael@0 | 724 | s2.userDisabled = false; |
michael@0 | 725 | s2.userDisabled = true; |
michael@0 | 726 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 727 | s3.userDisabled = false; |
michael@0 | 728 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 729 | do_execute_soon(update_schema_3); |
michael@0 | 730 | }); |
michael@0 | 731 | } |
michael@0 | 732 | |
michael@0 | 733 | function update_schema_3() { |
michael@0 | 734 | restartManager(); |
michael@0 | 735 | |
michael@0 | 736 | shutdownManager(); |
michael@0 | 737 | changeXPIDBVersion(100); |
michael@0 | 738 | gAppInfo.version = "2.5"; |
michael@0 | 739 | startupManager(true); |
michael@0 | 740 | |
michael@0 | 741 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 742 | |
michael@0 | 743 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 744 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 745 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 746 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 747 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 748 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 749 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 750 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 751 | |
michael@0 | 752 | do_execute_soon(update_schema_4); |
michael@0 | 753 | }); |
michael@0 | 754 | } |
michael@0 | 755 | |
michael@0 | 756 | function update_schema_4() { |
michael@0 | 757 | shutdownManager(); |
michael@0 | 758 | |
michael@0 | 759 | changeXPIDBVersion(100); |
michael@0 | 760 | startupManager(false); |
michael@0 | 761 | |
michael@0 | 762 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 763 | |
michael@0 | 764 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 765 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 766 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 767 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 768 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 769 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 770 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 771 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 772 | |
michael@0 | 773 | do_execute_soon(update_schema_5); |
michael@0 | 774 | }); |
michael@0 | 775 | } |
michael@0 | 776 | |
michael@0 | 777 | function update_schema_5() { |
michael@0 | 778 | shutdownManager(); |
michael@0 | 779 | |
michael@0 | 780 | changeXPIDBVersion(100); |
michael@0 | 781 | gAppInfo.version = "1"; |
michael@0 | 782 | startupManager(true); |
michael@0 | 783 | |
michael@0 | 784 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 785 | |
michael@0 | 786 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 787 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 788 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 789 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 790 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 791 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 792 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 793 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 794 | |
michael@0 | 795 | s1.userDisabled = false; |
michael@0 | 796 | s2.userDisabled = false; |
michael@0 | 797 | s5.userDisabled = false; |
michael@0 | 798 | run_next_test(); |
michael@0 | 799 | }); |
michael@0 | 800 | } |
michael@0 | 801 | }); |
michael@0 | 802 | |
michael@0 | 803 | // Starts with add-ons unblocked and then loads new blocklists to change add-ons |
michael@0 | 804 | // to blocked and back again. |
michael@0 | 805 | add_test(function run_blocklist_update_test() { |
michael@0 | 806 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 807 | load_blocklist("blocklist_update1.xml", function run_blocklist_update_1() { |
michael@0 | 808 | restartManager(); |
michael@0 | 809 | |
michael@0 | 810 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 811 | |
michael@0 | 812 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 813 | check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 814 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 815 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 816 | check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 817 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 818 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 819 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); |
michael@0 | 820 | |
michael@0 | 821 | load_blocklist("blocklist_update2.xml", function run_blocklist_update_2() { |
michael@0 | 822 | restartManager(); |
michael@0 | 823 | |
michael@0 | 824 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 825 | |
michael@0 | 826 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 827 | check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 828 | check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 829 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 830 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 831 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 832 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 833 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 834 | |
michael@0 | 835 | s2.userDisabled = false; |
michael@0 | 836 | s2.userDisabled = true; |
michael@0 | 837 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 838 | s3.userDisabled = false; |
michael@0 | 839 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 840 | |
michael@0 | 841 | do_execute_soon(function restart_and_reload() { |
michael@0 | 842 | restartManager(); |
michael@0 | 843 | |
michael@0 | 844 | load_blocklist("blocklist_update2.xml", function run_blocklist_update_3() { |
michael@0 | 845 | restartManager(); |
michael@0 | 846 | |
michael@0 | 847 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 848 | |
michael@0 | 849 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 850 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 851 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 852 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 853 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 854 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 855 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 856 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 857 | |
michael@0 | 858 | load_blocklist("blocklist_update1.xml", function run_blocklist_update_4() { |
michael@0 | 859 | restartManager(); |
michael@0 | 860 | |
michael@0 | 861 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 862 | |
michael@0 | 863 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 864 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 865 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 866 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 867 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 868 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 869 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 870 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 871 | |
michael@0 | 872 | s1.userDisabled = false; |
michael@0 | 873 | s2.userDisabled = false; |
michael@0 | 874 | s5.userDisabled = false; |
michael@0 | 875 | run_next_test(); |
michael@0 | 876 | }); |
michael@0 | 877 | }); |
michael@0 | 878 | }); |
michael@0 | 879 | }); |
michael@0 | 880 | }); |
michael@0 | 881 | }); |
michael@0 | 882 | }); |
michael@0 | 883 | }); |
michael@0 | 884 | }); |
michael@0 | 885 | }); |
michael@0 | 886 | |
michael@0 | 887 | // Starts with add-ons unblocked and then new versions are installed outside of |
michael@0 | 888 | // the app to change them to blocked and back again. |
michael@0 | 889 | add_test(function run_addon_change_test() { |
michael@0 | 890 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 891 | load_blocklist("addon_change.xml", function run_addon_change_1() { |
michael@0 | 892 | restartManager(); |
michael@0 | 893 | |
michael@0 | 894 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 895 | |
michael@0 | 896 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 897 | check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 898 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 899 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 900 | check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 901 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 902 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 903 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "test/1.0"); |
michael@0 | 904 | |
michael@0 | 905 | do_execute_soon(run_addon_change_2); |
michael@0 | 906 | }); |
michael@0 | 907 | }); |
michael@0 | 908 | |
michael@0 | 909 | function run_addon_change_2() { |
michael@0 | 910 | shutdownManager(); |
michael@0 | 911 | |
michael@0 | 912 | writeInstallRDFForExtension(softblock1_2, profileDir); |
michael@0 | 913 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_2.id), Date.now() + 10000); |
michael@0 | 914 | writeInstallRDFForExtension(softblock2_2, profileDir); |
michael@0 | 915 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_2.id), Date.now() + 10000); |
michael@0 | 916 | writeInstallRDFForExtension(softblock3_2, profileDir); |
michael@0 | 917 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_2.id), Date.now() + 10000); |
michael@0 | 918 | writeInstallRDFForExtension(softblock4_2, profileDir); |
michael@0 | 919 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_2.id), Date.now() + 10000); |
michael@0 | 920 | writeInstallRDFForExtension(softblock5_2, profileDir); |
michael@0 | 921 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_2.id), Date.now() + 10000); |
michael@0 | 922 | writeInstallRDFForExtension(hardblock_2, profileDir); |
michael@0 | 923 | setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_2.id), Date.now() + 10000); |
michael@0 | 924 | writeInstallRDFForExtension(regexpblock_2, profileDir); |
michael@0 | 925 | setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_2.id), Date.now() + 10000); |
michael@0 | 926 | |
michael@0 | 927 | startupManager(false); |
michael@0 | 928 | |
michael@0 | 929 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 930 | |
michael@0 | 931 | check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 932 | check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 933 | check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 934 | check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 935 | check_addon(s5, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 936 | check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 937 | check_addon(r, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 938 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 939 | |
michael@0 | 940 | s2.userDisabled = false; |
michael@0 | 941 | s2.userDisabled = true; |
michael@0 | 942 | check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 943 | s3.userDisabled = false; |
michael@0 | 944 | check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 945 | do_execute_soon(run_addon_change_3); |
michael@0 | 946 | }); |
michael@0 | 947 | } |
michael@0 | 948 | |
michael@0 | 949 | function run_addon_change_3() { |
michael@0 | 950 | restartManager(); |
michael@0 | 951 | |
michael@0 | 952 | shutdownManager(); |
michael@0 | 953 | |
michael@0 | 954 | writeInstallRDFForExtension(softblock1_3, profileDir); |
michael@0 | 955 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_3.id), Date.now() + 20000); |
michael@0 | 956 | writeInstallRDFForExtension(softblock2_3, profileDir); |
michael@0 | 957 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_3.id), Date.now() + 20000); |
michael@0 | 958 | writeInstallRDFForExtension(softblock3_3, profileDir); |
michael@0 | 959 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_3.id), Date.now() + 20000); |
michael@0 | 960 | writeInstallRDFForExtension(softblock4_3, profileDir); |
michael@0 | 961 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_3.id), Date.now() + 20000); |
michael@0 | 962 | writeInstallRDFForExtension(softblock5_3, profileDir); |
michael@0 | 963 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_3.id), Date.now() + 20000); |
michael@0 | 964 | writeInstallRDFForExtension(hardblock_3, profileDir); |
michael@0 | 965 | setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_3.id), Date.now() + 20000); |
michael@0 | 966 | writeInstallRDFForExtension(regexpblock_3, profileDir); |
michael@0 | 967 | setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_3.id), Date.now() + 20000); |
michael@0 | 968 | |
michael@0 | 969 | startupManager(false); |
michael@0 | 970 | |
michael@0 | 971 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 972 | |
michael@0 | 973 | check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 974 | check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 975 | check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 976 | check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 977 | check_addon(s5, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 978 | check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 979 | check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 980 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 981 | |
michael@0 | 982 | do_execute_soon(run_addon_change_4); |
michael@0 | 983 | }); |
michael@0 | 984 | } |
michael@0 | 985 | |
michael@0 | 986 | function run_addon_change_4() { |
michael@0 | 987 | shutdownManager(); |
michael@0 | 988 | |
michael@0 | 989 | writeInstallRDFForExtension(softblock1_1, profileDir); |
michael@0 | 990 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_1.id), Date.now() + 30000); |
michael@0 | 991 | writeInstallRDFForExtension(softblock2_1, profileDir); |
michael@0 | 992 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_1.id), Date.now() + 30000); |
michael@0 | 993 | writeInstallRDFForExtension(softblock3_1, profileDir); |
michael@0 | 994 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_1.id), Date.now() + 30000); |
michael@0 | 995 | writeInstallRDFForExtension(softblock4_1, profileDir); |
michael@0 | 996 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_1.id), Date.now() + 30000); |
michael@0 | 997 | writeInstallRDFForExtension(softblock5_1, profileDir); |
michael@0 | 998 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_1.id), Date.now() + 30000); |
michael@0 | 999 | writeInstallRDFForExtension(hardblock_1, profileDir); |
michael@0 | 1000 | setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_1.id), Date.now() + 30000); |
michael@0 | 1001 | writeInstallRDFForExtension(regexpblock_1, profileDir); |
michael@0 | 1002 | setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_1.id), Date.now() + 30000); |
michael@0 | 1003 | |
michael@0 | 1004 | startupManager(false); |
michael@0 | 1005 | |
michael@0 | 1006 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1007 | |
michael@0 | 1008 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1009 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1010 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1011 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1012 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1013 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1014 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1015 | do_check_eq(Services.prefs.getCharPref("general.skins.selectedSkin"), "classic/1.0"); |
michael@0 | 1016 | |
michael@0 | 1017 | s1.userDisabled = false; |
michael@0 | 1018 | s2.userDisabled = false; |
michael@0 | 1019 | s5.userDisabled = false; |
michael@0 | 1020 | run_next_test(); |
michael@0 | 1021 | }); |
michael@0 | 1022 | } |
michael@0 | 1023 | }); |
michael@0 | 1024 | |
michael@0 | 1025 | // Starts with add-ons blocked and then new versions are installed outside of |
michael@0 | 1026 | // the app to change them to unblocked. |
michael@0 | 1027 | add_test(function run_addon_change_2_test() { |
michael@0 | 1028 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 1029 | shutdownManager(); |
michael@0 | 1030 | |
michael@0 | 1031 | getFileForAddon(profileDir, softblock1_1.id).remove(true); |
michael@0 | 1032 | getFileForAddon(profileDir, softblock2_1.id).remove(true); |
michael@0 | 1033 | getFileForAddon(profileDir, softblock3_1.id).remove(true); |
michael@0 | 1034 | getFileForAddon(profileDir, softblock4_1.id).remove(true); |
michael@0 | 1035 | getFileForAddon(profileDir, softblock5_1.id).remove(true); |
michael@0 | 1036 | getFileForAddon(profileDir, hardblock_1.id).remove(true); |
michael@0 | 1037 | getFileForAddon(profileDir, regexpblock_1.id).remove(true); |
michael@0 | 1038 | |
michael@0 | 1039 | startupManager(false); |
michael@0 | 1040 | shutdownManager(); |
michael@0 | 1041 | |
michael@0 | 1042 | writeInstallRDFForExtension(softblock1_2, profileDir); |
michael@0 | 1043 | writeInstallRDFForExtension(softblock2_2, profileDir); |
michael@0 | 1044 | writeInstallRDFForExtension(softblock3_2, profileDir); |
michael@0 | 1045 | writeInstallRDFForExtension(softblock4_2, profileDir); |
michael@0 | 1046 | writeInstallRDFForExtension(softblock5_2, profileDir); |
michael@0 | 1047 | writeInstallRDFForExtension(hardblock_2, profileDir); |
michael@0 | 1048 | writeInstallRDFForExtension(regexpblock_2, profileDir); |
michael@0 | 1049 | |
michael@0 | 1050 | startupManager(false); |
michael@0 | 1051 | |
michael@0 | 1052 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1053 | |
michael@0 | 1054 | check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1055 | check_addon(s2, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1056 | check_addon(s3, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1057 | check_addon(h, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1058 | check_addon(r, "2.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1059 | |
michael@0 | 1060 | s2.userDisabled = false; |
michael@0 | 1061 | s2.userDisabled = true; |
michael@0 | 1062 | check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1063 | s3.userDisabled = false; |
michael@0 | 1064 | check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1065 | do_execute_soon(addon_change_2_test_2); |
michael@0 | 1066 | }); |
michael@0 | 1067 | |
michael@0 | 1068 | function addon_change_2_test_2() { |
michael@0 | 1069 | restartManager(); |
michael@0 | 1070 | |
michael@0 | 1071 | shutdownManager(); |
michael@0 | 1072 | |
michael@0 | 1073 | writeInstallRDFForExtension(softblock1_3, profileDir); |
michael@0 | 1074 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_3.id), Date.now() + 10000); |
michael@0 | 1075 | writeInstallRDFForExtension(softblock2_3, profileDir); |
michael@0 | 1076 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_3.id), Date.now() + 10000); |
michael@0 | 1077 | writeInstallRDFForExtension(softblock3_3, profileDir); |
michael@0 | 1078 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_3.id), Date.now() + 10000); |
michael@0 | 1079 | writeInstallRDFForExtension(softblock4_3, profileDir); |
michael@0 | 1080 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_3.id), Date.now() + 10000); |
michael@0 | 1081 | writeInstallRDFForExtension(softblock5_3, profileDir); |
michael@0 | 1082 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_3.id), Date.now() + 10000); |
michael@0 | 1083 | writeInstallRDFForExtension(hardblock_3, profileDir); |
michael@0 | 1084 | setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_3.id), Date.now() + 10000); |
michael@0 | 1085 | writeInstallRDFForExtension(regexpblock_3, profileDir); |
michael@0 | 1086 | setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_3.id), Date.now() + 10000); |
michael@0 | 1087 | |
michael@0 | 1088 | startupManager(false); |
michael@0 | 1089 | |
michael@0 | 1090 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1091 | |
michael@0 | 1092 | check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1093 | check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1094 | check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1095 | check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1096 | check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1097 | |
michael@0 | 1098 | do_execute_soon(addon_change_2_test_3); |
michael@0 | 1099 | }); |
michael@0 | 1100 | } |
michael@0 | 1101 | |
michael@0 | 1102 | function addon_change_2_test_3() { |
michael@0 | 1103 | shutdownManager(); |
michael@0 | 1104 | |
michael@0 | 1105 | writeInstallRDFForExtension(softblock1_1, profileDir); |
michael@0 | 1106 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock1_1.id), Date.now() + 20000); |
michael@0 | 1107 | writeInstallRDFForExtension(softblock2_1, profileDir); |
michael@0 | 1108 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock2_1.id), Date.now() + 20000); |
michael@0 | 1109 | writeInstallRDFForExtension(softblock3_1, profileDir); |
michael@0 | 1110 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock3_1.id), Date.now() + 20000); |
michael@0 | 1111 | writeInstallRDFForExtension(softblock4_1, profileDir); |
michael@0 | 1112 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock4_1.id), Date.now() + 20000); |
michael@0 | 1113 | writeInstallRDFForExtension(softblock5_1, profileDir); |
michael@0 | 1114 | setExtensionModifiedTime(getFileForAddon(profileDir, softblock5_1.id), Date.now() + 20000); |
michael@0 | 1115 | writeInstallRDFForExtension(hardblock_1, profileDir); |
michael@0 | 1116 | setExtensionModifiedTime(getFileForAddon(profileDir, hardblock_1.id), Date.now() + 20000); |
michael@0 | 1117 | writeInstallRDFForExtension(regexpblock_1, profileDir); |
michael@0 | 1118 | setExtensionModifiedTime(getFileForAddon(profileDir, regexpblock_1.id), Date.now() + 20000); |
michael@0 | 1119 | |
michael@0 | 1120 | startupManager(false); |
michael@0 | 1121 | |
michael@0 | 1122 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1123 | |
michael@0 | 1124 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1125 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1126 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1127 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1128 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1129 | |
michael@0 | 1130 | s1.userDisabled = false; |
michael@0 | 1131 | s2.userDisabled = false; |
michael@0 | 1132 | s4.userDisabled = true; |
michael@0 | 1133 | s5.userDisabled = false; |
michael@0 | 1134 | run_next_test(); |
michael@0 | 1135 | }); |
michael@0 | 1136 | } |
michael@0 | 1137 | }); |
michael@0 | 1138 | |
michael@0 | 1139 | // Add-ons are initially unblocked then attempts to upgrade to blocked versions |
michael@0 | 1140 | // in the background which should fail |
michael@0 | 1141 | add_test(function run_background_update_test() { |
michael@0 | 1142 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 1143 | restartManager(); |
michael@0 | 1144 | |
michael@0 | 1145 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1146 | |
michael@0 | 1147 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1148 | check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1149 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1150 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1151 | check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1152 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1153 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1154 | |
michael@0 | 1155 | background_update(function background_update_1() { |
michael@0 | 1156 | restartManager(); |
michael@0 | 1157 | |
michael@0 | 1158 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1159 | |
michael@0 | 1160 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1161 | check_addon(s2, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1162 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1163 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1164 | check_addon(s5, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1165 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1166 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1167 | |
michael@0 | 1168 | run_next_test(); |
michael@0 | 1169 | }); |
michael@0 | 1170 | }); |
michael@0 | 1171 | }); |
michael@0 | 1172 | }); |
michael@0 | 1173 | |
michael@0 | 1174 | // Starts with add-ons blocked and then new versions are detected and installed |
michael@0 | 1175 | // automatically for unblocked versions. |
michael@0 | 1176 | add_test(function run_background_update_2_test() { |
michael@0 | 1177 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 1178 | shutdownManager(); |
michael@0 | 1179 | |
michael@0 | 1180 | getFileForAddon(profileDir, softblock1_1.id).remove(true); |
michael@0 | 1181 | getFileForAddon(profileDir, softblock2_1.id).remove(true); |
michael@0 | 1182 | getFileForAddon(profileDir, softblock3_1.id).remove(true); |
michael@0 | 1183 | getFileForAddon(profileDir, softblock4_1.id).remove(true); |
michael@0 | 1184 | getFileForAddon(profileDir, softblock5_1.id).remove(true); |
michael@0 | 1185 | getFileForAddon(profileDir, hardblock_1.id).remove(true); |
michael@0 | 1186 | getFileForAddon(profileDir, regexpblock_1.id).remove(true); |
michael@0 | 1187 | |
michael@0 | 1188 | startupManager(false); |
michael@0 | 1189 | shutdownManager(); |
michael@0 | 1190 | |
michael@0 | 1191 | writeInstallRDFForExtension(softblock1_3, profileDir); |
michael@0 | 1192 | writeInstallRDFForExtension(softblock2_3, profileDir); |
michael@0 | 1193 | writeInstallRDFForExtension(softblock3_3, profileDir); |
michael@0 | 1194 | writeInstallRDFForExtension(softblock4_3, profileDir); |
michael@0 | 1195 | writeInstallRDFForExtension(softblock5_3, profileDir); |
michael@0 | 1196 | writeInstallRDFForExtension(hardblock_3, profileDir); |
michael@0 | 1197 | writeInstallRDFForExtension(regexpblock_3, profileDir); |
michael@0 | 1198 | |
michael@0 | 1199 | startupManager(false); |
michael@0 | 1200 | |
michael@0 | 1201 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1202 | |
michael@0 | 1203 | check_addon(s1, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1204 | check_addon(s2, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1205 | check_addon(s3, "3.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1206 | check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1207 | check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1208 | |
michael@0 | 1209 | s2.userDisabled = false; |
michael@0 | 1210 | s2.userDisabled = true; |
michael@0 | 1211 | check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1212 | s3.userDisabled = false; |
michael@0 | 1213 | check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1214 | |
michael@0 | 1215 | // make sure we're not in a handler when we restart |
michael@0 | 1216 | do_execute_soon(function restart_and_update() { |
michael@0 | 1217 | restartManager(); |
michael@0 | 1218 | |
michael@0 | 1219 | background_update(function background_update_2_1() { |
michael@0 | 1220 | restartManager(); |
michael@0 | 1221 | |
michael@0 | 1222 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1223 | |
michael@0 | 1224 | check_addon(s1, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1225 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1226 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1227 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1228 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1229 | |
michael@0 | 1230 | s1.userDisabled = false; |
michael@0 | 1231 | s2.userDisabled = false; |
michael@0 | 1232 | s4.userDisabled = true; |
michael@0 | 1233 | s5.userDisabled = true; |
michael@0 | 1234 | run_next_test(); |
michael@0 | 1235 | }); |
michael@0 | 1236 | }); |
michael@0 | 1237 | }); |
michael@0 | 1238 | }); |
michael@0 | 1239 | }); |
michael@0 | 1240 | |
michael@0 | 1241 | // Starts with add-ons blocked and then simulates the user upgrading them to |
michael@0 | 1242 | // unblocked versions. |
michael@0 | 1243 | add_test(function run_manual_update_test() { |
michael@0 | 1244 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 1245 | restartManager(); |
michael@0 | 1246 | load_blocklist("manual_update.xml", function manual_update_1() { |
michael@0 | 1247 | restartManager(); |
michael@0 | 1248 | |
michael@0 | 1249 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1250 | |
michael@0 | 1251 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1252 | check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1253 | check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1254 | check_addon(s4, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1255 | check_addon(s5, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1256 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1257 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1258 | |
michael@0 | 1259 | s2.userDisabled = false; |
michael@0 | 1260 | s2.userDisabled = true; |
michael@0 | 1261 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1262 | s3.userDisabled = false; |
michael@0 | 1263 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1264 | |
michael@0 | 1265 | do_execute_soon(function restart_manual_update() { |
michael@0 | 1266 | restartManager(); |
michael@0 | 1267 | |
michael@0 | 1268 | manual_update("2", function manual_update_2() { |
michael@0 | 1269 | restartManager(); |
michael@0 | 1270 | |
michael@0 | 1271 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1272 | |
michael@0 | 1273 | check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1274 | check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1275 | check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1276 | check_addon(s4, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1277 | check_addon(s5, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1278 | // Can't manually update to a hardblocked add-on |
michael@0 | 1279 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1280 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1281 | |
michael@0 | 1282 | manual_update("3", function manual_update_3() { |
michael@0 | 1283 | restartManager(); |
michael@0 | 1284 | |
michael@0 | 1285 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1286 | |
michael@0 | 1287 | check_addon(s1, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1288 | check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1289 | check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1290 | check_addon(s4, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1291 | check_addon(s5, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1292 | check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1293 | check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1294 | |
michael@0 | 1295 | run_next_test(); |
michael@0 | 1296 | }); |
michael@0 | 1297 | }); |
michael@0 | 1298 | }); |
michael@0 | 1299 | }); |
michael@0 | 1300 | }); |
michael@0 | 1301 | }); |
michael@0 | 1302 | }); |
michael@0 | 1303 | }); |
michael@0 | 1304 | |
michael@0 | 1305 | // Starts with add-ons blocked and then new versions are installed outside of |
michael@0 | 1306 | // the app to change them to unblocked. |
michael@0 | 1307 | add_test(function run_manual_update_2_test() { |
michael@0 | 1308 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 1309 | shutdownManager(); |
michael@0 | 1310 | |
michael@0 | 1311 | getFileForAddon(profileDir, softblock1_1.id).remove(true); |
michael@0 | 1312 | getFileForAddon(profileDir, softblock2_1.id).remove(true); |
michael@0 | 1313 | getFileForAddon(profileDir, softblock3_1.id).remove(true); |
michael@0 | 1314 | getFileForAddon(profileDir, softblock4_1.id).remove(true); |
michael@0 | 1315 | getFileForAddon(profileDir, softblock5_1.id).remove(true); |
michael@0 | 1316 | getFileForAddon(profileDir, hardblock_1.id).remove(true); |
michael@0 | 1317 | getFileForAddon(profileDir, regexpblock_1.id).remove(true); |
michael@0 | 1318 | |
michael@0 | 1319 | startupManager(false); |
michael@0 | 1320 | shutdownManager(); |
michael@0 | 1321 | |
michael@0 | 1322 | writeInstallRDFForExtension(softblock1_1, profileDir); |
michael@0 | 1323 | writeInstallRDFForExtension(softblock2_1, profileDir); |
michael@0 | 1324 | writeInstallRDFForExtension(softblock3_1, profileDir); |
michael@0 | 1325 | writeInstallRDFForExtension(softblock4_1, profileDir); |
michael@0 | 1326 | writeInstallRDFForExtension(softblock5_1, profileDir); |
michael@0 | 1327 | writeInstallRDFForExtension(hardblock_1, profileDir); |
michael@0 | 1328 | writeInstallRDFForExtension(regexpblock_1, profileDir); |
michael@0 | 1329 | |
michael@0 | 1330 | startupManager(false); |
michael@0 | 1331 | |
michael@0 | 1332 | AddonManager.getAddonsByIDs(ADDON_IDS, callback_soon(function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1333 | |
michael@0 | 1334 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1335 | check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1336 | check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1337 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1338 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1339 | |
michael@0 | 1340 | s2.userDisabled = false; |
michael@0 | 1341 | s2.userDisabled = true; |
michael@0 | 1342 | check_addon(s2, "1.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1343 | s3.userDisabled = false; |
michael@0 | 1344 | check_addon(s3, "1.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1345 | restartManager(); |
michael@0 | 1346 | |
michael@0 | 1347 | manual_update("2", function manual_update_2_2() { |
michael@0 | 1348 | restartManager(); |
michael@0 | 1349 | |
michael@0 | 1350 | AddonManager.getAddonsByIDs(ADDON_IDS, |
michael@0 | 1351 | callback_soon(function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1352 | |
michael@0 | 1353 | check_addon(s1, "2.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1354 | check_addon(s2, "2.0", true, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1355 | check_addon(s3, "2.0", false, false, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1356 | // Can't manually update to a hardblocked add-on |
michael@0 | 1357 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1358 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1359 | |
michael@0 | 1360 | restartManager(); |
michael@0 | 1361 | |
michael@0 | 1362 | manual_update("3", function manual_update_2_3() { |
michael@0 | 1363 | restartManager(); |
michael@0 | 1364 | |
michael@0 | 1365 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1366 | |
michael@0 | 1367 | check_addon(s1, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1368 | check_addon(s2, "3.0", true, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1369 | check_addon(s3, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1370 | check_addon(h, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1371 | check_addon(r, "3.0", false, false, Ci.nsIBlocklistService.STATE_NOT_BLOCKED); |
michael@0 | 1372 | |
michael@0 | 1373 | s1.userDisabled = false; |
michael@0 | 1374 | s2.userDisabled = false; |
michael@0 | 1375 | s4.userDisabled = true; |
michael@0 | 1376 | run_next_test(); |
michael@0 | 1377 | }); |
michael@0 | 1378 | }); |
michael@0 | 1379 | })); |
michael@0 | 1380 | }); |
michael@0 | 1381 | })); |
michael@0 | 1382 | }); |
michael@0 | 1383 | |
michael@0 | 1384 | // Uses the API to install blocked add-ons from the local filesystem |
michael@0 | 1385 | add_test(function run_local_install_test() { |
michael@0 | 1386 | do_print("Test: " + arguments.callee.name + "\n"); |
michael@0 | 1387 | shutdownManager(); |
michael@0 | 1388 | |
michael@0 | 1389 | getFileForAddon(profileDir, softblock1_1.id).remove(true); |
michael@0 | 1390 | getFileForAddon(profileDir, softblock2_1.id).remove(true); |
michael@0 | 1391 | getFileForAddon(profileDir, softblock3_1.id).remove(true); |
michael@0 | 1392 | getFileForAddon(profileDir, softblock4_1.id).remove(true); |
michael@0 | 1393 | getFileForAddon(profileDir, softblock5_1.id).remove(true); |
michael@0 | 1394 | getFileForAddon(profileDir, hardblock_1.id).remove(true); |
michael@0 | 1395 | getFileForAddon(profileDir, regexpblock_1.id).remove(true); |
michael@0 | 1396 | |
michael@0 | 1397 | startupManager(false); |
michael@0 | 1398 | |
michael@0 | 1399 | installAllFiles([ |
michael@0 | 1400 | do_get_file("addons/blocklist_soft1_1.xpi"), |
michael@0 | 1401 | do_get_file("addons/blocklist_soft2_1.xpi"), |
michael@0 | 1402 | do_get_file("addons/blocklist_soft3_1.xpi"), |
michael@0 | 1403 | do_get_file("addons/blocklist_soft4_1.xpi"), |
michael@0 | 1404 | do_get_file("addons/blocklist_soft5_1.xpi"), |
michael@0 | 1405 | do_get_file("addons/blocklist_hard1_1.xpi"), |
michael@0 | 1406 | do_get_file("addons/blocklist_regexp1_1.xpi") |
michael@0 | 1407 | ], function local_install_1() { |
michael@0 | 1408 | AddonManager.getAllInstalls(function(aInstalls) { |
michael@0 | 1409 | // Should have finished all installs without needing to restart |
michael@0 | 1410 | do_check_eq(aInstalls.length, 0); |
michael@0 | 1411 | |
michael@0 | 1412 | AddonManager.getAddonsByIDs(ADDON_IDS, function([s1, s2, s3, s4, s5, h, r]) { |
michael@0 | 1413 | |
michael@0 | 1414 | check_addon(s1, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1415 | check_addon(s2, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1416 | check_addon(s3, "1.0", true, true, Ci.nsIBlocklistService.STATE_SOFTBLOCKED); |
michael@0 | 1417 | check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1418 | check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED); |
michael@0 | 1419 | |
michael@0 | 1420 | run_next_test(); |
michael@0 | 1421 | }); |
michael@0 | 1422 | }); |
michael@0 | 1423 | }); |
michael@0 | 1424 | }); |
michael@0 | 1425 | |
michael@0 | 1426 | add_test(function shutdown_httpserver() { |
michael@0 | 1427 | testserver.stop(function() { |
michael@0 | 1428 | do_test_finished("test_blocklistchange main"); |
michael@0 | 1429 | // this really means "async test step done"; needs to be called |
michael@0 | 1430 | // even when there isn't a next test |
michael@0 | 1431 | run_next_test(); |
michael@0 | 1432 | }); |
michael@0 | 1433 | }); |