michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Test that we can cancel the add-on compatibility check while it is michael@0: // in progress (bug 772484). michael@0: // Test framework copied from browser_bug557956.js michael@0: michael@0: const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul"; michael@0: michael@0: const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url"; michael@0: const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion"; michael@0: michael@0: let repo = {}; michael@0: Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", repo); michael@0: michael@0: /** michael@0: * Test add-ons: michael@0: * michael@0: * Addon minVersion maxVersion Notes michael@0: * addon1 0 * michael@0: * addon2 0 0 michael@0: * addon3 0 0 michael@0: * addon4 1 * michael@0: * addon5 0 0 Made compatible by update check michael@0: * addon6 0 0 Made compatible by update check michael@0: * addon7 0 0 Has a broken update available michael@0: * addon8 0 0 Has an update available michael@0: * addon9 0 0 Has an update available michael@0: * addon10 0 0 Made incompatible by override check michael@0: */ michael@0: michael@0: // describe the addons michael@0: let ao1 = { file: "browser_bug557956_1", id: "addon1@tests.mozilla.org"}; michael@0: let ao2 = { file: "browser_bug557956_2", id: "addon2@tests.mozilla.org"}; michael@0: let ao3 = { file: "browser_bug557956_3", id: "addon3@tests.mozilla.org"}; michael@0: let ao4 = { file: "browser_bug557956_4", id: "addon4@tests.mozilla.org"}; michael@0: let ao5 = { file: "browser_bug557956_5", id: "addon5@tests.mozilla.org"}; michael@0: let ao6 = { file: "browser_bug557956_6", id: "addon6@tests.mozilla.org"}; michael@0: let ao7 = { file: "browser_bug557956_7", id: "addon7@tests.mozilla.org"}; michael@0: let ao8 = { file: "browser_bug557956_8_1", id: "addon8@tests.mozilla.org"}; michael@0: let ao9 = { file: "browser_bug557956_9_1", id: "addon9@tests.mozilla.org"}; michael@0: let ao10 = { file: "browser_bug557956_10", id: "addon10@tests.mozilla.org"}; michael@0: michael@0: // Return a promise that resolves after the specified delay in MS michael@0: function delayMS(aDelay) { michael@0: let deferred = Promise.defer(); michael@0: setTimeout(deferred.resolve, aDelay); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: // Return a promise that resolves when the specified observer topic is notified michael@0: function promise_observer(aTopic) { michael@0: let deferred = Promise.defer(); michael@0: Services.obs.addObserver(function observe(aSubject, aObsTopic, aData) { michael@0: Services.obs.removeObserver(arguments.callee, aObsTopic); michael@0: deferred.resolve([aSubject, aData]); michael@0: }, aTopic, false); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: // Install a set of addons using a bogus update URL so that we can force michael@0: // the compatibility update to happen later michael@0: // @param aUpdateURL The real update URL to use after the add-ons are installed michael@0: function promise_install_test_addons(aAddonList, aUpdateURL) { michael@0: info("Starting add-on installs"); michael@0: var installs = []; michael@0: let deferred = Promise.defer(); michael@0: michael@0: // Use a blank update URL michael@0: Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); michael@0: michael@0: for (let addon of aAddonList) { michael@0: AddonManager.getInstallForURL(TESTROOT + "addons/" + addon.file + ".xpi", function(aInstall) { michael@0: installs.push(aInstall); michael@0: }, "application/x-xpinstall"); michael@0: } michael@0: michael@0: var listener = { michael@0: installCount: 0, michael@0: michael@0: onInstallEnded: function() { michael@0: this.installCount++; michael@0: if (this.installCount == installs.length) { michael@0: info("Done add-on installs"); michael@0: // Switch to the test update URL michael@0: Services.prefs.setCharPref(PREF_UPDATEURL, aUpdateURL); michael@0: deferred.resolve(); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: for (let install of installs) { michael@0: install.addListener(listener); michael@0: install.install(); michael@0: } michael@0: michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function promise_addons_by_ids(aAddonIDs) { michael@0: info("promise_addons_by_ids " + aAddonIDs.toSource()); michael@0: let deferred = Promise.defer(); michael@0: AddonManager.getAddonsByIDs(aAddonIDs, deferred.resolve); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function* promise_uninstall_test_addons() { michael@0: info("Starting add-on uninstalls"); michael@0: let addons = yield promise_addons_by_ids([ao1.id, ao2.id, ao3.id, ao4.id, ao5.id, michael@0: ao6.id, ao7.id, ao8.id, ao9.id, ao10.id]); michael@0: let deferred = Promise.defer(); michael@0: let uninstallCount = addons.length; michael@0: let listener = { michael@0: onUninstalled: function(aAddon) { michael@0: if (aAddon) { michael@0: info("Finished uninstalling " + aAddon.id); michael@0: } michael@0: if (--uninstallCount == 0) { michael@0: info("Done add-on uninstalls"); michael@0: AddonManager.removeAddonListener(listener); michael@0: deferred.resolve(); michael@0: } michael@0: }}; michael@0: AddonManager.addAddonListener(listener); michael@0: for (let addon of addons) { michael@0: if (addon) michael@0: addon.uninstall(); michael@0: else michael@0: listener.onUninstalled(null); michael@0: } michael@0: yield deferred.promise; michael@0: } michael@0: michael@0: // Returns promise{window}, resolves with a handle to the compatibility michael@0: // check window michael@0: function promise_open_compatibility_window(aInactiveAddonIds) { michael@0: let deferred = Promise.defer(); michael@0: // This will reset the longer timeout multiplier to 2 which will give each michael@0: // test that calls open_compatibility_window a minimum of 60 seconds to michael@0: // complete. michael@0: requestLongerTimeout(100 /* XXX was 2 */); michael@0: michael@0: var variant = Cc["@mozilla.org/variant;1"]. michael@0: createInstance(Ci.nsIWritableVariant); michael@0: variant.setFromVariant(aInactiveAddonIds); michael@0: michael@0: // Cannot be modal as we want to interract with it, shouldn't cause problems michael@0: // with testing though. michael@0: var features = "chrome,centerscreen,dialog,titlebar"; michael@0: var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. michael@0: getService(Ci.nsIWindowWatcher); michael@0: var win = ww.openWindow(null, URI_EXTENSION_UPDATE_DIALOG, "", features, variant); michael@0: michael@0: win.addEventListener("load", function() { michael@0: function page_shown(aEvent) { michael@0: if (aEvent.target.pageid) michael@0: info("Page " + aEvent.target.pageid + " shown"); michael@0: } michael@0: michael@0: win.removeEventListener("load", arguments.callee, false); michael@0: michael@0: info("Compatibility dialog opened"); michael@0: michael@0: win.addEventListener("pageshow", page_shown, false); michael@0: win.addEventListener("unload", function() { michael@0: win.removeEventListener("unload", arguments.callee, false); michael@0: win.removeEventListener("pageshow", page_shown, false); michael@0: dump("Compatibility dialog closed\n"); michael@0: }, false); michael@0: michael@0: deferred.resolve(win); michael@0: }, false); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function promise_window_close(aWindow) { michael@0: let deferred = Promise.defer(); michael@0: aWindow.addEventListener("unload", function() { michael@0: aWindow.removeEventListener("unload", arguments.callee, false); michael@0: deferred.resolve(aWindow); michael@0: }, false); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function promise_page(aWindow, aPageId) { michael@0: let deferred = Promise.defer(); michael@0: var page = aWindow.document.getElementById(aPageId); michael@0: if (aWindow.document.getElementById("updateWizard").currentPage === page) { michael@0: deferred.resolve(aWindow); michael@0: } else { michael@0: page.addEventListener("pageshow", function() { michael@0: page.removeEventListener("pageshow", arguments.callee, false); michael@0: executeSoon(function() { michael@0: deferred.resolve(aWindow); michael@0: }); michael@0: }, false); michael@0: } michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function get_list_names(aList) { michael@0: var items = []; michael@0: for (let listItem of aList.childNodes) michael@0: items.push(listItem.label); michael@0: items.sort(); michael@0: return items; michael@0: } michael@0: michael@0: // These add-ons were inactive in the old application michael@0: let inactiveAddonIds = [ michael@0: ao2.id, michael@0: ao4.id, michael@0: ao5.id, michael@0: ao10.id michael@0: ]; michael@0: michael@0: // Make sure the addons in the list are not installed michael@0: function* check_addons_uninstalled(aAddonList) { michael@0: let foundList = yield promise_addons_by_ids([addon.id for (addon of aAddonList)]); michael@0: for (let i = 0; i < aAddonList.length; i++) { michael@0: ok(!foundList[i], "Addon " + aAddonList[i].id + " is not installed"); michael@0: } michael@0: info("Add-on uninstall check complete"); michael@0: yield true; michael@0: } michael@0: michael@0: michael@0: // Tests that the right add-ons show up in the mismatch dialog and updates can michael@0: // be installed michael@0: // This is a task-based rewrite of the first test in browser_bug557956.js michael@0: // kept here to show the whole process so that other tests in this file can michael@0: // pick and choose which steps to perform, but disabled since the logic is already michael@0: // tested in browser_bug557956.js. michael@0: // add_task( michael@0: function start_update() { michael@0: // Don't pull compatibility data during add-on install michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); michael@0: let addonList = [ao3, ao5, ao6, ao7, ao8, ao9]; michael@0: yield promise_install_test_addons(addonList, TESTROOT + "cancelCompatCheck.sjs"); michael@0: michael@0: michael@0: // Check that the addons start out not compatible. michael@0: let [a5, a6, a8, a9] = yield promise_addons_by_ids([ao5.id, ao6.id, ao8.id, ao9.id]); michael@0: ok(!a5.isCompatible, "addon5 should not be compatible"); michael@0: ok(!a6.isCompatible, "addon6 should not be compatible"); michael@0: ok(!a8.isCompatible, "addon8 should not be compatible"); michael@0: ok(!a9.isCompatible, "addon9 should not be compatible"); michael@0: michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: // Check that opening the compatibility window loads and applies michael@0: // the compatibility update michael@0: let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); michael@0: var doc = compatWindow.document; michael@0: compatWindow = yield promise_page(compatWindow, "mismatch"); michael@0: var items = get_list_names(doc.getElementById("mismatch.incompatible")); michael@0: is(items.length, 4, "Should have seen 4 still incompatible items"); michael@0: is(items[0], "Addon3 1.0", "Should have seen addon3 still incompatible"); michael@0: is(items[1], "Addon7 1.0", "Should have seen addon7 still incompatible"); michael@0: is(items[2], "Addon8 1.0", "Should have seen addon8 still incompatible"); michael@0: is(items[3], "Addon9 1.0", "Should have seen addon9 still incompatible"); michael@0: michael@0: ok(a5.isCompatible, "addon5 should be compatible"); michael@0: ok(a6.isCompatible, "addon6 should be compatible"); michael@0: michael@0: // Click next to start finding updates for the addons that are still incompatible michael@0: var button = doc.documentElement.getButton("next"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: compatWindow = yield promise_page(compatWindow, "found"); michael@0: ok(doc.getElementById("xpinstallDisabledAlert").hidden, michael@0: "Install should be allowed"); michael@0: michael@0: var list = doc.getElementById("found.updates"); michael@0: var items = get_list_names(list); michael@0: is(items.length, 3, "Should have seen 3 updates available"); michael@0: is(items[0], "Addon7 2.0", "Should have seen update for addon7"); michael@0: is(items[1], "Addon8 2.0", "Should have seen update for addon8"); michael@0: is(items[2], "Addon9 2.0", "Should have seen update for addon9"); michael@0: michael@0: ok(!doc.documentElement.getButton("next").disabled, michael@0: "Next button should be enabled"); michael@0: michael@0: // Uncheck all michael@0: for (let listItem of list.childNodes) michael@0: EventUtils.synthesizeMouse(listItem, 2, 2, { }, compatWindow); michael@0: michael@0: ok(doc.documentElement.getButton("next").disabled, michael@0: "Next button should not be enabled"); michael@0: michael@0: // Check the ones we want to install michael@0: for (let listItem of list.childNodes) { michael@0: if (listItem.label != "Addon7 2.0") michael@0: EventUtils.synthesizeMouse(listItem, 2, 2, { }, compatWindow); michael@0: } michael@0: michael@0: var button = doc.documentElement.getButton("next"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: compatWindow = yield promise_page(compatWindow, "finished"); michael@0: var button = doc.documentElement.getButton("finish"); michael@0: ok(!button.hidden, "Finish button should not be hidden"); michael@0: ok(!button.disabled, "Finish button should not be disabled"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: compatWindow = yield promise_window_close(compatWindow); michael@0: michael@0: // Check that the appropriate add-ons have been updated michael@0: let [a8, a9] = yield promise_addons_by_ids(["addon8@tests.mozilla.org", michael@0: "addon9@tests.mozilla.org"]); michael@0: is(a8.version, "2.0", "addon8 should have updated"); michael@0: is(a9.version, "2.0", "addon9 should have updated"); michael@0: michael@0: yield promise_uninstall_test_addons(); michael@0: } michael@0: // ); michael@0: michael@0: // Test what happens when the user cancels during AddonRepository.repopulateCache() michael@0: // Add-ons that have updates available should not update if they were disabled before michael@0: // For this test, addon8 became disabled during update and addon9 was previously disabled, michael@0: // so addon8 should update and addon9 should not michael@0: add_task(function cancel_during_repopulate() { michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); michael@0: Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); michael@0: Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); michael@0: michael@0: let installsDone = promise_observer("TEST:all-updates-done"); michael@0: michael@0: // Don't pull compatibility data during add-on install michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); michael@0: // Set up our test addons so that the server-side JS has a 500ms delay to make michael@0: // sure we cancel the dialog before we get the data we want to refill our michael@0: // AddonRepository cache michael@0: let addonList = [ao5, ao8, ao9, ao10]; michael@0: yield promise_install_test_addons(addonList, michael@0: TESTROOT + "cancelCompatCheck.sjs?500"); michael@0: michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_bug557956.xml"); michael@0: michael@0: let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]); michael@0: ok(!a5.isCompatible, "addon5 should not be compatible"); michael@0: ok(!a8.isCompatible, "addon8 should not be compatible"); michael@0: ok(!a9.isCompatible, "addon9 should not be compatible"); michael@0: michael@0: let compatWindow = yield promise_open_compatibility_window([ao9.id, ...inactiveAddonIds]); michael@0: var doc = compatWindow.document; michael@0: yield promise_page(compatWindow, "versioninfo"); michael@0: michael@0: // Brief delay to let the update window finish requesting all add-ons and start michael@0: // reloading the addon repository michael@0: yield delayMS(50); michael@0: michael@0: info("Cancel the compatibility check dialog"); michael@0: var button = doc.documentElement.getButton("cancel"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: info("Waiting for installs to complete"); michael@0: yield installsDone; michael@0: ok(!repo.AddonRepository.isSearching, "Background installs are done"); michael@0: michael@0: // There should be no active updates michael@0: let getInstalls = Promise.defer(); michael@0: AddonManager.getAllInstalls(getInstalls.resolve); michael@0: let installs = yield getInstalls.promise; michael@0: is (installs.length, 0, "There should be no active installs after background installs are done"); michael@0: michael@0: // addon8 should have updated in the background, michael@0: // addon9 was listed as previously disabled so it should not have updated michael@0: let [a5, a8, a9, a10] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id, ao10.id]); michael@0: ok(a5.isCompatible, "addon5 should be compatible"); michael@0: ok(a8.isCompatible, "addon8 should have been upgraded"); michael@0: ok(!a9.isCompatible, "addon9 should not have been upgraded"); michael@0: ok(!a10.isCompatible, "addon10 should not be compatible"); michael@0: michael@0: info("Updates done"); michael@0: yield promise_uninstall_test_addons(); michael@0: info("done uninstalling add-ons"); michael@0: }); michael@0: michael@0: // User cancels after repopulateCache, while we're waiting for the addon.findUpdates() michael@0: // calls in gVersionInfoPage_onPageShow() to complete michael@0: // For this test, both addon8 and addon9 were disabled by this update, but addon8 michael@0: // is set to not auto-update, so only addon9 should update in the background michael@0: add_task(function cancel_during_findUpdates() { michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); michael@0: Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); michael@0: michael@0: let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated"); michael@0: let installsDone = promise_observer("TEST:all-updates-done"); michael@0: michael@0: // Don't pull compatibility data during add-on install michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); michael@0: // No delay on the .sjs this time because we want the cache to repopulate michael@0: let addonList = [ao3, ao5, ao6, ao7, ao8, ao9]; michael@0: yield promise_install_test_addons(addonList, michael@0: TESTROOT + "cancelCompatCheck.sjs"); michael@0: michael@0: let [a8] = yield promise_addons_by_ids([ao8.id]); michael@0: a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; michael@0: michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); michael@0: var doc = compatWindow.document; michael@0: yield promise_page(compatWindow, "versioninfo"); michael@0: michael@0: info("Waiting for repository-data-updated"); michael@0: yield observeUpdateDone; michael@0: michael@0: // Quick wait to make sure the findUpdates calls get queued michael@0: yield delayMS(5); michael@0: michael@0: info("Cancel the compatibility check dialog"); michael@0: var button = doc.documentElement.getButton("cancel"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: info("Waiting for installs to complete 2"); michael@0: yield installsDone; michael@0: ok(!repo.AddonRepository.isSearching, "Background installs are done 2"); michael@0: michael@0: // addon8 should have updated in the background, michael@0: // addon9 was listed as previously disabled so it should not have updated michael@0: let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]); michael@0: ok(a5.isCompatible, "addon5 should be compatible"); michael@0: ok(!a8.isCompatible, "addon8 should not have been upgraded"); michael@0: ok(a9.isCompatible, "addon9 should have been upgraded"); michael@0: michael@0: let getInstalls = Promise.defer(); michael@0: AddonManager.getAllInstalls(getInstalls.resolve); michael@0: let installs = yield getInstalls.promise; michael@0: is (installs.length, 0, "There should be no active installs after the dialog is cancelled 2"); michael@0: michael@0: info("findUpdates done"); michael@0: yield promise_uninstall_test_addons(); michael@0: }); michael@0: michael@0: // Cancelling during the 'mismatch' screen allows add-ons that can auto-update michael@0: // to continue updating in the background and cancels any other updates michael@0: // Same conditions as the previous test - addon8 and addon9 have updates available, michael@0: // addon8 is set to not auto-update so only addon9 should become compatible michael@0: add_task(function cancel_mismatch() { michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); michael@0: Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); michael@0: michael@0: let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated"); michael@0: let installsDone = promise_observer("TEST:all-updates-done"); michael@0: michael@0: // Don't pull compatibility data during add-on install michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); michael@0: // No delay on the .sjs this time because we want the cache to repopulate michael@0: let addonList = [ao3, ao5, ao6, ao7, ao8, ao9]; michael@0: yield promise_install_test_addons(addonList, michael@0: TESTROOT + "cancelCompatCheck.sjs"); michael@0: michael@0: let [a8] = yield promise_addons_by_ids([ao8.id]); michael@0: a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; michael@0: michael@0: // Check that the addons start out not compatible. michael@0: let [a3, a7, a8, a9] = yield promise_addons_by_ids([ao3.id, ao7.id, ao8.id, ao9.id]); michael@0: ok(!a3.isCompatible, "addon3 should not be compatible"); michael@0: ok(!a7.isCompatible, "addon7 should not be compatible"); michael@0: ok(!a8.isCompatible, "addon8 should not be compatible"); michael@0: ok(!a9.isCompatible, "addon9 should not be compatible"); michael@0: michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); michael@0: var doc = compatWindow.document; michael@0: info("Wait for mismatch page"); michael@0: yield promise_page(compatWindow, "mismatch"); michael@0: info("Click the Don't Check button"); michael@0: var button = doc.documentElement.getButton("cancel"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: yield promise_window_close(compatWindow); michael@0: info("Waiting for installs to complete in cancel_mismatch"); michael@0: yield installsDone; michael@0: michael@0: // addon8 should not have updated in the background, michael@0: // addon9 was listed as previously disabled so it should not have updated michael@0: let [a5, a8, a9] = yield promise_addons_by_ids([ao5.id, ao8.id, ao9.id]); michael@0: ok(a5.isCompatible, "addon5 should be compatible"); michael@0: ok(!a8.isCompatible, "addon8 should not have been upgraded"); michael@0: ok(a9.isCompatible, "addon9 should have been upgraded"); michael@0: michael@0: // Make sure there are no pending addon installs michael@0: let pInstalls = Promise.defer(); michael@0: AddonManager.getAllInstalls(pInstalls.resolve); michael@0: let installs = yield pInstalls.promise; michael@0: ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")"); michael@0: michael@0: yield promise_uninstall_test_addons(); michael@0: yield check_addons_uninstalled(addonList); michael@0: }); michael@0: michael@0: // Cancelling during the 'mismatch' screen with only add-ons that have michael@0: // no updates available michael@0: add_task(function cancel_mismatch_no_updates() { michael@0: Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true); michael@0: Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); michael@0: michael@0: let observeUpdateDone = promise_observer("TEST:addon-repository-data-updated"); michael@0: michael@0: // Don't pull compatibility data during add-on install michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, false); michael@0: // No delay on the .sjs this time because we want the cache to repopulate michael@0: let addonList = [ao3, ao5, ao6]; michael@0: yield promise_install_test_addons(addonList, michael@0: TESTROOT + "cancelCompatCheck.sjs"); michael@0: michael@0: // Check that the addons start out not compatible. michael@0: let [a3, a5, a6] = yield promise_addons_by_ids([ao3.id, ao5.id, ao6.id]); michael@0: ok(!a3.isCompatible, "addon3 should not be compatible"); michael@0: ok(!a5.isCompatible, "addon7 should not be compatible"); michael@0: ok(!a6.isCompatible, "addon8 should not be compatible"); michael@0: michael@0: Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); michael@0: let compatWindow = yield promise_open_compatibility_window(inactiveAddonIds); michael@0: var doc = compatWindow.document; michael@0: info("Wait for mismatch page"); michael@0: yield promise_page(compatWindow, "mismatch"); michael@0: info("Click the Don't Check button"); michael@0: var button = doc.documentElement.getButton("cancel"); michael@0: EventUtils.synthesizeMouse(button, 2, 2, { }, compatWindow); michael@0: michael@0: yield promise_window_close(compatWindow); michael@0: michael@0: let [a3, a5, a6] = yield promise_addons_by_ids([ao3.id, ao5.id, ao6.id]); michael@0: ok(!a3.isCompatible, "addon3 should not be compatible"); michael@0: ok(a5.isCompatible, "addon5 should have become compatible"); michael@0: ok(a6.isCompatible, "addon6 should have become compatible"); michael@0: michael@0: // Make sure there are no pending addon installs michael@0: let pInstalls = Promise.defer(); michael@0: AddonManager.getAllInstalls(pInstalls.resolve); michael@0: let installs = yield pInstalls.promise; michael@0: ok(installs.length == 0, "No remaining add-on installs (" + installs.toSource() + ")"); michael@0: michael@0: yield promise_uninstall_test_addons(); michael@0: yield check_addons_uninstalled(addonList); michael@0: });