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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 the list view
michael@0 6
michael@0 7 let tempScope = {};
michael@0 8 Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope);
michael@0 9 let LightweightThemeManager = tempScope.LightweightThemeManager;
michael@0 10
michael@0 11
michael@0 12 var gProvider;
michael@0 13 var gManagerWindow;
michael@0 14 var gCategoryUtilities;
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, 16);
michael@0 21
michael@0 22 var gLWTheme = {
michael@0 23 id: "4",
michael@0 24 version: "1",
michael@0 25 name: "Bling",
michael@0 26 description: "SO MUCH BLING!",
michael@0 27 author: "Pixel Pusher",
michael@0 28 homepageURL: "http://mochi.test:8888/data/index.html",
michael@0 29 headerURL: "http://mochi.test:8888/data/header.png",
michael@0 30 footerURL: "http://mochi.test:8888/data/footer.png",
michael@0 31 previewURL: "http://mochi.test:8888/data/preview.png",
michael@0 32 iconURL: "http://mochi.test:8888/data/icon.png"
michael@0 33 };
michael@0 34
michael@0 35
michael@0 36 function test() {
michael@0 37 waitForExplicitFinish();
michael@0 38
michael@0 39 gProvider = new MockProvider();
michael@0 40
michael@0 41 gProvider.createAddons([{
michael@0 42 id: "addon1@tests.mozilla.org",
michael@0 43 name: "Test add-on",
michael@0 44 version: "1.0",
michael@0 45 description: "A test add-on",
michael@0 46 longDescription: " A longer description",
michael@0 47 updateDate: gDate
michael@0 48 }, {
michael@0 49 id: "addon2@tests.mozilla.org",
michael@0 50 name: "Test add-on 2",
michael@0 51 version: "2.0",
michael@0 52 longDescription: " A longer description",
michael@0 53 _userDisabled: true,
michael@0 54 isActive: false,
michael@0 55 }, {
michael@0 56 id: "addon3@tests.mozilla.org",
michael@0 57 name: "Test add-on 3",
michael@0 58 longDescription: " A longer description",
michael@0 59 isActive: false,
michael@0 60 isCompatible: false,
michael@0 61 appDisabled: true,
michael@0 62 permissions: AddonManager.PERM_CAN_ENABLE |
michael@0 63 AddonManager.PERM_CAN_DISABLE |
michael@0 64 AddonManager.PERM_CAN_UPGRADE
michael@0 65 }, {
michael@0 66 id: "addon4@tests.mozilla.org",
michael@0 67 blocklistURL: "http://example.com/addon4@tests.mozilla.org",
michael@0 68 name: "Test add-on 4",
michael@0 69 _userDisabled: true,
michael@0 70 isActive: false,
michael@0 71 blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED
michael@0 72 }, {
michael@0 73 id: "addon5@tests.mozilla.org",
michael@0 74 blocklistURL: "http://example.com/addon5@tests.mozilla.org",
michael@0 75 name: "Test add-on 5",
michael@0 76 isActive: false,
michael@0 77 blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
michael@0 78 appDisabled: true
michael@0 79 }, {
michael@0 80 id: "addon6@tests.mozilla.org",
michael@0 81 blocklistURL: "http://example.com/addon6@tests.mozilla.org",
michael@0 82 name: "Test add-on 6",
michael@0 83 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
michael@0 84 }, {
michael@0 85 id: "addon7@tests.mozilla.org",
michael@0 86 blocklistURL: "http://example.com/addon7@tests.mozilla.org",
michael@0 87 name: "Test add-on 7",
michael@0 88 blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED,
michael@0 89 }, {
michael@0 90 id: "addon8@tests.mozilla.org",
michael@0 91 blocklistURL: "http://example.com/addon8@tests.mozilla.org",
michael@0 92 name: "Test add-on 8",
michael@0 93 blocklistState: Ci.nsIBlocklistService.STATE_VULNERABLE_UPDATE_AVAILABLE,
michael@0 94 }, {
michael@0 95 id: "addon9@tests.mozilla.org",
michael@0 96 blocklistURL: "http://example.com/addon9@tests.mozilla.org",
michael@0 97 name: "Test add-on 9",
michael@0 98 blocklistState: Ci.nsIBlocklistService.STATE_VULNERABLE_NO_UPDATE,
michael@0 99 }]);
michael@0 100
michael@0 101 open_manager(null, function(aWindow) {
michael@0 102 gManagerWindow = aWindow;
michael@0 103 gCategoryUtilities = new CategoryUtilities(gManagerWindow);
michael@0 104 run_next_test();
michael@0 105 });
michael@0 106 }
michael@0 107
michael@0 108 function end_test() {
michael@0 109 close_manager(gManagerWindow, function() {
michael@0 110 finish();
michael@0 111 });
michael@0 112 }
michael@0 113
michael@0 114 function get_test_items() {
michael@0 115 var tests = "@tests.mozilla.org";
michael@0 116
michael@0 117 var items = {};
michael@0 118 var item = gManagerWindow.document.getElementById("addon-list").firstChild;
michael@0 119
michael@0 120 while (item) {
michael@0 121 if (item.mAddon.id.substring(item.mAddon.id.length - tests.length) == tests)
michael@0 122 items[item.mAddon.name] = item;
michael@0 123 item = item.nextSibling;
michael@0 124 }
michael@0 125
michael@0 126 return items;
michael@0 127 }
michael@0 128
michael@0 129 function get_node(parent, anonid) {
michael@0 130 return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
michael@0 131 }
michael@0 132
michael@0 133 function get_class_node(parent, cls) {
michael@0 134 return parent.ownerDocument.getAnonymousElementByAttribute(parent, "class", cls);
michael@0 135 }
michael@0 136
michael@0 137 // Check that the list appears to have displayed correctly and trigger some
michael@0 138 // changes
michael@0 139 add_test(function() {
michael@0 140 gCategoryUtilities.openType("extension", function() {
michael@0 141 let items = get_test_items();
michael@0 142 is(Object.keys(items).length, 9, "Should be nine add-ons installed");
michael@0 143
michael@0 144 info("Addon 1");
michael@0 145 let addon = items["Test add-on"];
michael@0 146 addon.parentNode.ensureElementIsVisible(addon);
michael@0 147 is(get_node(addon, "name").value, "Test add-on", "Name should be correct");
michael@0 148 is_element_visible(get_node(addon, "version"), "Version should be visible");
michael@0 149 is(get_node(addon, "version").value, "1.0", "Version should be correct");
michael@0 150 is_element_visible(get_node(addon, "description"), "Description should be visible");
michael@0 151 is(get_node(addon, "description").value, "A test add-on", "Description should be correct");
michael@0 152 is_element_hidden(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be hidden");
michael@0 153 is_element_hidden(get_class_node(addon, "update-postfix"), "Update postfix should be hidden");
michael@0 154 is(get_node(addon, "date-updated").value, formatDate(gDate), "Update date should be correct");
michael@0 155
michael@0 156 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 157 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 158 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 159 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 160
michael@0 161 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 162 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 163 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 164 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 165 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 166
michael@0 167 info("Disabling");
michael@0 168 EventUtils.synthesizeMouseAtCenter(get_node(addon, "disable-btn"), {}, gManagerWindow);
michael@0 169 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 170 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 171 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 172 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 173
michael@0 174 is_element_hidden(get_node(addon, "warning"), "Warning message should be visible");
michael@0 175 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 176 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 177 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 178 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 179 is(get_node(addon, "pending").textContent, "Test add-on will be disabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 180
michael@0 181 info("Addon 2");
michael@0 182 addon = items["Test add-on 2"];
michael@0 183 addon.parentNode.ensureElementIsVisible(addon);
michael@0 184 is(get_node(addon, "name").value, "Test add-on 2", "Name should be correct");
michael@0 185 is_element_visible(get_node(addon, "version"), "Version should be visible");
michael@0 186 is(get_node(addon, "version").value, "2.0", "Version should be correct");
michael@0 187 is_element_hidden(get_node(addon, "description"), "Description should be hidden");
michael@0 188 is_element_visible(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be visible");
michael@0 189 is_element_hidden(get_class_node(addon, "update-postfix"), "Update postfix should be hidden");
michael@0 190 is(get_node(addon, "date-updated").value, "Unknown", "Date should be correct");
michael@0 191
michael@0 192 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 193 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 194 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 195 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 196
michael@0 197 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 198 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 199 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 200 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 201 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 202
michael@0 203 info("Enabling");
michael@0 204 EventUtils.synthesizeMouseAtCenter(get_node(addon, "enable-btn"), {}, gManagerWindow);
michael@0 205 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 206 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 207 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 208 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 209
michael@0 210 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 211 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 212 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 213 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 214 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 215 is(get_node(addon, "pending").textContent, "Test add-on 2 will be enabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 216
michael@0 217 info("Addon 3");
michael@0 218 addon = items["Test add-on 3"];
michael@0 219 addon.parentNode.ensureElementIsVisible(addon);
michael@0 220 is(get_node(addon, "name").value, "Test add-on 3", "Name should be correct");
michael@0 221 is_element_hidden(get_node(addon, "version"), "Version should be hidden");
michael@0 222
michael@0 223 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 224 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 225 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 226 is_element_hidden(get_node(addon, "remove-btn"), "Remove button should be hidden");
michael@0 227
michael@0 228 is_element_visible(get_node(addon, "warning"), "Warning message should be visible");
michael@0 229 is(get_node(addon, "warning").textContent, "Test add-on 3 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
michael@0 230 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 231 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 232 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 233 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 234
michael@0 235 info("Addon 4");
michael@0 236 addon = items["Test add-on 4"];
michael@0 237 addon.parentNode.ensureElementIsVisible(addon);
michael@0 238 is(get_node(addon, "name").value, "Test add-on 4", "Name should be correct");
michael@0 239
michael@0 240 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 241 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 242 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 243 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 244
michael@0 245 is_element_visible(get_node(addon, "warning"), "Warning message should be visible");
michael@0 246 is(get_node(addon, "warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct");
michael@0 247 is_element_visible(get_node(addon, "warning-link"), "Warning link should be visible");
michael@0 248 is(get_node(addon, "warning-link").value, "More Information", "Warning link text should be correct");
michael@0 249 is(get_node(addon, "warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct");
michael@0 250 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 251 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 252 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 253
michael@0 254 info("Enabling");
michael@0 255 EventUtils.synthesizeMouseAtCenter(get_node(addon, "enable-btn"), {}, gManagerWindow);
michael@0 256 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 257 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 258 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 259 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 260
michael@0 261 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 262 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 263 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 264 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 265 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 266 is(get_node(addon, "pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 267
michael@0 268 info("Addon 5");
michael@0 269 addon = items["Test add-on 5"];
michael@0 270 addon.parentNode.ensureElementIsVisible(addon);
michael@0 271 is(get_node(addon, "name").value, "Test add-on 5", "Name should be correct");
michael@0 272
michael@0 273 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 274 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 275 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 276 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 277
michael@0 278 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 279 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 280 is_element_visible(get_node(addon, "error"), "Error message should be visible");
michael@0 281 is(get_node(addon, "error").textContent, "Test add-on 5 has been disabled due to security or stability issues.", "Error message should be correct");
michael@0 282 is_element_visible(get_node(addon, "error-link"), "Error link should be visible");
michael@0 283 is(get_node(addon, "error-link").value, "More Information", "Error link text should be correct");
michael@0 284 is(get_node(addon, "error-link").href, "http://example.com/addon5@tests.mozilla.org", "Error link should be correct");
michael@0 285 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 286
michael@0 287 info("Addon 6");
michael@0 288 addon = items["Test add-on 6"];
michael@0 289 addon.parentNode.ensureElementIsVisible(addon);
michael@0 290 is(get_node(addon, "name").value, "Test add-on 6", "Name should be correct");
michael@0 291 is_element_hidden(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be hidden");
michael@0 292
michael@0 293 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 294 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 295 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 296 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 297
michael@0 298 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 299 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 300 is_element_hidden(get_node(addon, "error"), "Error message should be visible");
michael@0 301 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 302 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 303
michael@0 304 info("Disabling");
michael@0 305 EventUtils.synthesizeMouseAtCenter(get_node(addon, "disable-btn"), {}, gManagerWindow);
michael@0 306 is_element_visible(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be visible");
michael@0 307
michael@0 308 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 309 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 310 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 311 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 312
michael@0 313 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 314 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 315 is_element_hidden(get_node(addon, "error"), "Error message should be visible");
michael@0 316 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 317 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 318
michael@0 319 info("Addon 7");
michael@0 320 addon = items["Test add-on 7"];
michael@0 321 addon.parentNode.ensureElementIsVisible(addon);
michael@0 322 is(get_node(addon, "name").value, "Test add-on 7", "Name should be correct");
michael@0 323
michael@0 324 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 325 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 326 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 327 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 328
michael@0 329 is_element_visible(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 330 is(get_node(addon, "warning").textContent, "An important update is available for Test add-on 7.", "Warning message should be correct");
michael@0 331 is_element_visible(get_node(addon, "warning-link"), "Warning link should be visible");
michael@0 332 is(get_node(addon, "warning-link").value, "Update Now", "Warning link text should be correct");
michael@0 333 is(get_node(addon, "warning-link").href, gPluginURL, "Warning link should be correct");
michael@0 334 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 335 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 336 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 337
michael@0 338 info("Disabling");
michael@0 339 EventUtils.synthesizeMouseAtCenter(get_node(addon, "disable-btn"), {}, gManagerWindow);
michael@0 340 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 341 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 342 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 343 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 344
michael@0 345 is_element_hidden(get_node(addon, "warning"), "Warning message should be visible");
michael@0 346 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 347 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 348 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 349 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 350 is(get_node(addon, "pending").textContent, "Test add-on 7 will be disabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 351
michael@0 352 info("Addon 8");
michael@0 353 addon = items["Test add-on 8"];
michael@0 354 addon.parentNode.ensureElementIsVisible(addon);
michael@0 355 is(get_node(addon, "name").value, "Test add-on 8", "Name should be correct");
michael@0 356
michael@0 357 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 358 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 359 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 360 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 361
michael@0 362 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 363 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 364 is_element_visible(get_node(addon, "error"), "Error message should be visible");
michael@0 365 is(get_node(addon, "error").textContent, "Test add-on 8 is known to be vulnerable and should be updated.", "Error message should be correct");
michael@0 366 is_element_visible(get_node(addon, "error-link"), "Error link should be visible");
michael@0 367 is(get_node(addon, "error-link").value, "Update Now", "Error link text should be correct");
michael@0 368 is(get_node(addon, "error-link").href, "http://example.com/addon8@tests.mozilla.org", "Error link should be correct");
michael@0 369 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 370
michael@0 371 info("Addon 9");
michael@0 372 addon = items["Test add-on 9"];
michael@0 373 addon.parentNode.ensureElementIsVisible(addon);
michael@0 374 is(get_node(addon, "name").value, "Test add-on 9", "Name should be correct");
michael@0 375
michael@0 376 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 377 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 378 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 379 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 380
michael@0 381 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 382 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 383 is_element_visible(get_node(addon, "error"), "Error message should be visible");
michael@0 384 is(get_node(addon, "error").textContent, "Test add-on 9 is known to be vulnerable. Use with caution.", "Error message should be correct");
michael@0 385 is_element_visible(get_node(addon, "error-link"), "Error link should be visible");
michael@0 386 is(get_node(addon, "error-link").value, "More Information", "Error link text should be correct");
michael@0 387 is(get_node(addon, "error-link").href, "http://example.com/addon9@tests.mozilla.org", "Error link should be correct");
michael@0 388 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 389
michael@0 390 run_next_test();
michael@0 391 });
michael@0 392 });
michael@0 393
michael@0 394 // Check the add-ons are now in the right state
michael@0 395 add_test(function() {
michael@0 396 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 397 "addon2@tests.mozilla.org",
michael@0 398 "addon4@tests.mozilla.org",
michael@0 399 "addon6@tests.mozilla.org"],
michael@0 400 function([a1, a2, a4, a6]) {
michael@0 401 is(a1.pendingOperations, AddonManager.PENDING_DISABLE, "Add-on 1 should be pending disable");
michael@0 402 is(a2.pendingOperations, AddonManager.PENDING_ENABLE, "Add-on 2 should be pending enable");
michael@0 403 is(a4.pendingOperations, AddonManager.PENDING_ENABLE, "Add-on 4 should be pending enable");
michael@0 404
michael@0 405 run_next_test();
michael@0 406 });
michael@0 407 });
michael@0 408
michael@0 409 // Reload the list to make sure the changes are still pending and that undoing
michael@0 410 // works
michael@0 411 add_test(function() {
michael@0 412 gCategoryUtilities.openType("plugin", function() {
michael@0 413 gCategoryUtilities.openType("extension", function() {
michael@0 414 let items = get_test_items();
michael@0 415 is(Object.keys(items).length, 9, "Should be nine add-ons installed");
michael@0 416
michael@0 417 info("Addon 1");
michael@0 418 let addon = items["Test add-on"];
michael@0 419 addon.parentNode.ensureElementIsVisible(addon);
michael@0 420 is(get_node(addon, "name").value, "Test add-on", "Name should be correct");
michael@0 421 is_element_visible(get_node(addon, "version"), "Version should be visible");
michael@0 422 is(get_node(addon, "version").value, "1.0", "Version should be correct");
michael@0 423 is_element_visible(get_node(addon, "description"), "Description should be visible");
michael@0 424 is(get_node(addon, "description").value, "A test add-on", "Description should be correct");
michael@0 425 is_element_hidden(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be hidden");
michael@0 426 is_element_hidden(get_class_node(addon, "update-postfix"), "Update postfix should be hidden");
michael@0 427 is(get_node(addon, "date-updated").value, formatDate(gDate), "Update date should be correct");
michael@0 428
michael@0 429 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 430 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 431 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 432 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 433
michael@0 434 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 435 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 436 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 437 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 438 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 439 is(get_node(addon, "pending").textContent, "Test add-on will be disabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 440
michael@0 441 info("Undoing");
michael@0 442 EventUtils.synthesizeMouseAtCenter(get_node(addon, "undo-btn"), {}, gManagerWindow);
michael@0 443 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 444 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 445 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 446 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 447
michael@0 448 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 449 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 450 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 451 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 452 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 453
michael@0 454 info("Addon 2");
michael@0 455 addon = items["Test add-on 2"];
michael@0 456 addon.parentNode.ensureElementIsVisible(addon);
michael@0 457 is(get_node(addon, "name").value, "Test add-on 2", "Name should be correct");
michael@0 458 is_element_visible(get_node(addon, "version"), "Version should be visible");
michael@0 459 is(get_node(addon, "version").value, "2.0", "Version should be correct");
michael@0 460 is_element_hidden(get_node(addon, "description"), "Description should be hidden");
michael@0 461 is_element_visible(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be visible");
michael@0 462 is_element_hidden(get_class_node(addon, "update-postfix"), "Update postfix should be hidden");
michael@0 463 is(get_node(addon, "date-updated").value, "Unknown", "Date should be correct");
michael@0 464
michael@0 465 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 466 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 467 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 468 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 469
michael@0 470 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 471 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 472 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 473 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 474 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 475 is(get_node(addon, "pending").textContent, "Test add-on 2 will be enabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 476
michael@0 477 info("Undoing");
michael@0 478 EventUtils.synthesizeMouseAtCenter(get_node(addon, "undo-btn"), {}, gManagerWindow);
michael@0 479 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 480 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 481 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 482 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 483
michael@0 484 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 485 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 486 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 487 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 488 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 489
michael@0 490 info("Addon 4");
michael@0 491 addon = items["Test add-on 4"];
michael@0 492 addon.parentNode.ensureElementIsVisible(addon);
michael@0 493 is(get_node(addon, "name").value, "Test add-on 4", "Name should be correct");
michael@0 494
michael@0 495 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 496 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 497 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 498 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 499
michael@0 500 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 501 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 502 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 503 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 504 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 505 is(get_node(addon, "pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 506
michael@0 507 info("Undoing");
michael@0 508 EventUtils.synthesizeMouseAtCenter(get_node(addon, "undo-btn"), {}, gManagerWindow);
michael@0 509 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 510 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 511 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 512 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 513
michael@0 514 is_element_visible(get_node(addon, "warning"), "Warning message should be visible");
michael@0 515 is(get_node(addon, "warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct");
michael@0 516 is_element_visible(get_node(addon, "warning-link"), "Warning link should be visible");
michael@0 517 is(get_node(addon, "warning-link").value, "More Information", "Warning link text should be correct");
michael@0 518 is(get_node(addon, "warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct");
michael@0 519 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 520 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 521 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 522
michael@0 523 info("Addon 6");
michael@0 524 addon = items["Test add-on 6"];
michael@0 525 addon.parentNode.ensureElementIsVisible(addon);
michael@0 526 is(get_node(addon, "name").value, "Test add-on 6", "Name should be correct");
michael@0 527 is_element_visible(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be visible");
michael@0 528
michael@0 529 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 530 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 531 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 532 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 533
michael@0 534 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 535 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 536 is_element_hidden(get_node(addon, "error"), "Error message should be visible");
michael@0 537 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 538 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 539
michael@0 540 info("Enabling");
michael@0 541 EventUtils.synthesizeMouseAtCenter(get_node(addon, "enable-btn"), {}, gManagerWindow);
michael@0 542 is_element_hidden(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be hidden");
michael@0 543
michael@0 544 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 545 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 546 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 547 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 548
michael@0 549 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 550 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 551 is_element_hidden(get_node(addon, "error"), "Error message should be visible");
michael@0 552 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 553 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 554
michael@0 555 info("Addon 7");
michael@0 556 addon = items["Test add-on 7"];
michael@0 557 addon.parentNode.ensureElementIsVisible(addon);
michael@0 558 is(get_node(addon, "name").value, "Test add-on 7", "Name should be correct");
michael@0 559
michael@0 560 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 561 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be visible");
michael@0 562 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be hidden");
michael@0 563 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 564
michael@0 565 is_element_hidden(get_node(addon, "warning"), "Warning message should be visible");
michael@0 566 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 567 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 568 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 569 is_element_visible(get_node(addon, "pending"), "Pending message should be visible");
michael@0 570 is(get_node(addon, "pending").textContent, "Test add-on 7 will be disabled after you restart " + gApp + ".", "Pending message should be correct");
michael@0 571
michael@0 572 info("Undoing");
michael@0 573 EventUtils.synthesizeMouseAtCenter(get_node(addon, "undo-btn"), {}, gManagerWindow);
michael@0 574 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 575 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 576 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 577 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 578
michael@0 579 is_element_visible(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 580 is(get_node(addon, "warning").textContent, "An important update is available for Test add-on 7.", "Warning message should be correct");
michael@0 581 is_element_visible(get_node(addon, "warning-link"), "Warning link should be visible");
michael@0 582 is(get_node(addon, "warning-link").value, "Update Now", "Warning link text should be correct");
michael@0 583 is(get_node(addon, "warning-link").href, gPluginURL, "Warning link should be correct");
michael@0 584 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 585 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 586 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 587
michael@0 588 run_next_test();
michael@0 589 });
michael@0 590 });
michael@0 591 });
michael@0 592
michael@0 593 // Check the add-ons are now in the right state
michael@0 594 add_test(function() {
michael@0 595 AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
michael@0 596 "addon2@tests.mozilla.org",
michael@0 597 "addon4@tests.mozilla.org"],
michael@0 598 function([a1, a2, a4]) {
michael@0 599 is(a1.pendingOperations, 0, "Add-on 1 should not have any pending operations");
michael@0 600 is(a2.pendingOperations, 0, "Add-on 1 should not have any pending operations");
michael@0 601 is(a4.pendingOperations, 0, "Add-on 1 should not have any pending operations");
michael@0 602
michael@0 603 run_next_test();
michael@0 604 });
michael@0 605 });
michael@0 606
michael@0 607 // Check that upgrades with onExternalInstall take effect immediately
michael@0 608 add_test(function() {
michael@0 609 gProvider.createAddons([{
michael@0 610 id: "addon1@tests.mozilla.org",
michael@0 611 name: "Test add-on replacement",
michael@0 612 version: "2.0",
michael@0 613 description: "A test add-on with a new description",
michael@0 614 updateDate: gDate,
michael@0 615 operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
michael@0 616 }]);
michael@0 617
michael@0 618 let items = get_test_items();
michael@0 619 is(Object.keys(items).length, 9, "Should be nine add-ons installed");
michael@0 620
michael@0 621 let addon = items["Test add-on replacement"];
michael@0 622 addon.parentNode.ensureElementIsVisible(addon);
michael@0 623 is(get_node(addon, "name").value, "Test add-on replacement", "Name should be correct");
michael@0 624 is_element_visible(get_node(addon, "version"), "Version should be visible");
michael@0 625 is(get_node(addon, "version").value, "2.0", "Version should be correct");
michael@0 626 is_element_visible(get_node(addon, "description"), "Description should be visible");
michael@0 627 is(get_node(addon, "description").value, "A test add-on with a new description", "Description should be correct");
michael@0 628 is_element_hidden(get_class_node(addon, "disabled-postfix"), "Disabled postfix should be hidden");
michael@0 629 is_element_hidden(get_class_node(addon, "update-postfix"), "Update postfix should be hidden");
michael@0 630 is(get_node(addon, "date-updated").value, formatDate(gDate), "Update date should be correct");
michael@0 631
michael@0 632 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 633 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 634 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 635 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 636
michael@0 637 is_element_hidden(get_node(addon, "warning"), "Warning message should be hidden");
michael@0 638 is_element_hidden(get_node(addon, "warning-link"), "Warning link should be hidden");
michael@0 639 is_element_hidden(get_node(addon, "error"), "Error message should be hidden");
michael@0 640 is_element_hidden(get_node(addon, "error-link"), "Error link should be hidden");
michael@0 641 is_element_hidden(get_node(addon, "pending"), "Pending message should be hidden");
michael@0 642
michael@0 643 run_next_test();
michael@0 644 });
michael@0 645
michael@0 646 // Check that focus changes correctly move around the selected list item
michael@0 647 add_test(function() {
michael@0 648 function is_node_in_list(aNode) {
michael@0 649 var list = gManagerWindow.document.getElementById("addon-list");
michael@0 650
michael@0 651 while (aNode && aNode != list)
michael@0 652 aNode = aNode.parentNode;
michael@0 653
michael@0 654 if (aNode)
michael@0 655 return true;
michael@0 656 return false;
michael@0 657 }
michael@0 658
michael@0 659 // Ignore the OSX full keyboard access setting
michael@0 660 Services.prefs.setBoolPref("accessibility.tabfocus_applies_to_xul", false);
michael@0 661
michael@0 662 let items = get_test_items();
michael@0 663
michael@0 664 var fm = Cc["@mozilla.org/focus-manager;1"].
michael@0 665 getService(Ci.nsIFocusManager);
michael@0 666
michael@0 667 let addon = items["Test add-on 6"];
michael@0 668 EventUtils.synthesizeMouseAtCenter(addon, { }, gManagerWindow);
michael@0 669 is(fm.focusedElement, addon.parentNode, "Focus should have moved to the list");
michael@0 670
michael@0 671 EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
michael@0 672 is(fm.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
michael@0 673
michael@0 674 EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
michael@0 675 is(fm.focusedElement, get_node(addon, "disable-btn"), "Focus should have moved to the disable button");
michael@0 676
michael@0 677 EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
michael@0 678 is(fm.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
michael@0 679
michael@0 680 EventUtils.synthesizeKey("VK_TAB", { }, gManagerWindow);
michael@0 681 ok(!is_node_in_list(fm.focusedElement), "Focus should be outside the list");
michael@0 682
michael@0 683 EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
michael@0 684 is(fm.focusedElement, get_node(addon, "remove-btn"), "Focus should have moved to the remove button");
michael@0 685
michael@0 686 EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
michael@0 687 EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
michael@0 688 is(fm.focusedElement, get_node(addon, "details-btn"), "Focus should have moved to the more button");
michael@0 689
michael@0 690 EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
michael@0 691 is(fm.focusedElement, addon.parentNode, "Focus should have moved to the list");
michael@0 692
michael@0 693 EventUtils.synthesizeKey("VK_TAB", { shiftKey: true }, gManagerWindow);
michael@0 694 ok(!is_node_in_list(fm.focusedElement), "Focus should be outside the list");
michael@0 695
michael@0 696 try {
michael@0 697 Services.prefs.clearUserPref("accessibility.tabfocus_applies_to_xul");
michael@0 698 }
michael@0 699 catch (e) { }
michael@0 700
michael@0 701 run_next_test();
michael@0 702 });
michael@0 703
michael@0 704
michael@0 705 add_test(function() {
michael@0 706 info("Enabling lightweight theme");
michael@0 707 LightweightThemeManager.currentTheme = gLWTheme;
michael@0 708
michael@0 709 gManagerWindow.loadView("addons://list/theme");
michael@0 710 wait_for_view_load(gManagerWindow, function() {
michael@0 711 var addon = get_addon_element(gManagerWindow, "4@personas.mozilla.org");
michael@0 712
michael@0 713 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 714 is_element_hidden(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 715 is_element_visible(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 716 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 717
michael@0 718 info("Disabling lightweight theme");
michael@0 719 LightweightThemeManager.currentTheme = null;
michael@0 720
michael@0 721 is_element_hidden(get_node(addon, "preferences-btn"), "Preferences button should be hidden");
michael@0 722 is_element_visible(get_node(addon, "enable-btn"), "Enable button should be hidden");
michael@0 723 is_element_hidden(get_node(addon, "disable-btn"), "Disable button should be visible");
michael@0 724 is_element_visible(get_node(addon, "remove-btn"), "Remove button should be visible");
michael@0 725
michael@0 726 AddonManager.getAddonByID("4@personas.mozilla.org", function(aAddon) {
michael@0 727 aAddon.uninstall();
michael@0 728 run_next_test();
michael@0 729 });
michael@0 730 });
michael@0 731 });
michael@0 732
michael@0 733 // Check that onPropertyChanges for appDisabled updates the UI
michael@0 734 add_test(function() {
michael@0 735 info("Checking that onPropertyChanges for appDisabled updates the UI");
michael@0 736
michael@0 737 AddonManager.getAddonByID("addon2@tests.mozilla.org", function(aAddon) {
michael@0 738 aAddon.userDisabled = true;
michael@0 739 aAddon.isCompatible = true;
michael@0 740 aAddon.appDisabled = false;
michael@0 741
michael@0 742 gManagerWindow.loadView("addons://list/extension");
michael@0 743 wait_for_view_load(gManagerWindow, function() {
michael@0 744 var el = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org");
michael@0 745
michael@0 746 is(el.getAttribute("active"), "false", "Addon should not be marked as active");
michael@0 747 is_element_hidden(get_node(el, "warning"), "Warning message should not be visible");
michael@0 748
michael@0 749 info("Making addon incompatible and appDisabled");
michael@0 750 aAddon.isCompatible = false;
michael@0 751 aAddon.appDisabled = true;
michael@0 752
michael@0 753 is(el.getAttribute("active"), "false", "Addon should not be marked as active");
michael@0 754 is_element_visible(get_node(el, "warning"), "Warning message should be visible");
michael@0 755 is(get_node(el, "warning").textContent, "Test add-on 2 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
michael@0 756
michael@0 757 run_next_test();
michael@0 758 });
michael@0 759 });
michael@0 760 });

mercurial