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: // Tests various aspects of the details view michael@0: michael@0: const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault" michael@0: const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url"; michael@0: const SEARCH_URL = TESTROOT + "browser_details.xml"; michael@0: const PREF_EM_HOTFIX_ID = "extensions.hotfix.id"; michael@0: michael@0: var gManagerWindow; michael@0: var gCategoryUtilities; michael@0: var gProvider; michael@0: michael@0: var gApp = document.getElementById("bundle_brand").getString("brandShortName"); michael@0: var gVersion = Services.appinfo.version; michael@0: var gBlocklistURL = Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL"); michael@0: var gPluginURL = Services.urlFormatter.formatURLPref("plugins.update.url"); michael@0: var gDate = new Date(2010, 7, 1); michael@0: michael@0: function open_details(aId, aType, aCallback) { michael@0: requestLongerTimeout(2); michael@0: michael@0: gCategoryUtilities.openType(aType, function() { michael@0: var list = gManagerWindow.document.getElementById("addon-list"); michael@0: var item = list.firstChild; michael@0: while (item) { michael@0: if ("mAddon" in item && item.mAddon.id == aId) { michael@0: list.ensureElementIsVisible(item); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); michael@0: EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); michael@0: wait_for_view_load(gManagerWindow, aCallback); michael@0: return; michael@0: } michael@0: item = item.nextSibling; michael@0: } michael@0: ok(false, "Should have found the add-on in the list"); michael@0: }); michael@0: } michael@0: michael@0: function get(aId) { michael@0: return gManagerWindow.document.getElementById(aId); michael@0: } michael@0: michael@0: function test() { michael@0: requestLongerTimeout(2); michael@0: // Turn on searching for this test michael@0: Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15); michael@0: Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL); michael@0: Services.prefs.setCharPref(PREF_EM_HOTFIX_ID, "hotfix@tests.mozilla.org"); michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: gProvider.createAddons([{ michael@0: id: "addon1@tests.mozilla.org", michael@0: name: "Test add-on 1", michael@0: version: "2.1", michael@0: description: "Short description", michael@0: fullDescription: "Longer description", michael@0: type: "extension", michael@0: iconURL: "chrome://foo/skin/icon.png", michael@0: icon64URL: "chrome://foo/skin/icon64.png", michael@0: contributionURL: "http://foo.com", michael@0: contributionAmount: "$0.99", michael@0: sourceURI: Services.io.newURI("http://example.com/foo", null, null), michael@0: averageRating: 4, michael@0: reviewCount: 5, michael@0: reviewURL: "http://example.com/reviews", michael@0: homepageURL: "http://example.com/addon1", michael@0: applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE michael@0: }, { michael@0: id: "addon2@tests.mozilla.org", michael@0: name: "Test add-on 2", michael@0: version: "2.2", michael@0: description: "Short description", michael@0: creator: { name: "Mozilla", url: null }, michael@0: type: "extension", michael@0: iconURL: "chrome://foo/skin/icon.png", michael@0: contributionURL: "http://foo.com", michael@0: contributionAmount: null, michael@0: updateDate: gDate, michael@0: permissions: 0, michael@0: screenshots: [{ michael@0: url: "chrome://branding/content/about.png", michael@0: width: 200, michael@0: height: 150 michael@0: }], michael@0: }, { michael@0: id: "addon3@tests.mozilla.org", michael@0: name: "Test add-on 3", michael@0: description: "Short description", michael@0: creator: { name: "Mozilla", url: "http://www.mozilla.org" }, michael@0: type: "extension", michael@0: sourceURI: Services.io.newURI("http://example.com/foo", null, null), michael@0: updateDate: gDate, michael@0: reviewCount: 1, michael@0: reviewURL: "http://example.com/reviews", michael@0: applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE, michael@0: isActive: false, michael@0: isCompatible: false, michael@0: appDisabled: true, michael@0: permissions: AddonManager.PERM_CAN_ENABLE | michael@0: AddonManager.PERM_CAN_DISABLE | michael@0: AddonManager.PERM_CAN_UPGRADE, michael@0: screenshots: [{ michael@0: url: "http://example.com/screenshot", michael@0: width: 400, michael@0: height: 300, michael@0: thumbnailURL: "chrome://branding/content/icon64.png", michael@0: thumbnailWidth: 160, michael@0: thumbnailHeight: 120 michael@0: }], michael@0: }, { michael@0: id: "addon4@tests.mozilla.org", michael@0: blocklistURL: "http://example.com/addon4@tests.mozilla.org", michael@0: name: "Test add-on 4", michael@0: _userDisabled: true, michael@0: isActive: false, michael@0: blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED michael@0: }, { michael@0: id: "addon5@tests.mozilla.org", michael@0: blocklistURL: "http://example.com/addon5@tests.mozilla.org", michael@0: name: "Test add-on 5", michael@0: isActive: false, michael@0: blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED, michael@0: appDisabled: true michael@0: }, { michael@0: id: "addon6@tests.mozilla.org", michael@0: blocklistURL: "http://example.com/addon6@tests.mozilla.org", michael@0: name: "Test add-on 6", michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }, { michael@0: id: "addon7@tests.mozilla.org", michael@0: blocklistURL: "http://example.com/addon7@tests.mozilla.org", michael@0: name: "Test add-on 7", michael@0: _userDisabled: true, michael@0: isActive: false michael@0: }, { michael@0: id: "addon8@tests.mozilla.org", michael@0: blocklistURL: "http://example.com/addon8@tests.mozilla.org", michael@0: name: "Test add-on 8", michael@0: blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED michael@0: }, { michael@0: id: "hotfix@tests.mozilla.org", michael@0: name: "Test hotfix 1", michael@0: }]); michael@0: michael@0: open_manager(null, function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: michael@0: function end_test() { michael@0: Services.prefs.clearUserPref(PREF_EM_HOTFIX_ID); michael@0: close_manager(gManagerWindow, function() { michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: // Opens and tests the details view for add-on 1 michael@0: add_test(function() { michael@0: open_details("addon1@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 1", "Name should be correct"); michael@0: is_element_visible(get("detail-version"), "Version should not be hidden"); michael@0: is(get("detail-version").value, "2.1", "Version should be correct"); michael@0: is(get("detail-icon").src, "chrome://foo/skin/icon64.png", "Icon should be correct"); michael@0: is_element_hidden(get("detail-creator"), "Creator should be hidden"); michael@0: is_element_hidden(get("detail-screenshot"), "Screenshot should be hidden"); michael@0: is(get("detail-screenshot").width, "", "Screenshot dimensions should not be set"); michael@0: is(get("detail-screenshot").height, "", "Screenshot dimensions should not be set"); michael@0: is(get("detail-desc").textContent, "Short description", "Description should be correct"); michael@0: is(get("detail-fulldesc").textContent, "Longer description", "Full description should be correct"); michael@0: michael@0: is_element_visible(get("detail-contributions"), "Contributions section should be visible"); michael@0: is_element_visible(get("detail-contrib-suggested"), "Contributions amount should be visible"); michael@0: ok(get("detail-contrib-suggested").value, "$0.99"); michael@0: michael@0: is_element_visible(get("detail-updates-row"), "Updates should not be hidden"); michael@0: is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden"); michael@0: michael@0: is_element_visible(get("detail-rating-row"), "Rating row should not be hidden"); michael@0: is_element_visible(get("detail-rating"), "Rating should not be hidden"); michael@0: is(get("detail-rating").averageRating, 4, "Rating should be correct"); michael@0: is_element_visible(get("detail-reviews"), "Reviews should not be hidden"); michael@0: is(get("detail-reviews").href, "http://example.com/reviews", "Review URL should be correct"); michael@0: is(get("detail-reviews").value, "5 reviews", "Review text should be correct"); michael@0: michael@0: is_element_visible(get("detail-homepage-row"), "Homepage should be visible"); michael@0: ok(get("detail-homepage").href, "http://example.com/addon1"); michael@0: is_element_hidden(get("detail-repository-row"), "Repository profile should not be visible"); michael@0: michael@0: is_element_hidden(get("detail-size"), "Size should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); michael@0: michael@0: is_element_visible(get("detail-autoUpdate"), "Updates should not be hidden"); michael@0: ok(get("detail-autoUpdate").childNodes[1].selected, "Updates ahould be automatic"); michael@0: is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").lastChild, {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual"); michael@0: is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").firstChild.selected, "Updates should be automatic"); michael@0: is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: // Disable it michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 1 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Reopen it michael@0: open_details("addon1@tests.mozilla.org", "extension", function() { michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 1 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Undo disabling michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 2 michael@0: add_test(function() { michael@0: open_details("addon2@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 2", "Name should be correct"); michael@0: is_element_visible(get("detail-version"), "Version should not be hidden"); michael@0: is(get("detail-version").value, "2.2", "Version should be correct"); michael@0: is(get("detail-icon").src, "chrome://foo/skin/icon.png", "Icon should be correct"); michael@0: michael@0: is_element_visible(get("detail-creator"), "Creator should not be hidden"); michael@0: is_element_visible(get("detail-creator")._creatorName, "Creator name should not be hidden"); michael@0: is(get("detail-creator")._creatorName.value, "Mozilla", "Creator should be correct"); michael@0: is_element_hidden(get("detail-creator")._creatorLink, "Creator link should be hidden"); michael@0: michael@0: is_element_visible(get("detail-screenshot"), "Screenshot should be visible"); michael@0: is(get("detail-screenshot").src, "chrome://branding/content/about.png", "Should be showing the full sized screenshot"); michael@0: is(get("detail-screenshot").width, 200, "Screenshot dimensions should be set"); michael@0: is(get("detail-screenshot").height, 150, "Screenshot dimensions should be set"); michael@0: is(get("detail-screenshot").hasAttribute("loading"), true, "Screenshot should have loading attribute"); michael@0: is(get("detail-desc").textContent, "Short description", "Description should be correct"); michael@0: is_element_hidden(get("detail-fulldesc"), "Full description should be hidden"); michael@0: michael@0: is_element_visible(get("detail-contributions"), "Contributions section should be visible"); michael@0: is_element_hidden(get("detail-contrib-suggested"), "Contributions amount should be hidden"); michael@0: michael@0: is_element_visible(get("detail-dateUpdated"), "Update date should not be hidden"); michael@0: is(get("detail-dateUpdated").value, formatDate(gDate), "Update date should be correct"); michael@0: michael@0: is_element_hidden(get("detail-rating-row"), "Rating should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-homepage-row"), "Homepage should not be visible"); michael@0: is_element_hidden(get("detail-repository-row"), "Repository profile should not be visible"); michael@0: michael@0: is_element_hidden(get("detail-size"), "Size should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-updates-row"), "Updates should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_hidden(get("detail-uninstall-btn"), "Remove button should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: get("detail-screenshot").addEventListener("load", function() { michael@0: this.removeEventListener("load", arguments.callee, false); michael@0: is(this.hasAttribute("loading"), false, "Screenshot should not have loading attribute"); michael@0: run_next_test(); michael@0: }, false); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 3 michael@0: add_test(function() { michael@0: open_details("addon3@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 3", "Name should be correct"); michael@0: is_element_hidden(get("detail-version"), "Version should be hidden"); michael@0: is(get("detail-icon").src, "", "Icon should be correct"); michael@0: michael@0: is_element_visible(get("detail-creator"), "Creator should not be hidden"); michael@0: is_element_hidden(get("detail-creator")._creatorName, "Creator name should be hidden"); michael@0: is_element_visible(get("detail-creator")._creatorLink, "Creator link should not be hidden"); michael@0: is(get("detail-creator")._creatorLink.value, "Mozilla", "Creator link should be correct"); michael@0: is(get("detail-creator")._creatorLink.href, "http://www.mozilla.org", "Creator link href should be correct"); michael@0: michael@0: is_element_visible(get("detail-screenshot"), "Screenshot should be visible"); michael@0: is(get("detail-screenshot").src, "chrome://branding/content/icon64.png", "Should be showing the thumbnail"); michael@0: is(get("detail-screenshot").width, 160, "Screenshot dimensions should be set"); michael@0: is(get("detail-screenshot").height, 120, "Screenshot dimensions should be set"); michael@0: is(get("detail-screenshot").hasAttribute("loading"), true, "Screenshot should have loading attribute"); michael@0: michael@0: is_element_hidden(get("detail-contributions"), "Contributions section should be hidden"); michael@0: michael@0: is_element_visible(get("detail-updates-row"), "Updates should not be hidden"); michael@0: is_element_visible(get("detail-dateUpdated"), "Update date should not be hidden"); michael@0: is(get("detail-dateUpdated").value, formatDate(gDate), "Update date should be correct"); michael@0: michael@0: is_element_visible(get("detail-rating-row"), "Rating row should not be hidden"); michael@0: is_element_hidden(get("detail-rating"), "Rating should be hidden"); michael@0: is_element_visible(get("detail-reviews"), "Reviews should not be hidden"); michael@0: is(get("detail-reviews").href, "http://example.com/reviews", "Review URL should be correct"); michael@0: is(get("detail-reviews").value, "1 review", "Review text should be correct"); michael@0: michael@0: is_element_hidden(get("detail-size"), "Size should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); michael@0: michael@0: is_element_visible(get("detail-autoUpdate"), "Updates should not be hidden"); michael@0: ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual"); michael@0: is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").childNodes[1], {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").childNodes[1].selected, "Updates should be automatic"); michael@0: is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").lastChild, {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual"); michael@0: is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); michael@0: michael@0: info("Setting " + PREF_AUTOUPDATE_DEFAULT + " to true"); michael@0: Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, true); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default"); michael@0: is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); michael@0: michael@0: info("Setting " + PREF_AUTOUPDATE_DEFAULT + " to false"); michael@0: Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, false); michael@0: ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default"); michael@0: is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").childNodes[1], {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").childNodes[1].selected, "Updates should be automatic"); michael@0: is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow); michael@0: ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default"); michael@0: is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); michael@0: Services.prefs.clearUserPref(PREF_AUTOUPDATE_DEFAULT); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_hidden(get("detail-uninstall-btn"), "Remove button should be hidden"); michael@0: michael@0: is_element_visible(get("detail-warning"), "Warning message should be visible"); michael@0: is(get("detail-warning").textContent, "Test add-on 3 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: get("detail-screenshot").addEventListener("load", function() { michael@0: this.removeEventListener("load", arguments.callee, false); michael@0: is(this.hasAttribute("loading"), false, "Screenshot should not have loading attribute"); michael@0: run_next_test(); michael@0: }, false); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 4 michael@0: add_test(function() { michael@0: open_details("addon4@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 4", "Name should be correct"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_visible(get("detail-warning"), "Warning message should be visible"); michael@0: is(get("detail-warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct"); michael@0: is_element_visible(get("detail-warning-link"), "Warning link should be visible"); michael@0: is(get("detail-warning-link").value, "More Information", "Warning link text should be correct"); michael@0: is(get("detail-warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: // Enable it michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Reopen it michael@0: open_details("addon4@tests.mozilla.org", "extension", function() { michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Undo enabling michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_visible(get("detail-warning"), "Warning message should be visible"); michael@0: is(get("detail-warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct"); michael@0: is_element_visible(get("detail-warning-link"), "Warning link should be visible"); michael@0: is(get("detail-warning-link").value, "More Information", "Warning link text should be correct"); michael@0: is(get("detail-warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 5 michael@0: add_test(function() { michael@0: open_details("addon5@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 5", "Name should be correct"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_visible(get("detail-error"), "Error message should be visible"); michael@0: is(get("detail-error").textContent, "Test add-on 5 has been disabled due to security or stability issues.", "Error message should be correct"); michael@0: is_element_visible(get("detail-error-link"), "Error link should be visible"); michael@0: is(get("detail-error-link").value, "More Information", "Error link text should be correct"); michael@0: is(get("detail-error-link").href, "http://example.com/addon5@tests.mozilla.org", "Error link should be correct"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 6 michael@0: add_test(function() { michael@0: open_details("addon6@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 6", "Name should be correct"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: // Disable it michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: // Reopen it michael@0: open_details("addon6@tests.mozilla.org", "extension", function() { michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be visible"); michael@0: michael@0: // Enable it michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 7 michael@0: add_test(function() { michael@0: open_details("addon7@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 7", "Name should be correct"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: // Enable it michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 7 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Reopen it michael@0: open_details("addon7@tests.mozilla.org", "extension", function() { michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 7 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Undo enabling michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for add-on 8 michael@0: add_test(function() { michael@0: open_details("addon8@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test add-on 8", "Name should be correct"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_visible(get("detail-warning"), "Warning message should be visible"); michael@0: is(get("detail-warning").textContent, "An important update is available for Test add-on 8.", "Warning message should be correct"); michael@0: is_element_visible(get("detail-warning-link"), "Warning link should be visible"); michael@0: is(get("detail-warning-link").value, "Update Now", "Warning link text should be correct"); michael@0: is(get("detail-warning-link").href, gPluginURL, "Warning link should be correct"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: // Disable it michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 8 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Reopen it michael@0: open_details("addon8@tests.mozilla.org", "extension", function() { michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); michael@0: is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_visible(get("detail-pending"), "Pending message should be visible"); michael@0: is(get("detail-pending").textContent, "Test add-on 8 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); michael@0: michael@0: // Undo disabling michael@0: EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_visible(get("detail-warning"), "Warning message should be visible"); michael@0: is(get("detail-warning").textContent, "An important update is available for Test add-on 8.", "Warning message should be correct"); michael@0: is_element_visible(get("detail-warning-link"), "Warning link should be visible"); michael@0: is(get("detail-warning-link").value, "Update Now", "Warning link text should be correct"); michael@0: is(get("detail-warning-link").href, gPluginURL, "Warning link should be correct"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-error-link"), "Error link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: }); michael@0: michael@0: // Opens and tests the details view for hotfix 1 michael@0: add_test(function() { michael@0: open_details("hotfix@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-name").textContent, "Test hotfix 1", "Name should be correct"); michael@0: michael@0: is_element_hidden(get("detail-updates-row"), "Updates should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: // Tests that upgrades with onExternalInstall apply immediately michael@0: add_test(function() { michael@0: open_details("addon1@tests.mozilla.org", "extension", function() { michael@0: gProvider.createAddons([{ michael@0: id: "addon1@tests.mozilla.org", michael@0: name: "Test add-on replacement", michael@0: version: "2.5", michael@0: description: "Short description replacement", michael@0: fullDescription: "Longer description replacement", michael@0: type: "extension", michael@0: iconURL: "chrome://foo/skin/icon.png", michael@0: icon64URL: "chrome://foo/skin/icon264.png", michael@0: sourceURI: Services.io.newURI("http://example.com/foo", null, null), michael@0: averageRating: 2, michael@0: optionsURL: "chrome://foo/content/options.xul", michael@0: applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE, michael@0: operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE michael@0: }]); michael@0: michael@0: is(get("detail-name").textContent, "Test add-on replacement", "Name should be correct"); michael@0: is_element_visible(get("detail-version"), "Version should not be hidden"); michael@0: is(get("detail-version").value, "2.5", "Version should be correct"); michael@0: is(get("detail-icon").src, "chrome://foo/skin/icon264.png", "Icon should be correct"); michael@0: is_element_hidden(get("detail-creator"), "Creator should be hidden"); michael@0: is_element_hidden(get("detail-screenshot"), "Screenshot should be hidden"); michael@0: is(get("detail-desc").textContent, "Short description replacement", "Description should be correct"); michael@0: is(get("detail-fulldesc").textContent, "Longer description replacement", "Full description should be correct"); michael@0: michael@0: is_element_hidden(get("detail-contributions"), "Contributions section should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden"); michael@0: michael@0: is_element_visible(get("detail-rating-row"), "Rating row should not be hidden"); michael@0: is_element_visible(get("detail-rating"), "Rating should not be hidden"); michael@0: is(get("detail-rating").averageRating, 2, "Rating should be correct"); michael@0: is_element_hidden(get("detail-reviews"), "Reviews should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-homepage-row"), "Homepage should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-size"), "Size should be hidden"); michael@0: michael@0: is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); michael@0: michael@0: is_element_visible(get("detail-prefs-btn"), "Preferences button should be visible"); michael@0: is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); michael@0: is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); michael@0: is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); michael@0: michael@0: is_element_hidden(get("detail-warning"), "Warning message should be hidden"); michael@0: is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); michael@0: is_element_hidden(get("detail-error"), "Error message should be hidden"); michael@0: is_element_hidden(get("detail-pending"), "Pending message should be hidden"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: michael@0: // Check that onPropertyChanges for appDisabled updates the UI michael@0: add_test(function() { michael@0: info("Checking that onPropertyChanges for appDisabled updates the UI"); michael@0: michael@0: AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) { michael@0: aAddon.userDisabled = true; michael@0: aAddon.isCompatible = true; michael@0: aAddon.appDisabled = false; michael@0: michael@0: open_details("addon1@tests.mozilla.org", "extension", function() { michael@0: is(get("detail-view").getAttribute("active"), "false", "Addon should not be marked as active"); michael@0: is_element_hidden(get("detail-warning"), "Warning message should not be visible"); michael@0: michael@0: info("Making addon incompatible and appDisabled"); michael@0: aAddon.isCompatible = false; michael@0: aAddon.appDisabled = true; michael@0: michael@0: is(get("detail-view").getAttribute("active"), "false", "Addon should not be marked as active"); michael@0: is_element_visible(get("detail-warning"), "Warning message should be visible"); michael@0: is(get("detail-warning").textContent, "Test add-on replacement is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct"); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: }); michael@0: });