1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_cancelCompatCheck.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,540 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// Test that we can cancel the add-on compatibility check while it is 1.9 +// in progress (bug 772484). 1.10 +// Test framework copied from browser_bug557956.js 1.11 + 1.12 +const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul"; 1.13 + 1.14 +const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url"; 1.15 +const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion"; 1.16 + 1.17 +let repo = {}; 1.18 +Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", repo); 1.19 + 1.20 +/** 1.21 + * Test add-ons: 1.22 + * 1.23 + * Addon minVersion maxVersion Notes 1.24 + * addon1 0 * 1.25 + * addon2 0 0 1.26 + * addon3 0 0 1.27 + * addon4 1 * 1.28 + * addon5 0 0 Made compatible by update check 1.29 + * addon6 0 0 Made compatible by update check 1.30 + * addon7 0 0 Has a broken update available 1.31 + * addon8 0 0 Has an update available 1.32 + * addon9 0 0 Has an update available 1.33 + * addon10 0 0 Made incompatible by override check 1.34 + */ 1.35 + 1.36 +// describe the addons 1.37 +let ao1 = { file: "browser_bug557956_1", id: "addon1@tests.mozilla.org"}; 1.38 +let ao2 = { file: "browser_bug557956_2", id: "addon2@tests.mozilla.org"}; 1.39 +let ao3 = { file: "browser_bug557956_3", id: "addon3@tests.mozilla.org"}; 1.40 +let ao4 = { file: "browser_bug557956_4", id: "addon4@tests.mozilla.org"}; 1.41 +let ao5 = { file: "browser_bug557956_5", id: "addon5@tests.mozilla.org"}; 1.42 +let ao6 = { file: "browser_bug557956_6", id: "addon6@tests.mozilla.org"}; 1.43 +let ao7 = { file: "browser_bug557956_7", id: "addon7@tests.mozilla.org"}; 1.44 +let ao8 = { file: "browser_bug557956_8_1", id: "addon8@tests.mozilla.org"}; 1.45 +let ao9 = { file: "browser_bug557956_9_1", id: "addon9@tests.mozilla.org"}; 1.46 +let ao10 = { file: "browser_bug557956_10", id: "addon10@tests.mozilla.org"}; 1.47 + 1.48 +// Return a promise that resolves after the specified delay in MS 1.49 +function delayMS(aDelay) { 1.50 + let deferred = Promise.defer(); 1.51 + setTimeout(deferred.resolve, aDelay); 1.52 + return deferred.promise; 1.53 +} 1.54 + 1.55 +// Return a promise that resolves when the specified observer topic is notified 1.56 +function promise_observer(aTopic) { 1.57 + let deferred = Promise.defer(); 1.58 + Services.obs.addObserver(function observe(aSubject, aObsTopic, aData) { 1.59 + Services.obs.removeObserver(arguments.callee, aObsTopic); 1.60 + deferred.resolve([aSubject, aData]); 1.61 + }, aTopic, false); 1.62 + return deferred.promise; 1.63 +} 1.64 + 1.65 +// Install a set of addons using a bogus update URL so that we can force 1.66 +// the compatibility update to happen later 1.67 +// @param aUpdateURL The real update URL to use after the add-ons are installed 1.68 +function promise_install_test_addons(aAddonList, aUpdateURL) { 1.69 + info("Starting add-on installs"); 1.70 + var installs = []; 1.71 + let deferred = Promise.defer(); 1.72 + 1.73 + // Use a blank update URL 1.74 + Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); 1.75 + 1.76 + for (let addon of aAddonList) { 1.77 + AddonManager.getInstallForURL(TESTROOT + "addons/" + addon.file + ".xpi", function(aInstall) { 1.78 + installs.push(aInstall); 1.79 + }, "application/x-xpinstall"); 1.80 + } 1.81 + 1.82 + var listener = { 1.83 + installCount: 0, 1.84 + 1.85 + onInstallEnded: function() { 1.86 + this.installCount++; 1.87 + if (this.installCount == installs.length) { 1.88 + info("Done add-on installs"); 1.89 + // Switch to the test update URL 1.90 + Services.prefs.setCharPref(PREF_UPDATEURL, aUpdateURL); 1.91 + deferred.resolve(); 1.92 + } 1.93 + } 1.94 + }; 1.95 + 1.96 + for (let install of installs) { 1.97 + install.addListener(listener); 1.98 + install.install(); 1.99 + } 1.100 + 1.101 + return deferred.promise; 1.102 +} 1.103 + 1.104 +function promise_addons_by_ids(aAddonIDs) { 1.105 + info("promise_addons_by_ids " + aAddonIDs.toSource()); 1.106 + let deferred = Promise.defer(); 1.107 + AddonManager.getAddonsByIDs(aAddonIDs, deferred.resolve); 1.108 + return deferred.promise; 1.109 +} 1.110 + 1.111 +function* promise_uninstall_test_addons() { 1.112 + info("Starting add-on uninstalls"); 1.113 + let addons = yield promise_addons_by_ids([ao1.id, ao2.id, ao3.id, ao4.id, ao5.id, 1.114 + ao6.id, ao7.id, ao8.id, ao9.id, ao10.id]); 1.115 + let deferred = Promise.defer(); 1.116 + let uninstallCount = addons.length; 1.117 + let listener = { 1.118 + onUninstalled: function(aAddon) { 1.119 + if (aAddon) { 1.120 + info("Finished uninstalling " + aAddon.id); 1.121 + } 1.122 + if (--uninstallCount == 0) { 1.123 + info("Done add-on uninstalls"); 1.124 + AddonManager.removeAddonListener(listener); 1.125 + deferred.resolve(); 1.126 + } 1.127 + }}; 1.128 + AddonManager.addAddonListener(listener); 1.129 + for (let addon of addons) { 1.130 + if (addon) 1.131 + addon.uninstall(); 1.132 + else 1.133 + listener.onUninstalled(null); 1.134 + } 1.135 + yield deferred.promise; 1.136 +} 1.137 + 1.138 +// Returns promise{window}, resolves with a handle to the compatibility 1.139 +// check window 1.140 +function promise_open_compatibility_window(aInactiveAddonIds) { 1.141 + let deferred = Promise.defer(); 1.142 + // This will reset the longer timeout multiplier to 2 which will give each 1.143 + // test that calls open_compatibility_window a minimum of 60 seconds to 1.144 + // complete. 1.145 + requestLongerTimeout(100 /* XXX was 2 */); 1.146 + 1.147 + var variant = Cc["@mozilla.org/variant;1"]. 1.148 + createInstance(Ci.nsIWritableVariant); 1.149 + variant.setFromVariant(aInactiveAddonIds); 1.150 + 1.151 + // Cannot be modal as we want to interract with it, shouldn't cause problems 1.152 + // with testing though. 1.153 + var features = "chrome,centerscreen,dialog,titlebar"; 1.154 + var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. 1.155 + getService(Ci.nsIWindowWatcher); 1.156 + var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant); 1.157 + 1.158 + win.addEventListener("load", function() { 1.159 + function page_shown(aEvent) { 1.160 + if (aEvent.target.pageid) 1.161 + info("Page " + aEvent.target.pageid + " shown"); 1.162 + } 1.163 + 1.164 + win.removeEventListener("load", arguments.callee, false); 1.165 + 1.166 + info("Compatibility dialog opened"); 1.167 + 1.168 + win.addEventListener("pageshow", page_shown, false); 1.169 + win.addEventListener("unload", function() { 1.170 + win.removeEventListener("unload", arguments.callee, false); 1.171 + win.removeEventListener("pageshow", page_shown, false); 1.172 + dump("Compatibility dialog closed\n"); 1.173 + }, false); 1.174 + 1.175 + deferred.resolve(win); 1.176 + }, false); 1.177 + return deferred.promise; 1.178 +} 1.179 + 1.180 +function promise_window_close(aWindow) { 1.181 + let deferred = Promise.defer(); 1.182 + aWindow.addEventListener("unload", function() { 1.183 + aWindow.removeEventListener("unload", arguments.callee, false); 1.184 + deferred.resolve(aWindow); 1.185 + }, false); 1.186 + return deferred.promise; 1.187 +} 1.188 + 1.189 +function promise_page(aWindow, aPageId) { 1.190 + let deferred = Promise.defer(); 1.191 + var page = aWindow.document.getElementById(aPageId); 1.192 + if (aWindow.document.getElementById("updateWizard").currentPage === page) { 1.193 + deferred.resolve(aWindow); 1.194 + } else { 1.195 + page.addEventListener("pageshow", function() { 1.196 + page.removeEventListener("pageshow", arguments.callee, false); 1.197 + executeSoon(function() { 1.198 + deferred.resolve(aWindow); 1.199 + }); 1.200 + }, false); 1.201 + } 1.202 + return deferred.promise; 1.203 +} 1.204 + 1.205 +function get_list_names(aList) { 1.206 + var items = []; 1.207 + for (let listItem of aList.childNodes) 1.208 + items.push(listItem.label); 1.209 + items.sort(); 1.210 + return items; 1.211 +} 1.212 + 1.213 +// These add-ons were inactive in the old application 1.214 +let inactiveAddonIds = [ 1.215 + ao2.id, 1.216 + ao4.id, 1.217 + ao5.id, 1.218 + ao10.id 1.219 +]; 1.220 + 1.221 +// Make sure the addons in the list are not installed 1.222 +function* check_addons_uninstalled(aAddonList) { 1.223 + let foundList = yield promise_addons_by_ids([addon.id for (addon of aAddonList)]); 1.224 + for (let i = 0; i < aAddonList.length; i++) { 1.225 + ok(!foundList[i], "Addon " + aAddonList[i].id + " is not installed"); 1.226 + } 1.227 + info("Add-on uninstall check complete"); 1.228 + yield true; 1.229 +} 1.230 + 1.231 + 1.232 +// Tests that the right add-ons show up in the mismatch dialog and updates can 1.233 +// be installed 1.234 +// This is a task-based rewrite of the first test in browser_bug557956.js 1.235 +// kept here to show the whole process so that other tests in this file can 1.236 +// pick and choose which steps to perform, but disabled since the logic is already 1.237 +// tested in browser_bug557956.js. 1.238 +// add_task( 1.239 + function start_update() { 1.240 + // Don't pull compatibility data during add-on install 1.241 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); 1.242 + let addonList = [ao3, ao5, ao6, ao7, ao8, ao9]; 1.243 + yield promise_install_test_addons(addonList, TESTROOT + "cancelCompatCheck.sjs"); 1.244 + 1.245 + 1.246 + // Check that the addons start out not compatible. 1.247 + let [a5, a6, a8, a9] = yield promise_addons_by_ids([ao5.id, ao6.id, ao8.id, ao9.id]); 1.248 + ok(!a5.isCompatible, "addon5 should not be compatible"); 1.249 + ok(!a6.isCompatible, "addon6 should not be compatible"); 1.250 + ok(!a8.isCompatible, "addon8 should not be compatible"); 1.251 + ok(!a9.isCompatible, "addon9 should not be compatible"); 1.252 + 1.253 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); 1.254 + // Check that opening the compatibility window loads and applies 1.255 + // the compatibility update 1.256 + let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); 1.257 + var doc = compatWindow.document; 1.258 + compatWindow = yield promise_page(compatWindow, "mismatch"); 1.259 + var items = get_list_names(doc.getElementById("mismatch.incompatible")); 1.260 + is(items.length, 4, "Should have seen 4 still incompatible items"); 1.261 + is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible"); 1.262 + is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible"); 1.263 + is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible"); 1.264 + is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible"); 1.265 + 1.266 + ok(a5.isCompatible, "addon5 should be compatible"); 1.267 + ok(a6.isCompatible, "addon6 should be compatible"); 1.268 + 1.269 + // Click next to start finding updates for the addons that are still incompatible 1.270 + var button = doc.documentElement.getButton("next"); 1.271 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.272 + 1.273 + compatWindow = yield promise_page(compatWindow, "found"); 1.274 + ok(doc.getElementById("xpinstallDisabledAlert").hidden, 1.275 + "Install should be allowed"); 1.276 + 1.277 + var list = doc.getElementById("found.updates"); 1.278 + var items = get_list_names(list); 1.279 + is(items.length, 3, "Should have seen 3 updates available"); 1.280 + is(items[0], "Addon7 2.0", "Should have seen update for addon7"); 1.281 + is(items[1], "Addon8 2.0", "Should have seen update for addon8"); 1.282 + is(items[2], "Addon9 2.0", "Should have seen update for addon9"); 1.283 + 1.284 + ok(!doc.documentElement.getButton("next").disabled, 1.285 + "Next button should be enabled"); 1.286 + 1.287 + // Uncheck all 1.288 + for (let listItem of list.childNodes) 1.289 + EventUtils.synthesizeMouse(listItem, 2, 2, { }, compatWindow); 1.290 + 1.291 + ok(doc.documentElement.getButton("next").disabled, 1.292 + "Next button should not be enabled"); 1.293 + 1.294 + // Check the ones we want to install 1.295 + for (let listItem of list.childNodes) { 1.296 + if (listItem.label != "Addon7 2.0") 1.297 + EventUtils.synthesizeMouse(listItem, 2, 2, { }, compatWindow); 1.298 + } 1.299 + 1.300 + var button = doc.documentElement.getButton("next"); 1.301 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.302 + 1.303 + compatWindow = yield promise_page(compatWindow, "finished"); 1.304 + var button = doc.documentElement.getButton("finish"); 1.305 + ok(!button.hidden, "Finish button should not be hidden"); 1.306 + ok(!button.disabled, "Finish button should not be disabled"); 1.307 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.308 + 1.309 + compatWindow = yield promise_window_close(compatWindow); 1.310 + 1.311 + // Check that the appropriate add-ons have been updated 1.312 + let [a8, a9] = yield promise_addons_by_ids(["addon8@tests.mozilla.org", 1.313 + "addon9@tests.mozilla.org"]); 1.314 + is(a8.version, "2.0", "addon8 should have updated"); 1.315 + is(a9.version, "2.0", "addon9 should have updated"); 1.316 + 1.317 + yield promise_uninstall_test_addons(); 1.318 +} 1.319 +// ); 1.320 + 1.321 +// Test what happens when the user cancels during AddonRepository.repopulateCache() 1.322 +// Add-ons that have updates available should not update if they were disabled before 1.323 +// For this test, addon8 became disabled during update and addon9 was previously disabled, 1.324 +// so addon8 should update and addon9 should not 1.325 +add_task(function cancel_during_repopulate() { 1.326 + Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); 1.327 + Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); 1.328 + Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); 1.329 + 1.330 + let installsDone = promise_observer("TEST:all-updates-done"); 1.331 + 1.332 + // Don't pull compatibility data during add-on install 1.333 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); 1.334 + // Set up our test addons so that the server-side JS has a 500ms delay to make 1.335 + // sure we cancel the dialog before we get the data we want to refill our 1.336 + // AddonRepository cache 1.337 + let addonList = [ao5, ao8, ao9, ao10]; 1.338 + yield promise_install_test_addons(addonList, 1.339 + TESTROOT + "cancelCompatCheck.sjs?500"); 1.340 + 1.341 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); 1.342 + Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_bug557956.xml"); 1.343 + 1.344 + let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]); 1.345 + ok(!a5.isCompatible, "addon5 should not be compatible"); 1.346 + ok(!a8.isCompatible, "addon8 should not be compatible"); 1.347 + ok(!a9.isCompatible, "addon9 should not be compatible"); 1.348 + 1.349 + let compatWindow = yield promise_open_compatibility_window([ao9.id, ...inactiveAddonIds]); 1.350 + var doc = compatWindow.document; 1.351 + yield promise_page(compatWindow, "versioninfo"); 1.352 + 1.353 + // Brief delay to let the update window finish requesting all add-ons and start 1.354 + // reloading the addon repository 1.355 + yield delayMS(50); 1.356 + 1.357 + info("Cancel the compatibility check dialog"); 1.358 + var button = doc.documentElement.getButton("cancel"); 1.359 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.360 + 1.361 + info("Waiting for installs to complete"); 1.362 + yield installsDone; 1.363 + ok(!repo.AddonRepository.isSearching, "Background installs are done"); 1.364 + 1.365 + // There should be no active updates 1.366 + let getInstalls = Promise.defer(); 1.367 + AddonManager.getAllInstalls(getInstalls.resolve); 1.368 + let installs = yield getInstalls.promise; 1.369 + is (installs.length, 0, "There should be no active installs after background installs are done"); 1.370 + 1.371 + // addon8 should have updated in the background, 1.372 + // addon9 was listed as previously disabled so it should not have updated 1.373 + let [a5, a8, a9, a10] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id, ao10.id]); 1.374 + ok(a5.isCompatible, "addon5 should be compatible"); 1.375 + ok(a8.isCompatible, "addon8 should have been upgraded"); 1.376 + ok(!a9.isCompatible, "addon9 should not have been upgraded"); 1.377 + ok(!a10.isCompatible, "addon10 should not be compatible"); 1.378 + 1.379 + info("Updates done"); 1.380 + yield promise_uninstall_test_addons(); 1.381 + info("done uninstalling add-ons"); 1.382 +}); 1.383 + 1.384 +// User cancels after repopulateCache, while we're waiting for the addon.findUpdates() 1.385 +// calls in gVersionInfoPage_onPageShow() to complete 1.386 +// For this test, both addon8 and addon9 were disabled by this update, but addon8 1.387 +// is set to not auto-update, so only addon9 should update in the background 1.388 +add_task(function cancel_during_findUpdates() { 1.389 + Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); 1.390 + Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); 1.391 + 1.392 + let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated"); 1.393 + let installsDone = promise_observer("TEST:all-updates-done"); 1.394 + 1.395 + // Don't pull compatibility data during add-on install 1.396 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); 1.397 + // No delay on the .sjs this time because we want the cache to repopulate 1.398 + let addonList = [ao3, ao5, ao6, ao7, ao8, ao9]; 1.399 + yield promise_install_test_addons(addonList, 1.400 + TESTROOT + "cancelCompatCheck.sjs"); 1.401 + 1.402 + let [a8] = yield promise_addons_by_ids([ao8.id]); 1.403 + a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; 1.404 + 1.405 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); 1.406 + let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); 1.407 + var doc = compatWindow.document; 1.408 + yield promise_page(compatWindow, "versioninfo"); 1.409 + 1.410 + info("Waiting for repository-data-updated"); 1.411 + yield observeUpdateDone; 1.412 + 1.413 + // Quick wait to make sure the findUpdates calls get queued 1.414 + yield delayMS(5); 1.415 + 1.416 + info("Cancel the compatibility check dialog"); 1.417 + var button = doc.documentElement.getButton("cancel"); 1.418 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.419 + 1.420 + info("Waiting for installs to complete 2"); 1.421 + yield installsDone; 1.422 + ok(!repo.AddonRepository.isSearching, "Background installs are done 2"); 1.423 + 1.424 + // addon8 should have updated in the background, 1.425 + // addon9 was listed as previously disabled so it should not have updated 1.426 + let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]); 1.427 + ok(a5.isCompatible, "addon5 should be compatible"); 1.428 + ok(!a8.isCompatible, "addon8 should not have been upgraded"); 1.429 + ok(a9.isCompatible, "addon9 should have been upgraded"); 1.430 + 1.431 + let getInstalls = Promise.defer(); 1.432 + AddonManager.getAllInstalls(getInstalls.resolve); 1.433 + let installs = yield getInstalls.promise; 1.434 + is (installs.length, 0, "There should be no active installs after the dialog is cancelled 2"); 1.435 + 1.436 + info("findUpdates done"); 1.437 + yield promise_uninstall_test_addons(); 1.438 +}); 1.439 + 1.440 +// Cancelling during the 'mismatch' screen allows add-ons that can auto-update 1.441 +// to continue updating in the background and cancels any other updates 1.442 +// Same conditions as the previous test - addon8 and addon9 have updates available, 1.443 +// addon8 is set to not auto-update so only addon9 should become compatible 1.444 +add_task(function cancel_mismatch() { 1.445 + Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); 1.446 + Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); 1.447 + 1.448 + let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated"); 1.449 + let installsDone = promise_observer("TEST:all-updates-done"); 1.450 + 1.451 + // Don't pull compatibility data during add-on install 1.452 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); 1.453 + // No delay on the .sjs this time because we want the cache to repopulate 1.454 + let addonList = [ao3, ao5, ao6, ao7, ao8, ao9]; 1.455 + yield promise_install_test_addons(addonList, 1.456 + TESTROOT + "cancelCompatCheck.sjs"); 1.457 + 1.458 + let [a8] = yield promise_addons_by_ids([ao8.id]); 1.459 + a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; 1.460 + 1.461 + // Check that the addons start out not compatible. 1.462 + let [a3, a7, a8, a9] = yield promise_addons_by_ids([ao3.id, ao7.id, ao8.id, ao9.id]); 1.463 + ok(!a3.isCompatible, "addon3 should not be compatible"); 1.464 + ok(!a7.isCompatible, "addon7 should not be compatible"); 1.465 + ok(!a8.isCompatible, "addon8 should not be compatible"); 1.466 + ok(!a9.isCompatible, "addon9 should not be compatible"); 1.467 + 1.468 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); 1.469 + let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); 1.470 + var doc = compatWindow.document; 1.471 + info("Wait for mismatch page"); 1.472 + yield promise_page(compatWindow, "mismatch"); 1.473 + info("Click the Don't Check button"); 1.474 + var button = doc.documentElement.getButton("cancel"); 1.475 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.476 + 1.477 + yield promise_window_close(compatWindow); 1.478 + info("Waiting for installs to complete in cancel_mismatch"); 1.479 + yield installsDone; 1.480 + 1.481 + // addon8 should not have updated in the background, 1.482 + // addon9 was listed as previously disabled so it should not have updated 1.483 + let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]); 1.484 + ok(a5.isCompatible, "addon5 should be compatible"); 1.485 + ok(!a8.isCompatible, "addon8 should not have been upgraded"); 1.486 + ok(a9.isCompatible, "addon9 should have been upgraded"); 1.487 + 1.488 + // Make sure there are no pending addon installs 1.489 + let pInstalls = Promise.defer(); 1.490 + AddonManager.getAllInstalls(pInstalls.resolve); 1.491 + let installs = yield pInstalls.promise; 1.492 + ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")"); 1.493 + 1.494 + yield promise_uninstall_test_addons(); 1.495 + yield check_addons_uninstalled(addonList); 1.496 +}); 1.497 + 1.498 +// Cancelling during the 'mismatch' screen with only add-ons that have 1.499 +// no updates available 1.500 +add_task(function cancel_mismatch_no_updates() { 1.501 + Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); 1.502 + Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); 1.503 + 1.504 + let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated"); 1.505 + 1.506 + // Don't pull compatibility data during add-on install 1.507 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); 1.508 + // No delay on the .sjs this time because we want the cache to repopulate 1.509 + let addonList = [ao3, ao5, ao6]; 1.510 + yield promise_install_test_addons(addonList, 1.511 + TESTROOT + "cancelCompatCheck.sjs"); 1.512 + 1.513 + // Check that the addons start out not compatible. 1.514 + let [a3, a5, a6] = yield promise_addons_by_ids([ao3.id, ao5.id, ao6.id]); 1.515 + ok(!a3.isCompatible, "addon3 should not be compatible"); 1.516 + ok(!a5.isCompatible, "addon7 should not be compatible"); 1.517 + ok(!a6.isCompatible, "addon8 should not be compatible"); 1.518 + 1.519 + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); 1.520 + let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); 1.521 + var doc = compatWindow.document; 1.522 + info("Wait for mismatch page"); 1.523 + yield promise_page(compatWindow, "mismatch"); 1.524 + info("Click the Don't Check button"); 1.525 + var button = doc.documentElement.getButton("cancel"); 1.526 + EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); 1.527 + 1.528 + yield promise_window_close(compatWindow); 1.529 + 1.530 + let [a3, a5, a6] = yield promise_addons_by_ids([ao3.id, ao5.id, ao6.id]); 1.531 + ok(!a3.isCompatible, "addon3 should not be compatible"); 1.532 + ok(a5.isCompatible, "addon5 should have become compatible"); 1.533 + ok(a6.isCompatible, "addon6 should have become compatible"); 1.534 + 1.535 + // Make sure there are no pending addon installs 1.536 + let pInstalls = Promise.defer(); 1.537 + AddonManager.getAllInstalls(pInstalls.resolve); 1.538 + let installs = yield pInstalls.promise; 1.539 + ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")"); 1.540 + 1.541 + yield promise_uninstall_test_addons(); 1.542 + yield check_addons_uninstalled(addonList); 1.543 +});