toolkit/mozapps/extensions/test/browser/browser_updateid.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_updateid.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     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 +// Tests that updates that change an add-on's ID show up correctly in the UI
     1.9 +
    1.10 +var gProvider;
    1.11 +var gManagerWindow;
    1.12 +var gCategoryUtilities;
    1.13 +
    1.14 +var gApp = document.getElementById("bundle_brand").getString("brandShortName");
    1.15 +
    1.16 +function test() {
    1.17 +  waitForExplicitFinish();
    1.18 +
    1.19 +  gProvider = new MockProvider();
    1.20 +
    1.21 +  gProvider.createAddons([{
    1.22 +    id: "addon1@tests.mozilla.org",
    1.23 +    name: "manually updating addon",
    1.24 +    version: "1.0",
    1.25 +    applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE
    1.26 +  }]);
    1.27 +
    1.28 +  open_manager("addons://list/extension", function(aWindow) {
    1.29 +    gManagerWindow = aWindow;
    1.30 +    gCategoryUtilities = new CategoryUtilities(gManagerWindow);
    1.31 +    run_next_test();
    1.32 +  });
    1.33 +}
    1.34 +
    1.35 +function end_test() {
    1.36 +  close_manager(gManagerWindow, function() {
    1.37 +    finish();
    1.38 +  });
    1.39 +}
    1.40 +
    1.41 +add_test(function() {
    1.42 +  gCategoryUtilities.openType("extension", function() {
    1.43 +    gProvider.createInstalls([{
    1.44 +      name: "updated add-on",
    1.45 +      existingAddon: gProvider.addons[0],
    1.46 +      version: "2.0"
    1.47 +    }]);
    1.48 +    var newAddon = new MockAddon("addon2@tests.mozilla.org");
    1.49 +    newAddon.name = "updated add-on";
    1.50 +    newAddon.version = "2.0";
    1.51 +    newAddon.pendingOperations = AddonManager.PENDING_INSTALL;
    1.52 +    gProvider.installs[0]._addonToInstall = newAddon;
    1.53 +
    1.54 +    var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
    1.55 +    is(item._version.value, "1.0", "Should still show the old version in the normal list");
    1.56 +    var name = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "name");
    1.57 +    is(name.value, "manually updating addon", "Should show the old name in the list");
    1.58 +    var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn");
    1.59 +    is_element_visible(update, "Update button should be visible");
    1.60 +
    1.61 +    item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
    1.62 +    is(item, null, "Should not show the new version in the list");
    1.63 +
    1.64 +    run_next_test();
    1.65 +  });
    1.66 +});
    1.67 +
    1.68 +add_test(function() {
    1.69 +  var item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
    1.70 +  var update = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "update-btn");
    1.71 +  EventUtils.synthesizeMouseAtCenter(update, { }, gManagerWindow);
    1.72 +
    1.73 +  var pending = gManagerWindow.document.getAnonymousElementByAttribute(item, "anonid", "pending");
    1.74 +  is_element_visible(pending, "Pending message should be visible");
    1.75 +  is(pending.textContent,
    1.76 +     get_string("notification.upgrade", "manually updating addon", gApp),
    1.77 +     "Pending message should be correct");
    1.78 +
    1.79 +  item = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
    1.80 +  is(item, null, "Should not show the new version in the list");
    1.81 +
    1.82 +  run_next_test();
    1.83 +});

mercurial