Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | // Tests various aspects of the details view |
michael@0 | 6 | |
michael@0 | 7 | const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault" |
michael@0 | 8 | const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url"; |
michael@0 | 9 | const SEARCH_URL = TESTROOT + "browser_details.xml"; |
michael@0 | 10 | const PREF_EM_HOTFIX_ID = "extensions.hotfix.id"; |
michael@0 | 11 | |
michael@0 | 12 | var gManagerWindow; |
michael@0 | 13 | var gCategoryUtilities; |
michael@0 | 14 | var gProvider; |
michael@0 | 15 | |
michael@0 | 16 | var gApp = document.getElementById("bundle_brand").getString("brandShortName"); |
michael@0 | 17 | var gVersion = Services.appinfo.version; |
michael@0 | 18 | var gBlocklistURL = Services.urlFormatter.formatURLPref("extensions.blocklist.detailsURL"); |
michael@0 | 19 | var gPluginURL = Services.urlFormatter.formatURLPref("plugins.update.url"); |
michael@0 | 20 | var gDate = new Date(2010, 7, 1); |
michael@0 | 21 | |
michael@0 | 22 | function open_details(aId, aType, aCallback) { |
michael@0 | 23 | requestLongerTimeout(2); |
michael@0 | 24 | |
michael@0 | 25 | gCategoryUtilities.openType(aType, function() { |
michael@0 | 26 | var list = gManagerWindow.document.getElementById("addon-list"); |
michael@0 | 27 | var item = list.firstChild; |
michael@0 | 28 | while (item) { |
michael@0 | 29 | if ("mAddon" in item && item.mAddon.id == aId) { |
michael@0 | 30 | list.ensureElementIsVisible(item); |
michael@0 | 31 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
michael@0 | 32 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
michael@0 | 33 | wait_for_view_load(gManagerWindow, aCallback); |
michael@0 | 34 | return; |
michael@0 | 35 | } |
michael@0 | 36 | item = item.nextSibling; |
michael@0 | 37 | } |
michael@0 | 38 | ok(false, "Should have found the add-on in the list"); |
michael@0 | 39 | }); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function get(aId) { |
michael@0 | 43 | return gManagerWindow.document.getElementById(aId); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function test() { |
michael@0 | 47 | requestLongerTimeout(2); |
michael@0 | 48 | // Turn on searching for this test |
michael@0 | 49 | Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15); |
michael@0 | 50 | Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL); |
michael@0 | 51 | Services.prefs.setCharPref(PREF_EM_HOTFIX_ID, "hotfix@tests.mozilla.org"); |
michael@0 | 52 | |
michael@0 | 53 | waitForExplicitFinish(); |
michael@0 | 54 | |
michael@0 | 55 | gProvider = new MockProvider(); |
michael@0 | 56 | |
michael@0 | 57 | gProvider.createAddons([{ |
michael@0 | 58 | id: "addon1@tests.mozilla.org", |
michael@0 | 59 | name: "Test add-on 1", |
michael@0 | 60 | version: "2.1", |
michael@0 | 61 | description: "Short description", |
michael@0 | 62 | fullDescription: "Longer description", |
michael@0 | 63 | type: "extension", |
michael@0 | 64 | iconURL: "chrome://foo/skin/icon.png", |
michael@0 | 65 | icon64URL: "chrome://foo/skin/icon64.png", |
michael@0 | 66 | contributionURL: "http://foo.com", |
michael@0 | 67 | contributionAmount: "$0.99", |
michael@0 | 68 | sourceURI: Services.io.newURI("http://example.com/foo", null, null), |
michael@0 | 69 | averageRating: 4, |
michael@0 | 70 | reviewCount: 5, |
michael@0 | 71 | reviewURL: "http://example.com/reviews", |
michael@0 | 72 | homepageURL: "http://example.com/addon1", |
michael@0 | 73 | applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE |
michael@0 | 74 | }, { |
michael@0 | 75 | id: "addon2@tests.mozilla.org", |
michael@0 | 76 | name: "Test add-on 2", |
michael@0 | 77 | version: "2.2", |
michael@0 | 78 | description: "Short description", |
michael@0 | 79 | creator: { name: "Mozilla", url: null }, |
michael@0 | 80 | type: "extension", |
michael@0 | 81 | iconURL: "chrome://foo/skin/icon.png", |
michael@0 | 82 | contributionURL: "http://foo.com", |
michael@0 | 83 | contributionAmount: null, |
michael@0 | 84 | updateDate: gDate, |
michael@0 | 85 | permissions: 0, |
michael@0 | 86 | screenshots: [{ |
michael@0 | 87 | url: "chrome://branding/content/about.png", |
michael@0 | 88 | width: 200, |
michael@0 | 89 | height: 150 |
michael@0 | 90 | }], |
michael@0 | 91 | }, { |
michael@0 | 92 | id: "addon3@tests.mozilla.org", |
michael@0 | 93 | name: "Test add-on 3", |
michael@0 | 94 | description: "Short description", |
michael@0 | 95 | creator: { name: "Mozilla", url: "http://www.mozilla.org" }, |
michael@0 | 96 | type: "extension", |
michael@0 | 97 | sourceURI: Services.io.newURI("http://example.com/foo", null, null), |
michael@0 | 98 | updateDate: gDate, |
michael@0 | 99 | reviewCount: 1, |
michael@0 | 100 | reviewURL: "http://example.com/reviews", |
michael@0 | 101 | applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE, |
michael@0 | 102 | isActive: false, |
michael@0 | 103 | isCompatible: false, |
michael@0 | 104 | appDisabled: true, |
michael@0 | 105 | permissions: AddonManager.PERM_CAN_ENABLE | |
michael@0 | 106 | AddonManager.PERM_CAN_DISABLE | |
michael@0 | 107 | AddonManager.PERM_CAN_UPGRADE, |
michael@0 | 108 | screenshots: [{ |
michael@0 | 109 | url: "http://example.com/screenshot", |
michael@0 | 110 | width: 400, |
michael@0 | 111 | height: 300, |
michael@0 | 112 | thumbnailURL: "chrome://branding/content/icon64.png", |
michael@0 | 113 | thumbnailWidth: 160, |
michael@0 | 114 | thumbnailHeight: 120 |
michael@0 | 115 | }], |
michael@0 | 116 | }, { |
michael@0 | 117 | id: "addon4@tests.mozilla.org", |
michael@0 | 118 | blocklistURL: "http://example.com/addon4@tests.mozilla.org", |
michael@0 | 119 | name: "Test add-on 4", |
michael@0 | 120 | _userDisabled: true, |
michael@0 | 121 | isActive: false, |
michael@0 | 122 | blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED |
michael@0 | 123 | }, { |
michael@0 | 124 | id: "addon5@tests.mozilla.org", |
michael@0 | 125 | blocklistURL: "http://example.com/addon5@tests.mozilla.org", |
michael@0 | 126 | name: "Test add-on 5", |
michael@0 | 127 | isActive: false, |
michael@0 | 128 | blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED, |
michael@0 | 129 | appDisabled: true |
michael@0 | 130 | }, { |
michael@0 | 131 | id: "addon6@tests.mozilla.org", |
michael@0 | 132 | blocklistURL: "http://example.com/addon6@tests.mozilla.org", |
michael@0 | 133 | name: "Test add-on 6", |
michael@0 | 134 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 135 | }, { |
michael@0 | 136 | id: "addon7@tests.mozilla.org", |
michael@0 | 137 | blocklistURL: "http://example.com/addon7@tests.mozilla.org", |
michael@0 | 138 | name: "Test add-on 7", |
michael@0 | 139 | _userDisabled: true, |
michael@0 | 140 | isActive: false |
michael@0 | 141 | }, { |
michael@0 | 142 | id: "addon8@tests.mozilla.org", |
michael@0 | 143 | blocklistURL: "http://example.com/addon8@tests.mozilla.org", |
michael@0 | 144 | name: "Test add-on 8", |
michael@0 | 145 | blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED |
michael@0 | 146 | }, { |
michael@0 | 147 | id: "hotfix@tests.mozilla.org", |
michael@0 | 148 | name: "Test hotfix 1", |
michael@0 | 149 | }]); |
michael@0 | 150 | |
michael@0 | 151 | open_manager(null, function(aWindow) { |
michael@0 | 152 | gManagerWindow = aWindow; |
michael@0 | 153 | gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
michael@0 | 154 | |
michael@0 | 155 | run_next_test(); |
michael@0 | 156 | }); |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | function end_test() { |
michael@0 | 160 | Services.prefs.clearUserPref(PREF_EM_HOTFIX_ID); |
michael@0 | 161 | close_manager(gManagerWindow, function() { |
michael@0 | 162 | finish(); |
michael@0 | 163 | }); |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | // Opens and tests the details view for add-on 1 |
michael@0 | 167 | add_test(function() { |
michael@0 | 168 | open_details("addon1@tests.mozilla.org", "extension", function() { |
michael@0 | 169 | is(get("detail-name").textContent, "Test add-on 1", "Name should be correct"); |
michael@0 | 170 | is_element_visible(get("detail-version"), "Version should not be hidden"); |
michael@0 | 171 | is(get("detail-version").value, "2.1", "Version should be correct"); |
michael@0 | 172 | is(get("detail-icon").src, "chrome://foo/skin/icon64.png", "Icon should be correct"); |
michael@0 | 173 | is_element_hidden(get("detail-creator"), "Creator should be hidden"); |
michael@0 | 174 | is_element_hidden(get("detail-screenshot"), "Screenshot should be hidden"); |
michael@0 | 175 | is(get("detail-screenshot").width, "", "Screenshot dimensions should not be set"); |
michael@0 | 176 | is(get("detail-screenshot").height, "", "Screenshot dimensions should not be set"); |
michael@0 | 177 | is(get("detail-desc").textContent, "Short description", "Description should be correct"); |
michael@0 | 178 | is(get("detail-fulldesc").textContent, "Longer description", "Full description should be correct"); |
michael@0 | 179 | |
michael@0 | 180 | is_element_visible(get("detail-contributions"), "Contributions section should be visible"); |
michael@0 | 181 | is_element_visible(get("detail-contrib-suggested"), "Contributions amount should be visible"); |
michael@0 | 182 | ok(get("detail-contrib-suggested").value, "$0.99"); |
michael@0 | 183 | |
michael@0 | 184 | is_element_visible(get("detail-updates-row"), "Updates should not be hidden"); |
michael@0 | 185 | is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden"); |
michael@0 | 186 | |
michael@0 | 187 | is_element_visible(get("detail-rating-row"), "Rating row should not be hidden"); |
michael@0 | 188 | is_element_visible(get("detail-rating"), "Rating should not be hidden"); |
michael@0 | 189 | is(get("detail-rating").averageRating, 4, "Rating should be correct"); |
michael@0 | 190 | is_element_visible(get("detail-reviews"), "Reviews should not be hidden"); |
michael@0 | 191 | is(get("detail-reviews").href, "http://example.com/reviews", "Review URL should be correct"); |
michael@0 | 192 | is(get("detail-reviews").value, "5 reviews", "Review text should be correct"); |
michael@0 | 193 | |
michael@0 | 194 | is_element_visible(get("detail-homepage-row"), "Homepage should be visible"); |
michael@0 | 195 | ok(get("detail-homepage").href, "http://example.com/addon1"); |
michael@0 | 196 | is_element_hidden(get("detail-repository-row"), "Repository profile should not be visible"); |
michael@0 | 197 | |
michael@0 | 198 | is_element_hidden(get("detail-size"), "Size should be hidden"); |
michael@0 | 199 | |
michael@0 | 200 | is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); |
michael@0 | 201 | |
michael@0 | 202 | is_element_visible(get("detail-autoUpdate"), "Updates should not be hidden"); |
michael@0 | 203 | ok(get("detail-autoUpdate").childNodes[1].selected, "Updates ahould be automatic"); |
michael@0 | 204 | is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); |
michael@0 | 205 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").lastChild, {}, gManagerWindow); |
michael@0 | 206 | ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual"); |
michael@0 | 207 | is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); |
michael@0 | 208 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow); |
michael@0 | 209 | ok(get("detail-autoUpdate").firstChild.selected, "Updates should be automatic"); |
michael@0 | 210 | is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); |
michael@0 | 211 | |
michael@0 | 212 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 213 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 214 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 215 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 216 | |
michael@0 | 217 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 218 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 219 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 220 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 221 | |
michael@0 | 222 | // Disable it |
michael@0 | 223 | EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow); |
michael@0 | 224 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 225 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 226 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 227 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 228 | |
michael@0 | 229 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 230 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 231 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 232 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 233 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 234 | is(get("detail-pending").textContent, "Test add-on 1 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 235 | |
michael@0 | 236 | // Reopen it |
michael@0 | 237 | open_details("addon1@tests.mozilla.org", "extension", function() { |
michael@0 | 238 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 239 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 240 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 241 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 242 | |
michael@0 | 243 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 244 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 245 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 246 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 247 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 248 | is(get("detail-pending").textContent, "Test add-on 1 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 249 | |
michael@0 | 250 | // Undo disabling |
michael@0 | 251 | EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); |
michael@0 | 252 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 253 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 254 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 255 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 256 | |
michael@0 | 257 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 258 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 259 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 260 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 261 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 262 | |
michael@0 | 263 | run_next_test(); |
michael@0 | 264 | }); |
michael@0 | 265 | }); |
michael@0 | 266 | }); |
michael@0 | 267 | |
michael@0 | 268 | // Opens and tests the details view for add-on 2 |
michael@0 | 269 | add_test(function() { |
michael@0 | 270 | open_details("addon2@tests.mozilla.org", "extension", function() { |
michael@0 | 271 | is(get("detail-name").textContent, "Test add-on 2", "Name should be correct"); |
michael@0 | 272 | is_element_visible(get("detail-version"), "Version should not be hidden"); |
michael@0 | 273 | is(get("detail-version").value, "2.2", "Version should be correct"); |
michael@0 | 274 | is(get("detail-icon").src, "chrome://foo/skin/icon.png", "Icon should be correct"); |
michael@0 | 275 | |
michael@0 | 276 | is_element_visible(get("detail-creator"), "Creator should not be hidden"); |
michael@0 | 277 | is_element_visible(get("detail-creator")._creatorName, "Creator name should not be hidden"); |
michael@0 | 278 | is(get("detail-creator")._creatorName.value, "Mozilla", "Creator should be correct"); |
michael@0 | 279 | is_element_hidden(get("detail-creator")._creatorLink, "Creator link should be hidden"); |
michael@0 | 280 | |
michael@0 | 281 | is_element_visible(get("detail-screenshot"), "Screenshot should be visible"); |
michael@0 | 282 | is(get("detail-screenshot").src, "chrome://branding/content/about.png", "Should be showing the full sized screenshot"); |
michael@0 | 283 | is(get("detail-screenshot").width, 200, "Screenshot dimensions should be set"); |
michael@0 | 284 | is(get("detail-screenshot").height, 150, "Screenshot dimensions should be set"); |
michael@0 | 285 | is(get("detail-screenshot").hasAttribute("loading"), true, "Screenshot should have loading attribute"); |
michael@0 | 286 | is(get("detail-desc").textContent, "Short description", "Description should be correct"); |
michael@0 | 287 | is_element_hidden(get("detail-fulldesc"), "Full description should be hidden"); |
michael@0 | 288 | |
michael@0 | 289 | is_element_visible(get("detail-contributions"), "Contributions section should be visible"); |
michael@0 | 290 | is_element_hidden(get("detail-contrib-suggested"), "Contributions amount should be hidden"); |
michael@0 | 291 | |
michael@0 | 292 | is_element_visible(get("detail-dateUpdated"), "Update date should not be hidden"); |
michael@0 | 293 | is(get("detail-dateUpdated").value, formatDate(gDate), "Update date should be correct"); |
michael@0 | 294 | |
michael@0 | 295 | is_element_hidden(get("detail-rating-row"), "Rating should be hidden"); |
michael@0 | 296 | |
michael@0 | 297 | is_element_hidden(get("detail-homepage-row"), "Homepage should not be visible"); |
michael@0 | 298 | is_element_hidden(get("detail-repository-row"), "Repository profile should not be visible"); |
michael@0 | 299 | |
michael@0 | 300 | is_element_hidden(get("detail-size"), "Size should be hidden"); |
michael@0 | 301 | |
michael@0 | 302 | is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); |
michael@0 | 303 | |
michael@0 | 304 | is_element_hidden(get("detail-updates-row"), "Updates should be hidden"); |
michael@0 | 305 | |
michael@0 | 306 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 307 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 308 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 309 | is_element_hidden(get("detail-uninstall-btn"), "Remove button should be hidden"); |
michael@0 | 310 | |
michael@0 | 311 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 312 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 313 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 314 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 315 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 316 | |
michael@0 | 317 | get("detail-screenshot").addEventListener("load", function() { |
michael@0 | 318 | this.removeEventListener("load", arguments.callee, false); |
michael@0 | 319 | is(this.hasAttribute("loading"), false, "Screenshot should not have loading attribute"); |
michael@0 | 320 | run_next_test(); |
michael@0 | 321 | }, false); |
michael@0 | 322 | }); |
michael@0 | 323 | }); |
michael@0 | 324 | |
michael@0 | 325 | // Opens and tests the details view for add-on 3 |
michael@0 | 326 | add_test(function() { |
michael@0 | 327 | open_details("addon3@tests.mozilla.org", "extension", function() { |
michael@0 | 328 | is(get("detail-name").textContent, "Test add-on 3", "Name should be correct"); |
michael@0 | 329 | is_element_hidden(get("detail-version"), "Version should be hidden"); |
michael@0 | 330 | is(get("detail-icon").src, "", "Icon should be correct"); |
michael@0 | 331 | |
michael@0 | 332 | is_element_visible(get("detail-creator"), "Creator should not be hidden"); |
michael@0 | 333 | is_element_hidden(get("detail-creator")._creatorName, "Creator name should be hidden"); |
michael@0 | 334 | is_element_visible(get("detail-creator")._creatorLink, "Creator link should not be hidden"); |
michael@0 | 335 | is(get("detail-creator")._creatorLink.value, "Mozilla", "Creator link should be correct"); |
michael@0 | 336 | is(get("detail-creator")._creatorLink.href, "http://www.mozilla.org", "Creator link href should be correct"); |
michael@0 | 337 | |
michael@0 | 338 | is_element_visible(get("detail-screenshot"), "Screenshot should be visible"); |
michael@0 | 339 | is(get("detail-screenshot").src, "chrome://branding/content/icon64.png", "Should be showing the thumbnail"); |
michael@0 | 340 | is(get("detail-screenshot").width, 160, "Screenshot dimensions should be set"); |
michael@0 | 341 | is(get("detail-screenshot").height, 120, "Screenshot dimensions should be set"); |
michael@0 | 342 | is(get("detail-screenshot").hasAttribute("loading"), true, "Screenshot should have loading attribute"); |
michael@0 | 343 | |
michael@0 | 344 | is_element_hidden(get("detail-contributions"), "Contributions section should be hidden"); |
michael@0 | 345 | |
michael@0 | 346 | is_element_visible(get("detail-updates-row"), "Updates should not be hidden"); |
michael@0 | 347 | is_element_visible(get("detail-dateUpdated"), "Update date should not be hidden"); |
michael@0 | 348 | is(get("detail-dateUpdated").value, formatDate(gDate), "Update date should be correct"); |
michael@0 | 349 | |
michael@0 | 350 | is_element_visible(get("detail-rating-row"), "Rating row should not be hidden"); |
michael@0 | 351 | is_element_hidden(get("detail-rating"), "Rating should be hidden"); |
michael@0 | 352 | is_element_visible(get("detail-reviews"), "Reviews should not be hidden"); |
michael@0 | 353 | is(get("detail-reviews").href, "http://example.com/reviews", "Review URL should be correct"); |
michael@0 | 354 | is(get("detail-reviews").value, "1 review", "Review text should be correct"); |
michael@0 | 355 | |
michael@0 | 356 | is_element_hidden(get("detail-size"), "Size should be hidden"); |
michael@0 | 357 | |
michael@0 | 358 | is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); |
michael@0 | 359 | |
michael@0 | 360 | is_element_visible(get("detail-autoUpdate"), "Updates should not be hidden"); |
michael@0 | 361 | ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual"); |
michael@0 | 362 | is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); |
michael@0 | 363 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").childNodes[1], {}, gManagerWindow); |
michael@0 | 364 | ok(get("detail-autoUpdate").childNodes[1].selected, "Updates should be automatic"); |
michael@0 | 365 | is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); |
michael@0 | 366 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").lastChild, {}, gManagerWindow); |
michael@0 | 367 | ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual"); |
michael@0 | 368 | is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); |
michael@0 | 369 | |
michael@0 | 370 | info("Setting " + PREF_AUTOUPDATE_DEFAULT + " to true"); |
michael@0 | 371 | Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, true); |
michael@0 | 372 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow); |
michael@0 | 373 | ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default"); |
michael@0 | 374 | is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); |
michael@0 | 375 | |
michael@0 | 376 | info("Setting " + PREF_AUTOUPDATE_DEFAULT + " to false"); |
michael@0 | 377 | Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, false); |
michael@0 | 378 | ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default"); |
michael@0 | 379 | is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); |
michael@0 | 380 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").childNodes[1], {}, gManagerWindow); |
michael@0 | 381 | ok(get("detail-autoUpdate").childNodes[1].selected, "Updates should be automatic"); |
michael@0 | 382 | is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden"); |
michael@0 | 383 | EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow); |
michael@0 | 384 | ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default"); |
michael@0 | 385 | is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible"); |
michael@0 | 386 | Services.prefs.clearUserPref(PREF_AUTOUPDATE_DEFAULT); |
michael@0 | 387 | |
michael@0 | 388 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 389 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 390 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 391 | is_element_hidden(get("detail-uninstall-btn"), "Remove button should be hidden"); |
michael@0 | 392 | |
michael@0 | 393 | is_element_visible(get("detail-warning"), "Warning message should be visible"); |
michael@0 | 394 | is(get("detail-warning").textContent, "Test add-on 3 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct"); |
michael@0 | 395 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 396 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 397 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 398 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 399 | |
michael@0 | 400 | get("detail-screenshot").addEventListener("load", function() { |
michael@0 | 401 | this.removeEventListener("load", arguments.callee, false); |
michael@0 | 402 | is(this.hasAttribute("loading"), false, "Screenshot should not have loading attribute"); |
michael@0 | 403 | run_next_test(); |
michael@0 | 404 | }, false); |
michael@0 | 405 | }); |
michael@0 | 406 | }); |
michael@0 | 407 | |
michael@0 | 408 | // Opens and tests the details view for add-on 4 |
michael@0 | 409 | add_test(function() { |
michael@0 | 410 | open_details("addon4@tests.mozilla.org", "extension", function() { |
michael@0 | 411 | is(get("detail-name").textContent, "Test add-on 4", "Name should be correct"); |
michael@0 | 412 | |
michael@0 | 413 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 414 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 415 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 416 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 417 | |
michael@0 | 418 | is_element_visible(get("detail-warning"), "Warning message should be visible"); |
michael@0 | 419 | is(get("detail-warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct"); |
michael@0 | 420 | is_element_visible(get("detail-warning-link"), "Warning link should be visible"); |
michael@0 | 421 | is(get("detail-warning-link").value, "More Information", "Warning link text should be correct"); |
michael@0 | 422 | is(get("detail-warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct"); |
michael@0 | 423 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 424 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 425 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 426 | |
michael@0 | 427 | // Enable it |
michael@0 | 428 | EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow); |
michael@0 | 429 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 430 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 431 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 432 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 433 | |
michael@0 | 434 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 435 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 436 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 437 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 438 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 439 | is(get("detail-pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 440 | |
michael@0 | 441 | // Reopen it |
michael@0 | 442 | open_details("addon4@tests.mozilla.org", "extension", function() { |
michael@0 | 443 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 444 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 445 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 446 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 447 | |
michael@0 | 448 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 449 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 450 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 451 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 452 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 453 | is(get("detail-pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 454 | |
michael@0 | 455 | // Undo enabling |
michael@0 | 456 | EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); |
michael@0 | 457 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 458 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 459 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 460 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 461 | |
michael@0 | 462 | is_element_visible(get("detail-warning"), "Warning message should be visible"); |
michael@0 | 463 | is(get("detail-warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct"); |
michael@0 | 464 | is_element_visible(get("detail-warning-link"), "Warning link should be visible"); |
michael@0 | 465 | is(get("detail-warning-link").value, "More Information", "Warning link text should be correct"); |
michael@0 | 466 | is(get("detail-warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct"); |
michael@0 | 467 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 468 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 469 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 470 | |
michael@0 | 471 | run_next_test(); |
michael@0 | 472 | }); |
michael@0 | 473 | }); |
michael@0 | 474 | }); |
michael@0 | 475 | |
michael@0 | 476 | // Opens and tests the details view for add-on 5 |
michael@0 | 477 | add_test(function() { |
michael@0 | 478 | open_details("addon5@tests.mozilla.org", "extension", function() { |
michael@0 | 479 | is(get("detail-name").textContent, "Test add-on 5", "Name should be correct"); |
michael@0 | 480 | |
michael@0 | 481 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 482 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 483 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 484 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 485 | |
michael@0 | 486 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 487 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 488 | is_element_visible(get("detail-error"), "Error message should be visible"); |
michael@0 | 489 | 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 | 490 | is_element_visible(get("detail-error-link"), "Error link should be visible"); |
michael@0 | 491 | is(get("detail-error-link").value, "More Information", "Error link text should be correct"); |
michael@0 | 492 | is(get("detail-error-link").href, "http://example.com/addon5@tests.mozilla.org", "Error link should be correct"); |
michael@0 | 493 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 494 | |
michael@0 | 495 | run_next_test(); |
michael@0 | 496 | }); |
michael@0 | 497 | }); |
michael@0 | 498 | |
michael@0 | 499 | // Opens and tests the details view for add-on 6 |
michael@0 | 500 | add_test(function() { |
michael@0 | 501 | open_details("addon6@tests.mozilla.org", "extension", function() { |
michael@0 | 502 | is(get("detail-name").textContent, "Test add-on 6", "Name should be correct"); |
michael@0 | 503 | |
michael@0 | 504 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 505 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 506 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 507 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 508 | |
michael@0 | 509 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 510 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 511 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 512 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 513 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 514 | |
michael@0 | 515 | // Disable it |
michael@0 | 516 | EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow); |
michael@0 | 517 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 518 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 519 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 520 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 521 | |
michael@0 | 522 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 523 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 524 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 525 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 526 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 527 | |
michael@0 | 528 | // Reopen it |
michael@0 | 529 | open_details("addon6@tests.mozilla.org", "extension", function() { |
michael@0 | 530 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 531 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 532 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 533 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 534 | |
michael@0 | 535 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 536 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 537 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 538 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 539 | is_element_hidden(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 540 | |
michael@0 | 541 | // Enable it |
michael@0 | 542 | EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow); |
michael@0 | 543 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 544 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 545 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 546 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 547 | |
michael@0 | 548 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 549 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 550 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 551 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 552 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 553 | |
michael@0 | 554 | run_next_test(); |
michael@0 | 555 | }); |
michael@0 | 556 | }); |
michael@0 | 557 | }); |
michael@0 | 558 | |
michael@0 | 559 | // Opens and tests the details view for add-on 7 |
michael@0 | 560 | add_test(function() { |
michael@0 | 561 | open_details("addon7@tests.mozilla.org", "extension", function() { |
michael@0 | 562 | is(get("detail-name").textContent, "Test add-on 7", "Name should be correct"); |
michael@0 | 563 | |
michael@0 | 564 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 565 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 566 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 567 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 568 | |
michael@0 | 569 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 570 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 571 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 572 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 573 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 574 | |
michael@0 | 575 | // Enable it |
michael@0 | 576 | EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow); |
michael@0 | 577 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 578 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 579 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 580 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 581 | |
michael@0 | 582 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 583 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 584 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 585 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 586 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 587 | is(get("detail-pending").textContent, "Test add-on 7 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 588 | |
michael@0 | 589 | // Reopen it |
michael@0 | 590 | open_details("addon7@tests.mozilla.org", "extension", function() { |
michael@0 | 591 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 592 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 593 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 594 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 595 | |
michael@0 | 596 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 597 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 598 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 599 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 600 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 601 | is(get("detail-pending").textContent, "Test add-on 7 will be enabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 602 | |
michael@0 | 603 | // Undo enabling |
michael@0 | 604 | EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); |
michael@0 | 605 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 606 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 607 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 608 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 609 | |
michael@0 | 610 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 611 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 612 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 613 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 614 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 615 | |
michael@0 | 616 | run_next_test(); |
michael@0 | 617 | }); |
michael@0 | 618 | }); |
michael@0 | 619 | }); |
michael@0 | 620 | |
michael@0 | 621 | // Opens and tests the details view for add-on 8 |
michael@0 | 622 | add_test(function() { |
michael@0 | 623 | open_details("addon8@tests.mozilla.org", "extension", function() { |
michael@0 | 624 | is(get("detail-name").textContent, "Test add-on 8", "Name should be correct"); |
michael@0 | 625 | |
michael@0 | 626 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 627 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 628 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 629 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 630 | |
michael@0 | 631 | is_element_visible(get("detail-warning"), "Warning message should be visible"); |
michael@0 | 632 | is(get("detail-warning").textContent, "An important update is available for Test add-on 8.", "Warning message should be correct"); |
michael@0 | 633 | is_element_visible(get("detail-warning-link"), "Warning link should be visible"); |
michael@0 | 634 | is(get("detail-warning-link").value, "Update Now", "Warning link text should be correct"); |
michael@0 | 635 | is(get("detail-warning-link").href, gPluginURL, "Warning link should be correct"); |
michael@0 | 636 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 637 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 638 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 639 | |
michael@0 | 640 | // Disable it |
michael@0 | 641 | EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow); |
michael@0 | 642 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 643 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 644 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 645 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 646 | |
michael@0 | 647 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 648 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 649 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 650 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 651 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 652 | is(get("detail-pending").textContent, "Test add-on 8 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 653 | |
michael@0 | 654 | // Reopen it |
michael@0 | 655 | open_details("addon8@tests.mozilla.org", "extension", function() { |
michael@0 | 656 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 657 | is_element_visible(get("detail-enable-btn"), "Enable button should be visible"); |
michael@0 | 658 | is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden"); |
michael@0 | 659 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 660 | |
michael@0 | 661 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 662 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 663 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 664 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 665 | is_element_visible(get("detail-pending"), "Pending message should be visible"); |
michael@0 | 666 | is(get("detail-pending").textContent, "Test add-on 8 will be disabled after you restart " + gApp + ".", "Pending message should be correct"); |
michael@0 | 667 | |
michael@0 | 668 | // Undo disabling |
michael@0 | 669 | EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow); |
michael@0 | 670 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 671 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 672 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 673 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 674 | |
michael@0 | 675 | is_element_visible(get("detail-warning"), "Warning message should be visible"); |
michael@0 | 676 | is(get("detail-warning").textContent, "An important update is available for Test add-on 8.", "Warning message should be correct"); |
michael@0 | 677 | is_element_visible(get("detail-warning-link"), "Warning link should be visible"); |
michael@0 | 678 | is(get("detail-warning-link").value, "Update Now", "Warning link text should be correct"); |
michael@0 | 679 | is(get("detail-warning-link").href, gPluginURL, "Warning link should be correct"); |
michael@0 | 680 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 681 | is_element_hidden(get("detail-error-link"), "Error link should be hidden"); |
michael@0 | 682 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 683 | |
michael@0 | 684 | run_next_test(); |
michael@0 | 685 | }); |
michael@0 | 686 | }); |
michael@0 | 687 | }); |
michael@0 | 688 | |
michael@0 | 689 | // Opens and tests the details view for hotfix 1 |
michael@0 | 690 | add_test(function() { |
michael@0 | 691 | open_details("hotfix@tests.mozilla.org", "extension", function() { |
michael@0 | 692 | is(get("detail-name").textContent, "Test hotfix 1", "Name should be correct"); |
michael@0 | 693 | |
michael@0 | 694 | is_element_hidden(get("detail-updates-row"), "Updates should be hidden"); |
michael@0 | 695 | |
michael@0 | 696 | is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden"); |
michael@0 | 697 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 698 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 699 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 700 | |
michael@0 | 701 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 702 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 703 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 704 | |
michael@0 | 705 | run_next_test(); |
michael@0 | 706 | }); |
michael@0 | 707 | }); |
michael@0 | 708 | |
michael@0 | 709 | // Tests that upgrades with onExternalInstall apply immediately |
michael@0 | 710 | add_test(function() { |
michael@0 | 711 | open_details("addon1@tests.mozilla.org", "extension", function() { |
michael@0 | 712 | gProvider.createAddons([{ |
michael@0 | 713 | id: "addon1@tests.mozilla.org", |
michael@0 | 714 | name: "Test add-on replacement", |
michael@0 | 715 | version: "2.5", |
michael@0 | 716 | description: "Short description replacement", |
michael@0 | 717 | fullDescription: "Longer description replacement", |
michael@0 | 718 | type: "extension", |
michael@0 | 719 | iconURL: "chrome://foo/skin/icon.png", |
michael@0 | 720 | icon64URL: "chrome://foo/skin/icon264.png", |
michael@0 | 721 | sourceURI: Services.io.newURI("http://example.com/foo", null, null), |
michael@0 | 722 | averageRating: 2, |
michael@0 | 723 | optionsURL: "chrome://foo/content/options.xul", |
michael@0 | 724 | applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE, |
michael@0 | 725 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 726 | }]); |
michael@0 | 727 | |
michael@0 | 728 | is(get("detail-name").textContent, "Test add-on replacement", "Name should be correct"); |
michael@0 | 729 | is_element_visible(get("detail-version"), "Version should not be hidden"); |
michael@0 | 730 | is(get("detail-version").value, "2.5", "Version should be correct"); |
michael@0 | 731 | is(get("detail-icon").src, "chrome://foo/skin/icon264.png", "Icon should be correct"); |
michael@0 | 732 | is_element_hidden(get("detail-creator"), "Creator should be hidden"); |
michael@0 | 733 | is_element_hidden(get("detail-screenshot"), "Screenshot should be hidden"); |
michael@0 | 734 | is(get("detail-desc").textContent, "Short description replacement", "Description should be correct"); |
michael@0 | 735 | is(get("detail-fulldesc").textContent, "Longer description replacement", "Full description should be correct"); |
michael@0 | 736 | |
michael@0 | 737 | is_element_hidden(get("detail-contributions"), "Contributions section should be hidden"); |
michael@0 | 738 | |
michael@0 | 739 | is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden"); |
michael@0 | 740 | |
michael@0 | 741 | is_element_visible(get("detail-rating-row"), "Rating row should not be hidden"); |
michael@0 | 742 | is_element_visible(get("detail-rating"), "Rating should not be hidden"); |
michael@0 | 743 | is(get("detail-rating").averageRating, 2, "Rating should be correct"); |
michael@0 | 744 | is_element_hidden(get("detail-reviews"), "Reviews should be hidden"); |
michael@0 | 745 | |
michael@0 | 746 | is_element_hidden(get("detail-homepage-row"), "Homepage should be hidden"); |
michael@0 | 747 | |
michael@0 | 748 | is_element_hidden(get("detail-size"), "Size should be hidden"); |
michael@0 | 749 | |
michael@0 | 750 | is_element_hidden(get("detail-downloads"), "Downloads should be hidden"); |
michael@0 | 751 | |
michael@0 | 752 | is_element_visible(get("detail-prefs-btn"), "Preferences button should be visible"); |
michael@0 | 753 | is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden"); |
michael@0 | 754 | is_element_visible(get("detail-disable-btn"), "Disable button should be visible"); |
michael@0 | 755 | is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible"); |
michael@0 | 756 | |
michael@0 | 757 | is_element_hidden(get("detail-warning"), "Warning message should be hidden"); |
michael@0 | 758 | is_element_hidden(get("detail-warning-link"), "Warning link should be hidden"); |
michael@0 | 759 | is_element_hidden(get("detail-error"), "Error message should be hidden"); |
michael@0 | 760 | is_element_hidden(get("detail-pending"), "Pending message should be hidden"); |
michael@0 | 761 | |
michael@0 | 762 | run_next_test(); |
michael@0 | 763 | }); |
michael@0 | 764 | }); |
michael@0 | 765 | |
michael@0 | 766 | // Check that onPropertyChanges for appDisabled updates the UI |
michael@0 | 767 | add_test(function() { |
michael@0 | 768 | info("Checking that onPropertyChanges for appDisabled updates the UI"); |
michael@0 | 769 | |
michael@0 | 770 | AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) { |
michael@0 | 771 | aAddon.userDisabled = true; |
michael@0 | 772 | aAddon.isCompatible = true; |
michael@0 | 773 | aAddon.appDisabled = false; |
michael@0 | 774 | |
michael@0 | 775 | open_details("addon1@tests.mozilla.org", "extension", function() { |
michael@0 | 776 | is(get("detail-view").getAttribute("active"), "false", "Addon should not be marked as active"); |
michael@0 | 777 | is_element_hidden(get("detail-warning"), "Warning message should not be visible"); |
michael@0 | 778 | |
michael@0 | 779 | info("Making addon incompatible and appDisabled"); |
michael@0 | 780 | aAddon.isCompatible = false; |
michael@0 | 781 | aAddon.appDisabled = true; |
michael@0 | 782 | |
michael@0 | 783 | is(get("detail-view").getAttribute("active"), "false", "Addon should not be marked as active"); |
michael@0 | 784 | is_element_visible(get("detail-warning"), "Warning message should be visible"); |
michael@0 | 785 | is(get("detail-warning").textContent, "Test add-on replacement is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct"); |
michael@0 | 786 | |
michael@0 | 787 | run_next_test(); |
michael@0 | 788 | }); |
michael@0 | 789 | }); |
michael@0 | 790 | }); |