toolkit/mozapps/extensions/test/browser/browser_cancelCompatCheck.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 // Test that we can cancel the add-on compatibility check while it is
michael@0 6 // in progress (bug 772484).
michael@0 7 // Test framework copied from browser_bug557956.js
michael@0 8
michael@0 9 const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
michael@0 10
michael@0 11 const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
michael@0 12 const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion";
michael@0 13
michael@0 14 let repo = {};
michael@0 15 Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", repo);
michael@0 16
michael@0 17 /**
michael@0 18 * Test add-ons:
michael@0 19 *
michael@0 20 * Addon minVersion maxVersion Notes
michael@0 21 * addon1 0 *
michael@0 22 * addon2 0 0
michael@0 23 * addon3 0 0
michael@0 24 * addon4 1 *
michael@0 25 * addon5 0 0 Made compatible by update check
michael@0 26 * addon6 0 0 Made compatible by update check
michael@0 27 * addon7 0 0 Has a broken update available
michael@0 28 * addon8 0 0 Has an update available
michael@0 29 * addon9 0 0 Has an update available
michael@0 30 * addon10 0 0 Made incompatible by override check
michael@0 31 */
michael@0 32
michael@0 33 // describe the addons
michael@0 34 let ao1 = { file: "browser_bug557956_1", id: "addon1@tests.mozilla.org"};
michael@0 35 let ao2 = { file: "browser_bug557956_2", id: "addon2@tests.mozilla.org"};
michael@0 36 let ao3 = { file: "browser_bug557956_3", id: "addon3@tests.mozilla.org"};
michael@0 37 let ao4 = { file: "browser_bug557956_4", id: "addon4@tests.mozilla.org"};
michael@0 38 let ao5 = { file: "browser_bug557956_5", id: "addon5@tests.mozilla.org"};
michael@0 39 let ao6 = { file: "browser_bug557956_6", id: "addon6@tests.mozilla.org"};
michael@0 40 let ao7 = { file: "browser_bug557956_7", id: "addon7@tests.mozilla.org"};
michael@0 41 let ao8 = { file: "browser_bug557956_8_1", id: "addon8@tests.mozilla.org"};
michael@0 42 let ao9 = { file: "browser_bug557956_9_1", id: "addon9@tests.mozilla.org"};
michael@0 43 let ao10 = { file: "browser_bug557956_10", id: "addon10@tests.mozilla.org"};
michael@0 44
michael@0 45 // Return a promise that resolves after the specified delay in MS
michael@0 46 function delayMS(aDelay) {
michael@0 47 let deferred = Promise.defer();
michael@0 48 setTimeout(deferred.resolve, aDelay);
michael@0 49 return deferred.promise;
michael@0 50 }
michael@0 51
michael@0 52 // Return a promise that resolves when the specified observer topic is notified
michael@0 53 function promise_observer(aTopic) {
michael@0 54 let deferred = Promise.defer();
michael@0 55 Services.obs.addObserver(function observe(aSubject, aObsTopic, aData) {
michael@0 56 Services.obs.removeObserver(arguments.callee, aObsTopic);
michael@0 57 deferred.resolve([aSubject, aData]);
michael@0 58 }, aTopic, false);
michael@0 59 return deferred.promise;
michael@0 60 }
michael@0 61
michael@0 62 // Install a set of addons using a bogus update URL so that we can force
michael@0 63 // the compatibility update to happen later
michael@0 64 // @param aUpdateURL The real update URL to use after the add-ons are installed
michael@0 65 function promise_install_test_addons(aAddonList, aUpdateURL) {
michael@0 66 info("Starting add-on installs");
michael@0 67 var installs = [];
michael@0 68 let deferred = Promise.defer();
michael@0 69
michael@0 70 // Use a blank update URL
michael@0 71 Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
michael@0 72
michael@0 73 for (let addon of aAddonList) {
michael@0 74 AddonManager.getInstallForURL(TESTROOT + "addons/" + addon.file + ".xpi", function(aInstall) {
michael@0 75 installs.push(aInstall);
michael@0 76 }, "application/x-xpinstall");
michael@0 77 }
michael@0 78
michael@0 79 var listener = {
michael@0 80 installCount: 0,
michael@0 81
michael@0 82 onInstallEnded: function() {
michael@0 83 this.installCount++;
michael@0 84 if (this.installCount == installs.length) {
michael@0 85 info("Done add-on installs");
michael@0 86 // Switch to the test update URL
michael@0 87 Services.prefs.setCharPref(PREF_UPDATEURL, aUpdateURL);
michael@0 88 deferred.resolve();
michael@0 89 }
michael@0 90 }
michael@0 91 };
michael@0 92
michael@0 93 for (let install of installs) {
michael@0 94 install.addListener(listener);
michael@0 95 install.install();
michael@0 96 }
michael@0 97
michael@0 98 return deferred.promise;
michael@0 99 }
michael@0 100
michael@0 101 function promise_addons_by_ids(aAddonIDs) {
michael@0 102 info("promise_addons_by_ids " + aAddonIDs.toSource());
michael@0 103 let deferred = Promise.defer();
michael@0 104 AddonManager.getAddonsByIDs(aAddonIDs, deferred.resolve);
michael@0 105 return deferred.promise;
michael@0 106 }
michael@0 107
michael@0 108 function* promise_uninstall_test_addons() {
michael@0 109 info("Starting add-on uninstalls");
michael@0 110 let addons = yield promise_addons_by_ids([ao1.id, ao2.id, ao3.id, ao4.id, ao5.id,
michael@0 111 ao6.id, ao7.id, ao8.id, ao9.id, ao10.id]);
michael@0 112 let deferred = Promise.defer();
michael@0 113 let uninstallCount = addons.length;
michael@0 114 let listener = {
michael@0 115 onUninstalled: function(aAddon) {
michael@0 116 if (aAddon) {
michael@0 117 info("Finished uninstalling " + aAddon.id);
michael@0 118 }
michael@0 119 if (--uninstallCount == 0) {
michael@0 120 info("Done add-on uninstalls");
michael@0 121 AddonManager.removeAddonListener(listener);
michael@0 122 deferred.resolve();
michael@0 123 }
michael@0 124 }};
michael@0 125 AddonManager.addAddonListener(listener);
michael@0 126 for (let addon of addons) {
michael@0 127 if (addon)
michael@0 128 addon.uninstall();
michael@0 129 else
michael@0 130 listener.onUninstalled(null);
michael@0 131 }
michael@0 132 yield deferred.promise;
michael@0 133 }
michael@0 134
michael@0 135 // Returns promise{window}, resolves with a handle to the compatibility
michael@0 136 // check window
michael@0 137 function promise_open_compatibility_window(aInactiveAddonIds) {
michael@0 138 let deferred = Promise.defer();
michael@0 139 // This will reset the longer timeout multiplier to 2 which will give each
michael@0 140 // test that calls open_compatibility_window a minimum of 60 seconds to
michael@0 141 // complete.
michael@0 142 requestLongerTimeout(100 /* XXX was 2 */);
michael@0 143
michael@0 144 var variant = Cc["@mozilla.org/variant;1"].
michael@0 145 createInstance(Ci.nsIWritableVariant);
michael@0 146 variant.setFromVariant(aInactiveAddonIds);
michael@0 147
michael@0 148 // Cannot be modal as we want to interract with it, shouldn't cause problems
michael@0 149 // with testing though.
michael@0 150 var features = "chrome,centerscreen,dialog,titlebar";
michael@0 151 var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
michael@0 152 getService(Ci.nsIWindowWatcher);
michael@0 153 var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant);
michael@0 154
michael@0 155 win.addEventListener("load", function() {
michael@0 156 function page_shown(aEvent) {
michael@0 157 if (aEvent.target.pageid)
michael@0 158 info("Page " + aEvent.target.pageid + " shown");
michael@0 159 }
michael@0 160
michael@0 161 win.removeEventListener("load", arguments.callee, false);
michael@0 162
michael@0 163 info("Compatibility dialog opened");
michael@0 164
michael@0 165 win.addEventListener("pageshow", page_shown, false);
michael@0 166 win.addEventListener("unload", function() {
michael@0 167 win.removeEventListener("unload", arguments.callee, false);
michael@0 168 win.removeEventListener("pageshow", page_shown, false);
michael@0 169 dump("Compatibility dialog closed\n");
michael@0 170 }, false);
michael@0 171
michael@0 172 deferred.resolve(win);
michael@0 173 }, false);
michael@0 174 return deferred.promise;
michael@0 175 }
michael@0 176
michael@0 177 function promise_window_close(aWindow) {
michael@0 178 let deferred = Promise.defer();
michael@0 179 aWindow.addEventListener("unload", function() {
michael@0 180 aWindow.removeEventListener("unload", arguments.callee, false);
michael@0 181 deferred.resolve(aWindow);
michael@0 182 }, false);
michael@0 183 return deferred.promise;
michael@0 184 }
michael@0 185
michael@0 186 function promise_page(aWindow, aPageId) {
michael@0 187 let deferred = Promise.defer();
michael@0 188 var page = aWindow.document.getElementById(aPageId);
michael@0 189 if (aWindow.document.getElementById("updateWizard").currentPage === page) {
michael@0 190 deferred.resolve(aWindow);
michael@0 191 } else {
michael@0 192 page.addEventListener("pageshow", function() {
michael@0 193 page.removeEventListener("pageshow", arguments.callee, false);
michael@0 194 executeSoon(function() {
michael@0 195 deferred.resolve(aWindow);
michael@0 196 });
michael@0 197 }, false);
michael@0 198 }
michael@0 199 return deferred.promise;
michael@0 200 }
michael@0 201
michael@0 202 function get_list_names(aList) {
michael@0 203 var items = [];
michael@0 204 for (let listItem of aList.childNodes)
michael@0 205 items.push(listItem.label);
michael@0 206 items.sort();
michael@0 207 return items;
michael@0 208 }
michael@0 209
michael@0 210 // These add-ons were inactive in the old application
michael@0 211 let inactiveAddonIds = [
michael@0 212 ao2.id,
michael@0 213 ao4.id,
michael@0 214 ao5.id,
michael@0 215 ao10.id
michael@0 216 ];
michael@0 217
michael@0 218 // Make sure the addons in the list are not installed
michael@0 219 function* check_addons_uninstalled(aAddonList) {
michael@0 220 let foundList = yield promise_addons_by_ids([addon.id for (addon of aAddonList)]);
michael@0 221 for (let i = 0; i < aAddonList.length; i++) {
michael@0 222 ok(!foundList[i], "Addon " + aAddonList[i].id + " is not installed");
michael@0 223 }
michael@0 224 info("Add-on uninstall check complete");
michael@0 225 yield true;
michael@0 226 }
michael@0 227
michael@0 228
michael@0 229 // Tests that the right add-ons show up in the mismatch dialog and updates can
michael@0 230 // be installed
michael@0 231 // This is a task-based rewrite of the first test in browser_bug557956.js
michael@0 232 // kept here to show the whole process so that other tests in this file can
michael@0 233 // pick and choose which steps to perform, but disabled since the logic is already
michael@0 234 // tested in browser_bug557956.js.
michael@0 235 // add_task(
michael@0 236 function start_update() {
michael@0 237 // Don't pull compatibility data during add-on install
michael@0 238 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
michael@0 239 let addonList = [ao3, ao5, ao6, ao7, ao8, ao9];
michael@0 240 yield promise_install_test_addons(addonList, TESTROOT + "cancelCompatCheck.sjs");
michael@0 241
michael@0 242
michael@0 243 // Check that the addons start out not compatible.
michael@0 244 let [a5, a6, a8, a9] = yield promise_addons_by_ids([ao5.id, ao6.id, ao8.id, ao9.id]);
michael@0 245 ok(!a5.isCompatible, "addon5 should not be compatible");
michael@0 246 ok(!a6.isCompatible, "addon6 should not be compatible");
michael@0 247 ok(!a8.isCompatible, "addon8 should not be compatible");
michael@0 248 ok(!a9.isCompatible, "addon9 should not be compatible");
michael@0 249
michael@0 250 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
michael@0 251 // Check that opening the compatibility window loads and applies
michael@0 252 // the compatibility update
michael@0 253 let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds);
michael@0 254 var doc = compatWindow.document;
michael@0 255 compatWindow = yield promise_page(compatWindow, "mismatch");
michael@0 256 var items = get_list_names(doc.getElementById("mismatch.incompatible"));
michael@0 257 is(items.length, 4, "Should have seen 4 still incompatible items");
michael@0 258 is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible");
michael@0 259 is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible");
michael@0 260 is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible");
michael@0 261 is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible");
michael@0 262
michael@0 263 ok(a5.isCompatible, "addon5 should be compatible");
michael@0 264 ok(a6.isCompatible, "addon6 should be compatible");
michael@0 265
michael@0 266 // Click next to start finding updates for the addons that are still incompatible
michael@0 267 var button = doc.documentElement.getButton("next");
michael@0 268 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 269
michael@0 270 compatWindow = yield promise_page(compatWindow, "found");
michael@0 271 ok(doc.getElementById("xpinstallDisabledAlert").hidden,
michael@0 272 "Install should be allowed");
michael@0 273
michael@0 274 var list = doc.getElementById("found.updates");
michael@0 275 var items = get_list_names(list);
michael@0 276 is(items.length, 3, "Should have seen 3 updates available");
michael@0 277 is(items[0], "Addon7 2.0", "Should have seen update for addon7");
michael@0 278 is(items[1], "Addon8 2.0", "Should have seen update for addon8");
michael@0 279 is(items[2], "Addon9 2.0", "Should have seen update for addon9");
michael@0 280
michael@0 281 ok(!doc.documentElement.getButton("next").disabled,
michael@0 282 "Next button should be enabled");
michael@0 283
michael@0 284 // Uncheck all
michael@0 285 for (let listItem of list.childNodes)
michael@0 286 EventUtils.synthesizeMouse(listItem, 2, 2, { }, compatWindow);
michael@0 287
michael@0 288 ok(doc.documentElement.getButton("next").disabled,
michael@0 289 "Next button should not be enabled");
michael@0 290
michael@0 291 // Check the ones we want to install
michael@0 292 for (let listItem of list.childNodes) {
michael@0 293 if (listItem.label != "Addon7 2.0")
michael@0 294 EventUtils.synthesizeMouse(listItem, 2, 2, { }, compatWindow);
michael@0 295 }
michael@0 296
michael@0 297 var button = doc.documentElement.getButton("next");
michael@0 298 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 299
michael@0 300 compatWindow = yield promise_page(compatWindow, "finished");
michael@0 301 var button = doc.documentElement.getButton("finish");
michael@0 302 ok(!button.hidden, "Finish button should not be hidden");
michael@0 303 ok(!button.disabled, "Finish button should not be disabled");
michael@0 304 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 305
michael@0 306 compatWindow = yield promise_window_close(compatWindow);
michael@0 307
michael@0 308 // Check that the appropriate add-ons have been updated
michael@0 309 let [a8, a9] = yield promise_addons_by_ids(["addon8@tests.mozilla.org",
michael@0 310 "addon9@tests.mozilla.org"]);
michael@0 311 is(a8.version, "2.0", "addon8 should have updated");
michael@0 312 is(a9.version, "2.0", "addon9 should have updated");
michael@0 313
michael@0 314 yield promise_uninstall_test_addons();
michael@0 315 }
michael@0 316 // );
michael@0 317
michael@0 318 // Test what happens when the user cancels during AddonRepository.repopulateCache()
michael@0 319 // Add-ons that have updates available should not update if they were disabled before
michael@0 320 // For this test, addon8 became disabled during update and addon9 was previously disabled,
michael@0 321 // so addon8 should update and addon9 should not
michael@0 322 add_task(function cancel_during_repopulate() {
michael@0 323 Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
michael@0 324 Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
michael@0 325 Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf");
michael@0 326
michael@0 327 let installsDone = promise_observer("TEST:all-updates-done");
michael@0 328
michael@0 329 // Don't pull compatibility data during add-on install
michael@0 330 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
michael@0 331 // Set up our test addons so that the server-side JS has a 500ms delay to make
michael@0 332 // sure we cancel the dialog before we get the data we want to refill our
michael@0 333 // AddonRepository cache
michael@0 334 let addonList = [ao5, ao8, ao9, ao10];
michael@0 335 yield promise_install_test_addons(addonList,
michael@0 336 TESTROOT + "cancelCompatCheck.sjs?500");
michael@0 337
michael@0 338 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
michael@0 339 Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_bug557956.xml");
michael@0 340
michael@0 341 let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]);
michael@0 342 ok(!a5.isCompatible, "addon5 should not be compatible");
michael@0 343 ok(!a8.isCompatible, "addon8 should not be compatible");
michael@0 344 ok(!a9.isCompatible, "addon9 should not be compatible");
michael@0 345
michael@0 346 let compatWindow = yield promise_open_compatibility_window([ao9.id, ...inactiveAddonIds]);
michael@0 347 var doc = compatWindow.document;
michael@0 348 yield promise_page(compatWindow, "versioninfo");
michael@0 349
michael@0 350 // Brief delay to let the update window finish requesting all add-ons and start
michael@0 351 // reloading the addon repository
michael@0 352 yield delayMS(50);
michael@0 353
michael@0 354 info("Cancel the compatibility check dialog");
michael@0 355 var button = doc.documentElement.getButton("cancel");
michael@0 356 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 357
michael@0 358 info("Waiting for installs to complete");
michael@0 359 yield installsDone;
michael@0 360 ok(!repo.AddonRepository.isSearching, "Background installs are done");
michael@0 361
michael@0 362 // There should be no active updates
michael@0 363 let getInstalls = Promise.defer();
michael@0 364 AddonManager.getAllInstalls(getInstalls.resolve);
michael@0 365 let installs = yield getInstalls.promise;
michael@0 366 is (installs.length, 0, "There should be no active installs after background installs are done");
michael@0 367
michael@0 368 // addon8 should have updated in the background,
michael@0 369 // addon9 was listed as previously disabled so it should not have updated
michael@0 370 let [a5, a8, a9, a10] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id, ao10.id]);
michael@0 371 ok(a5.isCompatible, "addon5 should be compatible");
michael@0 372 ok(a8.isCompatible, "addon8 should have been upgraded");
michael@0 373 ok(!a9.isCompatible, "addon9 should not have been upgraded");
michael@0 374 ok(!a10.isCompatible, "addon10 should not be compatible");
michael@0 375
michael@0 376 info("Updates done");
michael@0 377 yield promise_uninstall_test_addons();
michael@0 378 info("done uninstalling add-ons");
michael@0 379 });
michael@0 380
michael@0 381 // User cancels after repopulateCache, while we're waiting for the addon.findUpdates()
michael@0 382 // calls in gVersionInfoPage_onPageShow() to complete
michael@0 383 // For this test, both addon8 and addon9 were disabled by this update, but addon8
michael@0 384 // is set to not auto-update, so only addon9 should update in the background
michael@0 385 add_task(function cancel_during_findUpdates() {
michael@0 386 Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
michael@0 387 Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
michael@0 388
michael@0 389 let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated");
michael@0 390 let installsDone = promise_observer("TEST:all-updates-done");
michael@0 391
michael@0 392 // Don't pull compatibility data during add-on install
michael@0 393 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
michael@0 394 // No delay on the .sjs this time because we want the cache to repopulate
michael@0 395 let addonList = [ao3, ao5, ao6, ao7, ao8, ao9];
michael@0 396 yield promise_install_test_addons(addonList,
michael@0 397 TESTROOT + "cancelCompatCheck.sjs");
michael@0 398
michael@0 399 let [a8] = yield promise_addons_by_ids([ao8.id]);
michael@0 400 a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
michael@0 401
michael@0 402 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
michael@0 403 let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds);
michael@0 404 var doc = compatWindow.document;
michael@0 405 yield promise_page(compatWindow, "versioninfo");
michael@0 406
michael@0 407 info("Waiting for repository-data-updated");
michael@0 408 yield observeUpdateDone;
michael@0 409
michael@0 410 // Quick wait to make sure the findUpdates calls get queued
michael@0 411 yield delayMS(5);
michael@0 412
michael@0 413 info("Cancel the compatibility check dialog");
michael@0 414 var button = doc.documentElement.getButton("cancel");
michael@0 415 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 416
michael@0 417 info("Waiting for installs to complete 2");
michael@0 418 yield installsDone;
michael@0 419 ok(!repo.AddonRepository.isSearching, "Background installs are done 2");
michael@0 420
michael@0 421 // addon8 should have updated in the background,
michael@0 422 // addon9 was listed as previously disabled so it should not have updated
michael@0 423 let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]);
michael@0 424 ok(a5.isCompatible, "addon5 should be compatible");
michael@0 425 ok(!a8.isCompatible, "addon8 should not have been upgraded");
michael@0 426 ok(a9.isCompatible, "addon9 should have been upgraded");
michael@0 427
michael@0 428 let getInstalls = Promise.defer();
michael@0 429 AddonManager.getAllInstalls(getInstalls.resolve);
michael@0 430 let installs = yield getInstalls.promise;
michael@0 431 is (installs.length, 0, "There should be no active installs after the dialog is cancelled 2");
michael@0 432
michael@0 433 info("findUpdates done");
michael@0 434 yield promise_uninstall_test_addons();
michael@0 435 });
michael@0 436
michael@0 437 // Cancelling during the 'mismatch' screen allows add-ons that can auto-update
michael@0 438 // to continue updating in the background and cancels any other updates
michael@0 439 // Same conditions as the previous test - addon8 and addon9 have updates available,
michael@0 440 // addon8 is set to not auto-update so only addon9 should become compatible
michael@0 441 add_task(function cancel_mismatch() {
michael@0 442 Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
michael@0 443 Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
michael@0 444
michael@0 445 let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated");
michael@0 446 let installsDone = promise_observer("TEST:all-updates-done");
michael@0 447
michael@0 448 // Don't pull compatibility data during add-on install
michael@0 449 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
michael@0 450 // No delay on the .sjs this time because we want the cache to repopulate
michael@0 451 let addonList = [ao3, ao5, ao6, ao7, ao8, ao9];
michael@0 452 yield promise_install_test_addons(addonList,
michael@0 453 TESTROOT + "cancelCompatCheck.sjs");
michael@0 454
michael@0 455 let [a8] = yield promise_addons_by_ids([ao8.id]);
michael@0 456 a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
michael@0 457
michael@0 458 // Check that the addons start out not compatible.
michael@0 459 let [a3, a7, a8, a9] = yield promise_addons_by_ids([ao3.id, ao7.id, ao8.id, ao9.id]);
michael@0 460 ok(!a3.isCompatible, "addon3 should not be compatible");
michael@0 461 ok(!a7.isCompatible, "addon7 should not be compatible");
michael@0 462 ok(!a8.isCompatible, "addon8 should not be compatible");
michael@0 463 ok(!a9.isCompatible, "addon9 should not be compatible");
michael@0 464
michael@0 465 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
michael@0 466 let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds);
michael@0 467 var doc = compatWindow.document;
michael@0 468 info("Wait for mismatch page");
michael@0 469 yield promise_page(compatWindow, "mismatch");
michael@0 470 info("Click the Don't Check button");
michael@0 471 var button = doc.documentElement.getButton("cancel");
michael@0 472 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 473
michael@0 474 yield promise_window_close(compatWindow);
michael@0 475 info("Waiting for installs to complete in cancel_mismatch");
michael@0 476 yield installsDone;
michael@0 477
michael@0 478 // addon8 should not have updated in the background,
michael@0 479 // addon9 was listed as previously disabled so it should not have updated
michael@0 480 let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]);
michael@0 481 ok(a5.isCompatible, "addon5 should be compatible");
michael@0 482 ok(!a8.isCompatible, "addon8 should not have been upgraded");
michael@0 483 ok(a9.isCompatible, "addon9 should have been upgraded");
michael@0 484
michael@0 485 // Make sure there are no pending addon installs
michael@0 486 let pInstalls = Promise.defer();
michael@0 487 AddonManager.getAllInstalls(pInstalls.resolve);
michael@0 488 let installs = yield pInstalls.promise;
michael@0 489 ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")");
michael@0 490
michael@0 491 yield promise_uninstall_test_addons();
michael@0 492 yield check_addons_uninstalled(addonList);
michael@0 493 });
michael@0 494
michael@0 495 // Cancelling during the 'mismatch' screen with only add-ons that have
michael@0 496 // no updates available
michael@0 497 add_task(function cancel_mismatch_no_updates() {
michael@0 498 Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
michael@0 499 Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0");
michael@0 500
michael@0 501 let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated");
michael@0 502
michael@0 503 // Don't pull compatibility data during add-on install
michael@0 504 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false);
michael@0 505 // No delay on the .sjs this time because we want the cache to repopulate
michael@0 506 let addonList = [ao3, ao5, ao6];
michael@0 507 yield promise_install_test_addons(addonList,
michael@0 508 TESTROOT + "cancelCompatCheck.sjs");
michael@0 509
michael@0 510 // Check that the addons start out not compatible.
michael@0 511 let [a3, a5, a6] = yield promise_addons_by_ids([ao3.id, ao5.id, ao6.id]);
michael@0 512 ok(!a3.isCompatible, "addon3 should not be compatible");
michael@0 513 ok(!a5.isCompatible, "addon7 should not be compatible");
michael@0 514 ok(!a6.isCompatible, "addon8 should not be compatible");
michael@0 515
michael@0 516 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
michael@0 517 let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds);
michael@0 518 var doc = compatWindow.document;
michael@0 519 info("Wait for mismatch page");
michael@0 520 yield promise_page(compatWindow, "mismatch");
michael@0 521 info("Click the Don't Check button");
michael@0 522 var button = doc.documentElement.getButton("cancel");
michael@0 523 EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow);
michael@0 524
michael@0 525 yield promise_window_close(compatWindow);
michael@0 526
michael@0 527 let [a3, a5, a6] = yield promise_addons_by_ids([ao3.id, ao5.id, ao6.id]);
michael@0 528 ok(!a3.isCompatible, "addon3 should not be compatible");
michael@0 529 ok(a5.isCompatible, "addon5 should have become compatible");
michael@0 530 ok(a6.isCompatible, "addon6 should have become compatible");
michael@0 531
michael@0 532 // Make sure there are no pending addon installs
michael@0 533 let pInstalls = Promise.defer();
michael@0 534 AddonManager.getAllInstalls(pInstalls.resolve);
michael@0 535 let installs = yield pInstalls.promise;
michael@0 536 ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")");
michael@0 537
michael@0 538 yield promise_uninstall_test_addons();
michael@0 539 yield check_addons_uninstalled(addonList);
michael@0 540 });

mercurial