toolkit/mozapps/extensions/test/xpcshell/test_startup.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 // This verifies startup detection of added/removed/changed items and install
michael@0 6 // location priorities
michael@0 7
michael@0 8 // Enable loading extensions from the user and system scopes
michael@0 9 Services.prefs.setIntPref("extensions.enabledScopes",
michael@0 10 AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER +
michael@0 11 AddonManager.SCOPE_SYSTEM);
michael@0 12
michael@0 13 var addon1 = {
michael@0 14 id: "addon1@tests.mozilla.org",
michael@0 15 version: "1.0",
michael@0 16 name: "Test 1",
michael@0 17 targetApplications: [{
michael@0 18 id: "xpcshell@tests.mozilla.org",
michael@0 19 minVersion: "1",
michael@0 20 maxVersion: "1"
michael@0 21 }, { // Repeated target application entries should be ignored
michael@0 22 id: "xpcshell@tests.mozilla.org",
michael@0 23 minVersion: "2",
michael@0 24 maxVersion: "2"
michael@0 25 }]
michael@0 26 };
michael@0 27
michael@0 28 var addon2 = {
michael@0 29 id: "addon2@tests.mozilla.org",
michael@0 30 version: "2.0",
michael@0 31 name: "Test 2",
michael@0 32 targetApplications: [{ // Bad target application entries should be ignored
michael@0 33 minVersion: "3",
michael@0 34 maxVersion: "4"
michael@0 35 }, {
michael@0 36 id: "xpcshell@tests.mozilla.org",
michael@0 37 minVersion: "1",
michael@0 38 maxVersion: "2"
michael@0 39 }]
michael@0 40 };
michael@0 41
michael@0 42 var addon3 = {
michael@0 43 id: "addon3@tests.mozilla.org",
michael@0 44 version: "3.0",
michael@0 45 name: "Test 3",
michael@0 46 targetApplications: [{
michael@0 47 id: "toolkit@mozilla.org",
michael@0 48 minVersion: "1.9.2",
michael@0 49 maxVersion: "1.9.2.*"
michael@0 50 }]
michael@0 51 };
michael@0 52
michael@0 53 // Should be ignored because it has no ID
michael@0 54 var addon4 = {
michael@0 55 version: "4.0",
michael@0 56 name: "Test 4",
michael@0 57 targetApplications: [{
michael@0 58 id: "xpcshell@tests.mozilla.org",
michael@0 59 minVersion: "1",
michael@0 60 maxVersion: "1"
michael@0 61 }]
michael@0 62 };
michael@0 63
michael@0 64 // Should be ignored because it has no version
michael@0 65 var addon5 = {
michael@0 66 id: "addon5@tests.mozilla.org",
michael@0 67 name: "Test 5",
michael@0 68 targetApplications: [{
michael@0 69 id: "xpcshell@tests.mozilla.org",
michael@0 70 minVersion: "1",
michael@0 71 maxVersion: "1"
michael@0 72 }]
michael@0 73 };
michael@0 74
michael@0 75 // Should be ignored because it has an invalid type
michael@0 76 var addon6 = {
michael@0 77 id: "addon6@tests.mozilla.org",
michael@0 78 version: "3.0",
michael@0 79 name: "Test 6",
michael@0 80 type: 5,
michael@0 81 targetApplications: [{
michael@0 82 id: "toolkit@mozilla.org",
michael@0 83 minVersion: "1.9.2",
michael@0 84 maxVersion: "1.9.2.*"
michael@0 85 }]
michael@0 86 };
michael@0 87
michael@0 88 // Should be ignored because it has an invalid type
michael@0 89 var addon7 = {
michael@0 90 id: "addon7@tests.mozilla.org",
michael@0 91 version: "3.0",
michael@0 92 name: "Test 3",
michael@0 93 type: "extension",
michael@0 94 targetApplications: [{
michael@0 95 id: "toolkit@mozilla.org",
michael@0 96 minVersion: "1.9.2",
michael@0 97 maxVersion: "1.9.2.*"
michael@0 98 }]
michael@0 99 };
michael@0 100
michael@0 101 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
michael@0 102
michael@0 103 const globalDir = gProfD.clone();
michael@0 104 globalDir.append("extensions2");
michael@0 105 globalDir.append(gAppInfo.ID);
michael@0 106 registerDirectory("XRESysSExtPD", globalDir.parent);
michael@0 107 const userDir = gProfD.clone();
michael@0 108 userDir.append("extensions3");
michael@0 109 userDir.append(gAppInfo.ID);
michael@0 110 registerDirectory("XREUSysExt", userDir.parent);
michael@0 111 const profileDir = gProfD.clone();
michael@0 112 profileDir.append("extensions");
michael@0 113
michael@0 114 var gCachePurged = false;
michael@0 115
michael@0 116 // Set up the profile
michael@0 117 function run_test() {
michael@0 118 do_test_pending("test_startup main");
michael@0 119
michael@0 120 let obs = AM_Cc["@mozilla.org/observer-service;1"].
michael@0 121 getService(AM_Ci.nsIObserverService);
michael@0 122 obs.addObserver({
michael@0 123 observe: function(aSubject, aTopic, aData) {
michael@0 124 gCachePurged = true;
michael@0 125 }
michael@0 126 }, "startupcache-invalidate", false);
michael@0 127
michael@0 128 startupManager();
michael@0 129 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 130 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
michael@0 131 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 132 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 133 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 134
michael@0 135 do_check_false(gExtensionsJSON.exists());
michael@0 136
michael@0 137 do_check_false(gExtensionsINI.exists());
michael@0 138
michael@0 139 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 140 "addon2@tests.mozilla.org",
michael@0 141 "addon3@tests.mozilla.org",
michael@0 142 "addon4@tests.mozilla.org",
michael@0 143 "addon5@tests.mozilla.org",
michael@0 144 "addon6@tests.mozilla.org",
michael@0 145 "addon7@tests.mozilla.org"],
michael@0 146 function([a1, a2, a3, a4, a5, a6, a7]) {
michael@0 147
michael@0 148 do_check_eq(a1, null);
michael@0 149 do_check_not_in_crash_annotation(addon1.id, addon1.version);
michael@0 150 do_check_eq(a2, null);
michael@0 151 do_check_not_in_crash_annotation(addon2.id, addon2.version);
michael@0 152 do_check_eq(a3, null);
michael@0 153 do_check_not_in_crash_annotation(addon3.id, addon3.version);
michael@0 154 do_check_eq(a4, null);
michael@0 155 do_check_eq(a5, null);
michael@0 156
michael@0 157 do_execute_soon(run_test_1);
michael@0 158 });
michael@0 159 }
michael@0 160
michael@0 161 function end_test() {
michael@0 162 do_test_finished("test_startup main");
michael@0 163 }
michael@0 164
michael@0 165 // Try to install all the items into the profile
michael@0 166 function run_test_1() {
michael@0 167 writeInstallRDFForExtension(addon1, profileDir);
michael@0 168 var dest = writeInstallRDFForExtension(addon2, profileDir);
michael@0 169 // Attempt to make this look like it was added some time in the past so
michael@0 170 // the change in run_test_2 makes the last modified time change.
michael@0 171 setExtensionModifiedTime(dest, dest.lastModifiedTime - 5000);
michael@0 172
michael@0 173 writeInstallRDFForExtension(addon3, profileDir);
michael@0 174 writeInstallRDFForExtension(addon4, profileDir);
michael@0 175 writeInstallRDFForExtension(addon5, profileDir);
michael@0 176 writeInstallRDFForExtension(addon6, profileDir);
michael@0 177 writeInstallRDFForExtension(addon7, profileDir);
michael@0 178
michael@0 179 gCachePurged = false;
michael@0 180 restartManager();
michael@0 181 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, ["addon1@tests.mozilla.org",
michael@0 182 "addon2@tests.mozilla.org",
michael@0 183 "addon3@tests.mozilla.org"]);
michael@0 184 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
michael@0 185 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 186 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 187 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 188 do_check_true(gCachePurged);
michael@0 189
michael@0 190 do_print("Checking for " + gExtensionsINI.path);
michael@0 191 do_check_true(gExtensionsINI.exists());
michael@0 192
michael@0 193 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 194 "addon2@tests.mozilla.org",
michael@0 195 "addon3@tests.mozilla.org",
michael@0 196 "addon4@tests.mozilla.org",
michael@0 197 "addon5@tests.mozilla.org",
michael@0 198 "addon6@tests.mozilla.org",
michael@0 199 "addon7@tests.mozilla.org"],
michael@0 200 function([a1, a2, a3, a4, a5, a6, a7]) {
michael@0 201
michael@0 202 do_check_neq(a1, null);
michael@0 203 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 204 do_check_neq(a1.syncGUID, null);
michael@0 205 do_check_true(a1.syncGUID.length >= 9);
michael@0 206 do_check_eq(a1.version, "1.0");
michael@0 207 do_check_eq(a1.name, "Test 1");
michael@0 208 do_check_true(isExtensionInAddonsList(profileDir, a1.id));
michael@0 209 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 210 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 211 do_check_in_crash_annotation(addon1.id, addon1.version);
michael@0 212 do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
michael@0 213 do_check_eq(a1.sourceURI, null);
michael@0 214 do_check_true(a1.foreignInstall);
michael@0 215
michael@0 216 do_check_neq(a2, null);
michael@0 217 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 218 do_check_neq(a2.syncGUID, null);
michael@0 219 do_check_true(a2.syncGUID.length >= 9);
michael@0 220 do_check_eq(a2.version, "2.0");
michael@0 221 do_check_eq(a2.name, "Test 2");
michael@0 222 do_check_true(isExtensionInAddonsList(profileDir, a2.id));
michael@0 223 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 224 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 225 do_check_in_crash_annotation(addon2.id, addon2.version);
michael@0 226 do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
michael@0 227 do_check_eq(a2.sourceURI, null);
michael@0 228 do_check_true(a2.foreignInstall);
michael@0 229
michael@0 230 do_check_neq(a3, null);
michael@0 231 do_check_eq(a3.id, "addon3@tests.mozilla.org");
michael@0 232 do_check_neq(a3.syncGUID, null);
michael@0 233 do_check_true(a3.syncGUID.length >= 9);
michael@0 234 do_check_eq(a3.version, "3.0");
michael@0 235 do_check_eq(a3.name, "Test 3");
michael@0 236 do_check_true(isExtensionInAddonsList(profileDir, a3.id));
michael@0 237 do_check_true(hasFlag(a3.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 238 do_check_true(hasFlag(a3.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 239 do_check_in_crash_annotation(addon3.id, addon3.version);
michael@0 240 do_check_eq(a3.scope, AddonManager.SCOPE_PROFILE);
michael@0 241 do_check_eq(a3.sourceURI, null);
michael@0 242 do_check_true(a3.foreignInstall);
michael@0 243
michael@0 244 do_check_eq(a4, null);
michael@0 245 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 246 dest = profileDir.clone();
michael@0 247 dest.append(do_get_expected_addon_name("addon4@tests.mozilla.org"));
michael@0 248 do_check_false(dest.exists());
michael@0 249
michael@0 250 do_check_eq(a5, null);
michael@0 251 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 252 dest = profileDir.clone();
michael@0 253 dest.append(do_get_expected_addon_name("addon5@tests.mozilla.org"));
michael@0 254 do_check_false(dest.exists());
michael@0 255
michael@0 256 do_check_eq(a6, null);
michael@0 257 do_check_false(isExtensionInAddonsList(profileDir, "addon6@tests.mozilla.org"));
michael@0 258 dest = profileDir.clone();
michael@0 259 dest.append(do_get_expected_addon_name("addon6@tests.mozilla.org"));
michael@0 260 do_check_false(dest.exists());
michael@0 261
michael@0 262 do_check_eq(a7, null);
michael@0 263 do_check_false(isExtensionInAddonsList(profileDir, "addon7@tests.mozilla.org"));
michael@0 264 dest = profileDir.clone();
michael@0 265 dest.append(do_get_expected_addon_name("addon7@tests.mozilla.org"));
michael@0 266 do_check_false(dest.exists());
michael@0 267
michael@0 268 AddonManager.getAddonsByTypes(["extension"], function(extensionAddons) {
michael@0 269 do_check_eq(extensionAddons.length, 3);
michael@0 270
michael@0 271 do_execute_soon(run_test_2);
michael@0 272 });
michael@0 273 });
michael@0 274 }
michael@0 275
michael@0 276 // Test that modified items are detected and items in other install locations
michael@0 277 // are ignored
michael@0 278 function run_test_2() {
michael@0 279 addon1.version = "1.1";
michael@0 280 writeInstallRDFForExtension(addon1, userDir);
michael@0 281 addon2.version="2.1";
michael@0 282 writeInstallRDFForExtension(addon2, profileDir);
michael@0 283 addon2.version="2.2";
michael@0 284 writeInstallRDFForExtension(addon2, globalDir);
michael@0 285 addon2.version="2.3";
michael@0 286 writeInstallRDFForExtension(addon2, userDir);
michael@0 287 var dest = profileDir.clone();
michael@0 288 dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
michael@0 289 dest.remove(true);
michael@0 290
michael@0 291 gCachePurged = false;
michael@0 292 restartManager();
michael@0 293 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 294 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon2@tests.mozilla.org"]);
michael@0 295 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, ["addon3@tests.mozilla.org"]);
michael@0 296 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 297 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 298 do_check_true(gCachePurged);
michael@0 299
michael@0 300 do_check_true(gExtensionsINI.exists());
michael@0 301
michael@0 302 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 303 "addon2@tests.mozilla.org",
michael@0 304 "addon3@tests.mozilla.org",
michael@0 305 "addon4@tests.mozilla.org",
michael@0 306 "addon5@tests.mozilla.org"],
michael@0 307 function([a1, a2, a3, a4, a5]) {
michael@0 308
michael@0 309 do_check_neq(a1, null);
michael@0 310 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 311 do_check_eq(a1.version, "1.0");
michael@0 312 do_check_true(isExtensionInAddonsList(profileDir, a1.id));
michael@0 313 do_check_false(isExtensionInAddonsList(userDir, a1.id));
michael@0 314 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 315 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 316 do_check_in_crash_annotation(addon1.id, a1.version);
michael@0 317 do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
michael@0 318 do_check_true(a1.foreignInstall);
michael@0 319
michael@0 320 do_check_neq(a2, null);
michael@0 321 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 322 do_check_eq(a2.version, "2.1");
michael@0 323 do_check_true(isExtensionInAddonsList(profileDir, a2.id));
michael@0 324 do_check_false(isExtensionInAddonsList(userDir, a2.id));
michael@0 325 do_check_false(isExtensionInAddonsList(globalDir, a2.id));
michael@0 326 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 327 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 328 do_check_in_crash_annotation(addon2.id, a2.version);
michael@0 329 do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
michael@0 330 do_check_true(a2.foreignInstall);
michael@0 331
michael@0 332 do_check_eq(a3, null);
michael@0 333 do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
michael@0 334 do_check_not_in_crash_annotation(addon3.id, addon3.version);
michael@0 335
michael@0 336 do_check_eq(a4, null);
michael@0 337 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 338
michael@0 339 do_check_eq(a5, null);
michael@0 340 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 341
michael@0 342 do_execute_soon(run_test_3);
michael@0 343 });
michael@0 344 }
michael@0 345
michael@0 346 // Check that removing items from the profile reveals their hidden versions.
michael@0 347 function run_test_3() {
michael@0 348 var dest = profileDir.clone();
michael@0 349 dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
michael@0 350 dest.remove(true);
michael@0 351 dest = profileDir.clone();
michael@0 352 dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
michael@0 353 dest.remove(true);
michael@0 354 writeInstallRDFForExtension(addon3, profileDir, "addon4@tests.mozilla.org");
michael@0 355
michael@0 356 gCachePurged = false;
michael@0 357 restartManager();
michael@0 358 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 359 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon1@tests.mozilla.org",
michael@0 360 "addon2@tests.mozilla.org"]);
michael@0 361 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 362 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 363 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 364 do_check_true(gCachePurged);
michael@0 365
michael@0 366 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 367 "addon2@tests.mozilla.org",
michael@0 368 "addon3@tests.mozilla.org",
michael@0 369 "addon4@tests.mozilla.org",
michael@0 370 "addon5@tests.mozilla.org"],
michael@0 371 function([a1, a2, a3, a4, a5]) {
michael@0 372
michael@0 373 do_check_neq(a1, null);
michael@0 374 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 375 do_check_eq(a1.version, "1.1");
michael@0 376 do_check_false(isExtensionInAddonsList(profileDir, a1.id));
michael@0 377 do_check_true(isExtensionInAddonsList(userDir, a1.id));
michael@0 378 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 379 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 380 do_check_in_crash_annotation(addon1.id, a1.version);
michael@0 381 do_check_eq(a1.scope, AddonManager.SCOPE_USER);
michael@0 382
michael@0 383 do_check_neq(a2, null);
michael@0 384 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 385 do_check_eq(a2.version, "2.3");
michael@0 386 do_check_false(isExtensionInAddonsList(profileDir, a2.id));
michael@0 387 do_check_true(isExtensionInAddonsList(userDir, a2.id));
michael@0 388 do_check_false(isExtensionInAddonsList(globalDir, a2.id));
michael@0 389 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 390 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 391 do_check_in_crash_annotation(addon2.id, a2.version);
michael@0 392 do_check_eq(a2.scope, AddonManager.SCOPE_USER);
michael@0 393
michael@0 394 do_check_eq(a3, null);
michael@0 395 do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
michael@0 396
michael@0 397 do_check_eq(a4, null);
michael@0 398 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 399
michael@0 400 do_check_eq(a5, null);
michael@0 401 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 402
michael@0 403 dest = profileDir.clone();
michael@0 404 dest.append(do_get_expected_addon_name("addon4@tests.mozilla.org"));
michael@0 405 do_check_false(dest.exists());
michael@0 406
michael@0 407 do_execute_soon(run_test_4);
michael@0 408 });
michael@0 409 }
michael@0 410
michael@0 411 // Test that disabling an install location works
michael@0 412 function run_test_4() {
michael@0 413 Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_SYSTEM);
michael@0 414
michael@0 415 gCachePurged = false;
michael@0 416 restartManager();
michael@0 417 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 418 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon2@tests.mozilla.org"]);
michael@0 419 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, ["addon1@tests.mozilla.org"]);
michael@0 420 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 421 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 422 do_check_true(gCachePurged);
michael@0 423
michael@0 424 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 425 "addon2@tests.mozilla.org",
michael@0 426 "addon3@tests.mozilla.org",
michael@0 427 "addon4@tests.mozilla.org",
michael@0 428 "addon5@tests.mozilla.org"],
michael@0 429 function([a1, a2, a3, a4, a5]) {
michael@0 430
michael@0 431 do_check_eq(a1, null);
michael@0 432 do_check_false(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
michael@0 433 do_check_false(isExtensionInAddonsList(userDir, "addon1@tests.mozilla.org"));
michael@0 434
michael@0 435 do_check_neq(a2, null);
michael@0 436 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 437 do_check_eq(a2.version, "2.2");
michael@0 438 do_check_false(isExtensionInAddonsList(profileDir, a2.id));
michael@0 439 do_check_false(isExtensionInAddonsList(userDir, a2.id));
michael@0 440 do_check_true(isExtensionInAddonsList(globalDir, a2.id));
michael@0 441 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 442 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 443 do_check_in_crash_annotation(addon2.id, a2.version);
michael@0 444 do_check_eq(a2.scope, AddonManager.SCOPE_SYSTEM);
michael@0 445
michael@0 446 do_execute_soon(run_test_5);
michael@0 447 });
michael@0 448 }
michael@0 449
michael@0 450 // Switching disabled locations works
michael@0 451 function run_test_5() {
michael@0 452 Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_USER);
michael@0 453
michael@0 454 gCachePurged = false;
michael@0 455 restartManager();
michael@0 456 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, ["addon1@tests.mozilla.org"]);
michael@0 457 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon2@tests.mozilla.org"]);
michael@0 458 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 459 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 460 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 461 do_check_true(gCachePurged);
michael@0 462
michael@0 463 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 464 "addon2@tests.mozilla.org",
michael@0 465 "addon3@tests.mozilla.org",
michael@0 466 "addon4@tests.mozilla.org",
michael@0 467 "addon5@tests.mozilla.org"],
michael@0 468 function([a1, a2, a3, a4, a5]) {
michael@0 469
michael@0 470 do_check_neq(a1, null);
michael@0 471 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 472 do_check_eq(a1.version, "1.1");
michael@0 473 do_check_false(isExtensionInAddonsList(profileDir, a1.id));
michael@0 474 do_check_true(isExtensionInAddonsList(userDir, a1.id));
michael@0 475 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 476 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 477 do_check_in_crash_annotation(addon1.id, a1.version);
michael@0 478 do_check_eq(a1.scope, AddonManager.SCOPE_USER);
michael@0 479
michael@0 480 do_check_neq(a2, null);
michael@0 481 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 482 do_check_eq(a2.version, "2.3");
michael@0 483 do_check_false(isExtensionInAddonsList(profileDir, a2.id));
michael@0 484 do_check_true(isExtensionInAddonsList(userDir, a2.id));
michael@0 485 do_check_false(isExtensionInAddonsList(globalDir, a2.id));
michael@0 486 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 487 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 488 do_check_in_crash_annotation(addon2.id, a2.version);
michael@0 489 do_check_eq(a2.scope, AddonManager.SCOPE_USER);
michael@0 490
michael@0 491 do_execute_soon(run_test_6);
michael@0 492 });
michael@0 493 }
michael@0 494
michael@0 495 // Resetting the pref makes everything visible again
michael@0 496 function run_test_6() {
michael@0 497 Services.prefs.clearUserPref("extensions.enabledScopes");
michael@0 498
michael@0 499 gCachePurged = false;
michael@0 500 restartManager();
michael@0 501 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 502 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
michael@0 503 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 504 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 505 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 506 do_check_true(gCachePurged);
michael@0 507
michael@0 508 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 509 "addon2@tests.mozilla.org",
michael@0 510 "addon3@tests.mozilla.org",
michael@0 511 "addon4@tests.mozilla.org",
michael@0 512 "addon5@tests.mozilla.org"],
michael@0 513 function([a1, a2, a3, a4, a5]) {
michael@0 514
michael@0 515 do_check_neq(a1, null);
michael@0 516 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 517 do_check_eq(a1.version, "1.1");
michael@0 518 do_check_false(isExtensionInAddonsList(profileDir, a1.id));
michael@0 519 do_check_true(isExtensionInAddonsList(userDir, a1.id));
michael@0 520 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 521 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 522 do_check_in_crash_annotation(addon1.id, a1.version);
michael@0 523 do_check_eq(a1.scope, AddonManager.SCOPE_USER);
michael@0 524
michael@0 525 do_check_neq(a2, null);
michael@0 526 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 527 do_check_eq(a2.version, "2.3");
michael@0 528 do_check_false(isExtensionInAddonsList(profileDir, a2.id));
michael@0 529 do_check_true(isExtensionInAddonsList(userDir, a2.id));
michael@0 530 do_check_false(isExtensionInAddonsList(globalDir, a2.id));
michael@0 531 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 532 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 533 do_check_in_crash_annotation(addon2.id, a2.version);
michael@0 534 do_check_eq(a2.scope, AddonManager.SCOPE_USER);
michael@0 535
michael@0 536 do_execute_soon(run_test_7);
michael@0 537 });
michael@0 538 }
michael@0 539
michael@0 540 // Check that items in the profile hide the others again.
michael@0 541 function run_test_7() {
michael@0 542 addon1.version = "1.2";
michael@0 543 writeInstallRDFForExtension(addon1, profileDir);
michael@0 544 var dest = userDir.clone();
michael@0 545 dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
michael@0 546 dest.remove(true);
michael@0 547
michael@0 548 gCachePurged = false;
michael@0 549 restartManager();
michael@0 550 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 551 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon1@tests.mozilla.org",
michael@0 552 "addon2@tests.mozilla.org"]);
michael@0 553 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 554 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 555 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 556 do_check_true(gCachePurged);
michael@0 557
michael@0 558 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 559 "addon2@tests.mozilla.org",
michael@0 560 "addon3@tests.mozilla.org",
michael@0 561 "addon4@tests.mozilla.org",
michael@0 562 "addon5@tests.mozilla.org"],
michael@0 563 function([a1, a2, a3, a4, a5]) {
michael@0 564
michael@0 565 do_check_neq(a1, null);
michael@0 566 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 567 do_check_eq(a1.version, "1.2");
michael@0 568 do_check_true(isExtensionInAddonsList(profileDir, a1.id));
michael@0 569 do_check_false(isExtensionInAddonsList(userDir, a1.id));
michael@0 570 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 571 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 572 do_check_in_crash_annotation(addon1.id, a1.version);
michael@0 573 do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
michael@0 574
michael@0 575 do_check_neq(a2, null);
michael@0 576 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 577 do_check_eq(a2.version, "2.2");
michael@0 578 do_check_false(isExtensionInAddonsList(profileDir, a2.id));
michael@0 579 do_check_false(isExtensionInAddonsList(userDir, a2.id));
michael@0 580 do_check_true(isExtensionInAddonsList(globalDir, a2.id));
michael@0 581 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 582 do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 583 do_check_in_crash_annotation(addon2.id, a2.version);
michael@0 584 do_check_eq(a2.scope, AddonManager.SCOPE_SYSTEM);
michael@0 585
michael@0 586 do_check_eq(a3, null);
michael@0 587 do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
michael@0 588
michael@0 589 do_check_eq(a4, null);
michael@0 590 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 591
michael@0 592 do_check_eq(a5, null);
michael@0 593 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 594
michael@0 595 do_execute_soon(run_test_8);
michael@0 596 });
michael@0 597 }
michael@0 598
michael@0 599 // Disabling all locations still leaves the profile working
michael@0 600 function run_test_8() {
michael@0 601 Services.prefs.setIntPref("extensions.enabledScopes", 0);
michael@0 602
michael@0 603 gCachePurged = false;
michael@0 604 restartManager();
michael@0 605 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 606 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
michael@0 607 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, ["addon2@tests.mozilla.org"]);
michael@0 608 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 609 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 610 do_check_true(gCachePurged);
michael@0 611
michael@0 612 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 613 "addon2@tests.mozilla.org",
michael@0 614 "addon3@tests.mozilla.org",
michael@0 615 "addon4@tests.mozilla.org",
michael@0 616 "addon5@tests.mozilla.org"],
michael@0 617 function([a1, a2, a3, a4, a5]) {
michael@0 618
michael@0 619 do_check_neq(a1, null);
michael@0 620 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 621 do_check_eq(a1.version, "1.2");
michael@0 622 do_check_true(isExtensionInAddonsList(profileDir, a1.id));
michael@0 623 do_check_false(isExtensionInAddonsList(userDir, a1.id));
michael@0 624 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 625 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 626 do_check_in_crash_annotation(addon1.id, a1.version);
michael@0 627 do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
michael@0 628
michael@0 629 do_check_eq(a2, null);
michael@0 630 do_check_false(isExtensionInAddonsList(profileDir, "addon2@tests.mozilla.org"));
michael@0 631 do_check_false(isExtensionInAddonsList(userDir, "addon2@tests.mozilla.org"));
michael@0 632 do_check_false(isExtensionInAddonsList(globalDir, "addon2@tests.mozilla.org"));
michael@0 633
michael@0 634 do_execute_soon(run_test_9);
michael@0 635 });
michael@0 636 }
michael@0 637
michael@0 638 // More hiding and revealing
michael@0 639 function run_test_9() {
michael@0 640 Services.prefs.clearUserPref("extensions.enabledScopes", 0);
michael@0 641
michael@0 642 var dest = userDir.clone();
michael@0 643 dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
michael@0 644 dest.remove(true);
michael@0 645 dest = globalDir.clone();
michael@0 646 dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
michael@0 647 dest.remove(true);
michael@0 648 addon2.version = "2.4";
michael@0 649 writeInstallRDFForExtension(addon2, profileDir);
michael@0 650
michael@0 651 gCachePurged = false;
michael@0 652 restartManager();
michael@0 653 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, ["addon2@tests.mozilla.org"]);
michael@0 654 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
michael@0 655 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 656 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 657 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 658 do_check_true(gCachePurged);
michael@0 659
michael@0 660 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 661 "addon2@tests.mozilla.org",
michael@0 662 "addon3@tests.mozilla.org",
michael@0 663 "addon4@tests.mozilla.org",
michael@0 664 "addon5@tests.mozilla.org"],
michael@0 665 function([a1, a2, a3, a4, a5]) {
michael@0 666
michael@0 667 do_check_neq(a1, null);
michael@0 668 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 669 do_check_eq(a1.version, "1.2");
michael@0 670 do_check_true(isExtensionInAddonsList(profileDir, a1.id));
michael@0 671 do_check_false(isExtensionInAddonsList(userDir, a1.id));
michael@0 672 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 673 do_check_true(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 674 do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
michael@0 675
michael@0 676 do_check_neq(a2, null);
michael@0 677 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 678 do_check_eq(a2.version, "2.4");
michael@0 679 do_check_true(isExtensionInAddonsList(profileDir, a2.id));
michael@0 680 do_check_false(isExtensionInAddonsList(userDir, a2.id));
michael@0 681 do_check_false(isExtensionInAddonsList(globalDir, a2.id));
michael@0 682 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 683 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 684 do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
michael@0 685
michael@0 686 do_check_eq(a3, null);
michael@0 687 do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
michael@0 688
michael@0 689 do_check_eq(a4, null);
michael@0 690 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 691
michael@0 692 do_check_eq(a5, null);
michael@0 693 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 694
michael@0 695 do_execute_soon(run_test_10);
michael@0 696 });
michael@0 697 }
michael@0 698
michael@0 699 // Checks that a removal from one location and an addition in another location
michael@0 700 // for the same item is handled
michael@0 701 function run_test_10() {
michael@0 702 var dest = profileDir.clone();
michael@0 703 dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
michael@0 704 dest.remove(true);
michael@0 705 addon1.version = "1.3";
michael@0 706 writeInstallRDFForExtension(addon1, userDir);
michael@0 707
michael@0 708 gCachePurged = false;
michael@0 709 restartManager();
michael@0 710 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 711 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, ["addon1@tests.mozilla.org"]);
michael@0 712 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, []);
michael@0 713 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 714 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 715 do_check_true(gCachePurged);
michael@0 716
michael@0 717 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 718 "addon2@tests.mozilla.org",
michael@0 719 "addon3@tests.mozilla.org",
michael@0 720 "addon4@tests.mozilla.org",
michael@0 721 "addon5@tests.mozilla.org"],
michael@0 722 function([a1, a2, a3, a4, a5]) {
michael@0 723
michael@0 724 do_check_neq(a1, null);
michael@0 725 do_check_eq(a1.id, "addon1@tests.mozilla.org");
michael@0 726 do_check_eq(a1.version, "1.3");
michael@0 727 do_check_false(isExtensionInAddonsList(profileDir, a1.id));
michael@0 728 do_check_true(isExtensionInAddonsList(userDir, a1.id));
michael@0 729 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 730 do_check_false(hasFlag(a1.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 731 do_check_eq(a1.scope, AddonManager.SCOPE_USER);
michael@0 732
michael@0 733 do_check_neq(a2, null);
michael@0 734 do_check_eq(a2.id, "addon2@tests.mozilla.org");
michael@0 735 do_check_eq(a2.version, "2.4");
michael@0 736 do_check_true(isExtensionInAddonsList(profileDir, a2.id));
michael@0 737 do_check_false(isExtensionInAddonsList(userDir, a2.id));
michael@0 738 do_check_false(isExtensionInAddonsList(globalDir, a2.id));
michael@0 739 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UNINSTALL));
michael@0 740 do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_UPGRADE));
michael@0 741 do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
michael@0 742
michael@0 743 do_check_eq(a3, null);
michael@0 744 do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
michael@0 745
michael@0 746 do_check_eq(a4, null);
michael@0 747 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 748
michael@0 749 do_check_eq(a5, null);
michael@0 750 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 751
michael@0 752 do_execute_soon(run_test_11);
michael@0 753 });
michael@0 754 }
michael@0 755
michael@0 756 // This should remove any remaining items
michael@0 757 function run_test_11() {
michael@0 758 var dest = userDir.clone();
michael@0 759 dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
michael@0 760 dest.remove(true);
michael@0 761 dest = profileDir.clone();
michael@0 762 dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
michael@0 763 dest.remove(true);
michael@0 764
michael@0 765 gCachePurged = false;
michael@0 766 restartManager();
michael@0 767 check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
michael@0 768 check_startup_changes(AddonManager.STARTUP_CHANGE_CHANGED, []);
michael@0 769 check_startup_changes(AddonManager.STARTUP_CHANGE_UNINSTALLED, ["addon1@tests.mozilla.org",
michael@0 770 "addon2@tests.mozilla.org"]);
michael@0 771 check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
michael@0 772 check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
michael@0 773 do_check_true(gCachePurged);
michael@0 774
michael@0 775 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 776 "addon2@tests.mozilla.org",
michael@0 777 "addon3@tests.mozilla.org",
michael@0 778 "addon4@tests.mozilla.org",
michael@0 779 "addon5@tests.mozilla.org"],
michael@0 780 function([a1, a2, a3, a4, a5]) {
michael@0 781
michael@0 782 do_check_eq(a1, null);
michael@0 783 do_check_eq(a2, null);
michael@0 784 do_check_eq(a3, null);
michael@0 785 do_check_eq(a4, null);
michael@0 786 do_check_eq(a5, null);
michael@0 787 do_check_false(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
michael@0 788 do_check_false(isExtensionInAddonsList(profileDir, "addon2@tests.mozilla.org"));
michael@0 789 do_check_false(isExtensionInAddonsList(profileDir, "addon3@tests.mozilla.org"));
michael@0 790 do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
michael@0 791 do_check_false(isExtensionInAddonsList(profileDir, "addon5@tests.mozilla.org"));
michael@0 792 do_check_false(isExtensionInAddonsList(userDir, "addon1@tests.mozilla.org"));
michael@0 793 do_check_false(isExtensionInAddonsList(userDir, "addon2@tests.mozilla.org"));
michael@0 794 do_check_false(isExtensionInAddonsList(userDir, "addon3@tests.mozilla.org"));
michael@0 795 do_check_false(isExtensionInAddonsList(userDir, "addon4@tests.mozilla.org"));
michael@0 796 do_check_false(isExtensionInAddonsList(userDir, "addon5@tests.mozilla.org"));
michael@0 797 do_check_false(isExtensionInAddonsList(globalDir, "addon1@tests.mozilla.org"));
michael@0 798 do_check_false(isExtensionInAddonsList(globalDir, "addon2@tests.mozilla.org"));
michael@0 799 do_check_false(isExtensionInAddonsList(globalDir, "addon3@tests.mozilla.org"));
michael@0 800 do_check_false(isExtensionInAddonsList(globalDir, "addon4@tests.mozilla.org"));
michael@0 801 do_check_false(isExtensionInAddonsList(globalDir, "addon5@tests.mozilla.org"));
michael@0 802 do_check_not_in_crash_annotation(addon1.id, addon1.version);
michael@0 803 do_check_not_in_crash_annotation(addon2.id, addon2.version);
michael@0 804
michael@0 805 do_execute_soon(run_test_12);
michael@0 806 });
michael@0 807 }
michael@0 808
michael@0 809 // Test that auto-disabling for specific scopes works
michael@0 810 function run_test_12() {
michael@0 811 Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_USER);
michael@0 812
michael@0 813 writeInstallRDFForExtension(addon1, profileDir);
michael@0 814 writeInstallRDFForExtension(addon2, userDir);
michael@0 815 writeInstallRDFForExtension(addon3, globalDir);
michael@0 816
michael@0 817 restartManager();
michael@0 818
michael@0 819 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 820 "addon2@tests.mozilla.org",
michael@0 821 "addon3@tests.mozilla.org",
michael@0 822 "addon4@tests.mozilla.org",
michael@0 823 "addon5@tests.mozilla.org"],
michael@0 824 callback_soon(function([a1, a2, a3, a4, a5]) {
michael@0 825 do_check_neq(a1, null);
michael@0 826 do_check_false(a1.userDisabled);
michael@0 827 do_check_true(a1.isActive);
michael@0 828
michael@0 829 do_check_neq(a2, null);
michael@0 830 do_check_true(a2.userDisabled);
michael@0 831 do_check_false(a2.isActive);
michael@0 832
michael@0 833 do_check_neq(a3, null);
michael@0 834 do_check_false(a3.userDisabled);
michael@0 835 do_check_true(a3.isActive);
michael@0 836
michael@0 837 var dest = profileDir.clone();
michael@0 838 dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
michael@0 839 dest.remove(true);
michael@0 840 dest = userDir.clone();
michael@0 841 dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
michael@0 842 dest.remove(true);
michael@0 843 dest = globalDir.clone();
michael@0 844 dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
michael@0 845 dest.remove(true);
michael@0 846
michael@0 847 restartManager();
michael@0 848
michael@0 849 Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_SYSTEM);
michael@0 850
michael@0 851 writeInstallRDFForExtension(addon1, profileDir);
michael@0 852 writeInstallRDFForExtension(addon2, userDir);
michael@0 853 writeInstallRDFForExtension(addon3, globalDir);
michael@0 854
michael@0 855 restartManager();
michael@0 856
michael@0 857 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 858 "addon2@tests.mozilla.org",
michael@0 859 "addon3@tests.mozilla.org",
michael@0 860 "addon4@tests.mozilla.org",
michael@0 861 "addon5@tests.mozilla.org"],
michael@0 862 function([a1, a2, a3, a4, a5]) {
michael@0 863 do_check_neq(a1, null);
michael@0 864 do_check_false(a1.userDisabled);
michael@0 865 do_check_true(a1.isActive);
michael@0 866
michael@0 867 do_check_neq(a2, null);
michael@0 868 do_check_false(a2.userDisabled);
michael@0 869 do_check_true(a2.isActive);
michael@0 870
michael@0 871 do_check_neq(a3, null);
michael@0 872 do_check_true(a3.userDisabled);
michael@0 873 do_check_false(a3.isActive);
michael@0 874
michael@0 875 var dest = profileDir.clone();
michael@0 876 dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
michael@0 877 dest.remove(true);
michael@0 878 dest = userDir.clone();
michael@0 879 dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
michael@0 880 dest.remove(true);
michael@0 881 dest = globalDir.clone();
michael@0 882 dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
michael@0 883 dest.remove(true);
michael@0 884
michael@0 885 restartManager();
michael@0 886
michael@0 887 Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_USER + AddonManager.SCOPE_SYSTEM);
michael@0 888
michael@0 889 writeInstallRDFForExtension(addon1, profileDir);
michael@0 890 writeInstallRDFForExtension(addon2, userDir);
michael@0 891 writeInstallRDFForExtension(addon3, globalDir);
michael@0 892
michael@0 893 restartManager();
michael@0 894
michael@0 895 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 896 "addon2@tests.mozilla.org",
michael@0 897 "addon3@tests.mozilla.org",
michael@0 898 "addon4@tests.mozilla.org",
michael@0 899 "addon5@tests.mozilla.org"],
michael@0 900 function([a1, a2, a3, a4, a5]) {
michael@0 901 do_check_neq(a1, null);
michael@0 902 do_check_false(a1.userDisabled);
michael@0 903 do_check_true(a1.isActive);
michael@0 904
michael@0 905 do_check_neq(a2, null);
michael@0 906 do_check_true(a2.userDisabled);
michael@0 907 do_check_false(a2.isActive);
michael@0 908
michael@0 909 do_check_neq(a3, null);
michael@0 910 do_check_true(a3.userDisabled);
michael@0 911 do_check_false(a3.isActive);
michael@0 912
michael@0 913 do_execute_soon(end_test);
michael@0 914 });
michael@0 915 });
michael@0 916 }));
michael@0 917 }

mercurial