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 that searching for add-ons works correctly |
michael@0 | 6 | |
michael@0 | 7 | var gManagerWindow; |
michael@0 | 8 | var gDocument; |
michael@0 | 9 | var gCategoryUtilities; |
michael@0 | 10 | var gProvider; |
michael@0 | 11 | |
michael@0 | 12 | function test() { |
michael@0 | 13 | requestLongerTimeout(2); |
michael@0 | 14 | waitForExplicitFinish(); |
michael@0 | 15 | |
michael@0 | 16 | gProvider = new MockProvider(); |
michael@0 | 17 | |
michael@0 | 18 | gProvider.createAddons([{ |
michael@0 | 19 | id: "addon1@tests.mozilla.org", |
michael@0 | 20 | name: "Uninstall needs restart", |
michael@0 | 21 | type: "extension", |
michael@0 | 22 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_UNINSTALL |
michael@0 | 23 | }, { |
michael@0 | 24 | id: "addon2@tests.mozilla.org", |
michael@0 | 25 | name: "Uninstall doesn't need restart 1", |
michael@0 | 26 | type: "extension", |
michael@0 | 27 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 28 | }, { |
michael@0 | 29 | id: "addon3@tests.mozilla.org", |
michael@0 | 30 | name: "Uninstall doesn't need restart 2", |
michael@0 | 31 | type: "extension", |
michael@0 | 32 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 33 | }, { |
michael@0 | 34 | id: "addon4@tests.mozilla.org", |
michael@0 | 35 | name: "Uninstall doesn't need restart 3", |
michael@0 | 36 | type: "extension", |
michael@0 | 37 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 38 | }, { |
michael@0 | 39 | id: "addon5@tests.mozilla.org", |
michael@0 | 40 | name: "Uninstall doesn't need restart 4", |
michael@0 | 41 | type: "extension", |
michael@0 | 42 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 43 | }, { |
michael@0 | 44 | id: "addon6@tests.mozilla.org", |
michael@0 | 45 | name: "Uninstall doesn't need restart 5", |
michael@0 | 46 | type: "extension", |
michael@0 | 47 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 48 | }, { |
michael@0 | 49 | id: "addon7@tests.mozilla.org", |
michael@0 | 50 | name: "Uninstall doesn't need restart 6", |
michael@0 | 51 | type: "extension", |
michael@0 | 52 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 53 | }, { |
michael@0 | 54 | id: "addon8@tests.mozilla.org", |
michael@0 | 55 | name: "Uninstall doesn't need restart 7", |
michael@0 | 56 | type: "extension", |
michael@0 | 57 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 58 | }, { |
michael@0 | 59 | id: "addon9@tests.mozilla.org", |
michael@0 | 60 | name: "Uninstall doesn't need restart 8", |
michael@0 | 61 | type: "extension", |
michael@0 | 62 | operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE |
michael@0 | 63 | }]); |
michael@0 | 64 | |
michael@0 | 65 | open_manager(null, function(aWindow) { |
michael@0 | 66 | gManagerWindow = aWindow; |
michael@0 | 67 | gDocument = gManagerWindow.document; |
michael@0 | 68 | gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
michael@0 | 69 | run_next_test(); |
michael@0 | 70 | }); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function end_test() { |
michael@0 | 74 | close_manager(gManagerWindow, function() { |
michael@0 | 75 | finish(); |
michael@0 | 76 | }); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function get_item_in_list(aId, aList) { |
michael@0 | 80 | var item = aList.firstChild; |
michael@0 | 81 | while (item) { |
michael@0 | 82 | if ("mAddon" in item && item.mAddon.id == aId) { |
michael@0 | 83 | aList.ensureElementIsVisible(item); |
michael@0 | 84 | return item; |
michael@0 | 85 | } |
michael@0 | 86 | item = item.nextSibling; |
michael@0 | 87 | } |
michael@0 | 88 | return null; |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | // Tests that uninstalling a normal add-on from the list view can be undone |
michael@0 | 92 | add_test(function() { |
michael@0 | 93 | var ID = "addon1@tests.mozilla.org"; |
michael@0 | 94 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 95 | |
michael@0 | 96 | // Select the extensions category |
michael@0 | 97 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 98 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 99 | |
michael@0 | 100 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 101 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 102 | ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
michael@0 | 103 | |
michael@0 | 104 | var item = get_item_in_list(ID, list); |
michael@0 | 105 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 106 | |
michael@0 | 107 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 108 | isnot(button, null, "Should have a remove button"); |
michael@0 | 109 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 110 | |
michael@0 | 111 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 112 | |
michael@0 | 113 | // Force XBL to apply |
michael@0 | 114 | item.clientTop; |
michael@0 | 115 | |
michael@0 | 116 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 117 | |
michael@0 | 118 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 119 | |
michael@0 | 120 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 121 | isnot(button, null, "Should have a restart button"); |
michael@0 | 122 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 123 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 124 | isnot(button, null, "Should have an undo button"); |
michael@0 | 125 | |
michael@0 | 126 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 127 | |
michael@0 | 128 | // Force XBL to apply |
michael@0 | 129 | item.clientTop; |
michael@0 | 130 | |
michael@0 | 131 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 132 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 133 | isnot(button, null, "Should have a remove button"); |
michael@0 | 134 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 135 | |
michael@0 | 136 | run_next_test(); |
michael@0 | 137 | }); |
michael@0 | 138 | }); |
michael@0 | 139 | }); |
michael@0 | 140 | |
michael@0 | 141 | // Tests that uninstalling a restartless add-on from the list view can be undone |
michael@0 | 142 | add_test(function() { |
michael@0 | 143 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 144 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 145 | |
michael@0 | 146 | // Select the extensions category |
michael@0 | 147 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 148 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 149 | |
michael@0 | 150 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 151 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 152 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 153 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 154 | |
michael@0 | 155 | var item = get_item_in_list(ID, list); |
michael@0 | 156 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 157 | |
michael@0 | 158 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 159 | isnot(button, null, "Should have a remove button"); |
michael@0 | 160 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 161 | |
michael@0 | 162 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 163 | |
michael@0 | 164 | // Force XBL to apply |
michael@0 | 165 | item.clientTop; |
michael@0 | 166 | |
michael@0 | 167 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 168 | |
michael@0 | 169 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 170 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 171 | |
michael@0 | 172 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 173 | isnot(button, null, "Should have a restart button"); |
michael@0 | 174 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 175 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 176 | isnot(button, null, "Should have an undo button"); |
michael@0 | 177 | |
michael@0 | 178 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 179 | |
michael@0 | 180 | // Force XBL to apply |
michael@0 | 181 | item.clientTop; |
michael@0 | 182 | |
michael@0 | 183 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 184 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 185 | isnot(button, null, "Should have a remove button"); |
michael@0 | 186 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 187 | |
michael@0 | 188 | run_next_test(); |
michael@0 | 189 | }); |
michael@0 | 190 | }); |
michael@0 | 191 | }); |
michael@0 | 192 | |
michael@0 | 193 | // Tests that uninstalling a disabled restartless add-on from the list view can |
michael@0 | 194 | // be undone and doesn't re-enable |
michael@0 | 195 | add_test(function() { |
michael@0 | 196 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 197 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 198 | |
michael@0 | 199 | // Select the extensions category |
michael@0 | 200 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 201 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 202 | |
michael@0 | 203 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 204 | aAddon.userDisabled = true; |
michael@0 | 205 | |
michael@0 | 206 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 207 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 208 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 209 | |
michael@0 | 210 | var item = get_item_in_list(ID, list); |
michael@0 | 211 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 212 | |
michael@0 | 213 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 214 | isnot(button, null, "Should have a remove button"); |
michael@0 | 215 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 216 | |
michael@0 | 217 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 218 | |
michael@0 | 219 | // Force XBL to apply |
michael@0 | 220 | item.clientTop; |
michael@0 | 221 | |
michael@0 | 222 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 223 | |
michael@0 | 224 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 225 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 226 | |
michael@0 | 227 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 228 | isnot(button, null, "Should have a restart button"); |
michael@0 | 229 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 230 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 231 | isnot(button, null, "Should have an undo button"); |
michael@0 | 232 | |
michael@0 | 233 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 234 | |
michael@0 | 235 | // Force XBL to apply |
michael@0 | 236 | item.clientTop; |
michael@0 | 237 | |
michael@0 | 238 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 239 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 240 | isnot(button, null, "Should have a remove button"); |
michael@0 | 241 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 242 | |
michael@0 | 243 | aAddon.userDisabled = false; |
michael@0 | 244 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 245 | |
michael@0 | 246 | run_next_test(); |
michael@0 | 247 | }); |
michael@0 | 248 | }); |
michael@0 | 249 | }); |
michael@0 | 250 | |
michael@0 | 251 | // Tests that uninstalling a normal add-on from the search view can be undone |
michael@0 | 252 | add_test(function() { |
michael@0 | 253 | var ID = "addon1@tests.mozilla.org"; |
michael@0 | 254 | var list = gDocument.getElementById("search-list"); |
michael@0 | 255 | |
michael@0 | 256 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 257 | searchBox.value = "Uninstall"; |
michael@0 | 258 | |
michael@0 | 259 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 260 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 261 | |
michael@0 | 262 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 263 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 264 | |
michael@0 | 265 | // Make sure to show local add-ons |
michael@0 | 266 | EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
michael@0 | 267 | |
michael@0 | 268 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 269 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 270 | ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
michael@0 | 271 | |
michael@0 | 272 | var item = get_item_in_list(ID, list); |
michael@0 | 273 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 274 | |
michael@0 | 275 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 276 | isnot(button, null, "Should have a remove button"); |
michael@0 | 277 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 278 | |
michael@0 | 279 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 280 | |
michael@0 | 281 | // Force XBL to apply |
michael@0 | 282 | item.clientTop; |
michael@0 | 283 | |
michael@0 | 284 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 285 | |
michael@0 | 286 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 287 | |
michael@0 | 288 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 289 | isnot(button, null, "Should have a restart button"); |
michael@0 | 290 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 291 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 292 | isnot(button, null, "Should have an undo button"); |
michael@0 | 293 | |
michael@0 | 294 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 295 | |
michael@0 | 296 | // Force XBL to apply |
michael@0 | 297 | item.clientTop; |
michael@0 | 298 | |
michael@0 | 299 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 300 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 301 | isnot(button, null, "Should have a remove button"); |
michael@0 | 302 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 303 | |
michael@0 | 304 | run_next_test(); |
michael@0 | 305 | }); |
michael@0 | 306 | }); |
michael@0 | 307 | }); |
michael@0 | 308 | |
michael@0 | 309 | // Tests that uninstalling a restartless add-on from the search view can be undone |
michael@0 | 310 | add_test(function() { |
michael@0 | 311 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 312 | var list = gDocument.getElementById("search-list"); |
michael@0 | 313 | |
michael@0 | 314 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 315 | searchBox.value = "Uninstall"; |
michael@0 | 316 | |
michael@0 | 317 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 318 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 319 | |
michael@0 | 320 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 321 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 322 | |
michael@0 | 323 | // Make sure to show local add-ons |
michael@0 | 324 | EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
michael@0 | 325 | |
michael@0 | 326 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 327 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 328 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 329 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 330 | |
michael@0 | 331 | var item = get_item_in_list(ID, list); |
michael@0 | 332 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 333 | |
michael@0 | 334 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 335 | isnot(button, null, "Should have a remove button"); |
michael@0 | 336 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 337 | |
michael@0 | 338 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 339 | |
michael@0 | 340 | // Force XBL to apply |
michael@0 | 341 | item.clientTop; |
michael@0 | 342 | |
michael@0 | 343 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 344 | |
michael@0 | 345 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 346 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 347 | |
michael@0 | 348 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 349 | isnot(button, null, "Should have a restart button"); |
michael@0 | 350 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 351 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 352 | isnot(button, null, "Should have an undo button"); |
michael@0 | 353 | |
michael@0 | 354 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 355 | |
michael@0 | 356 | // Force XBL to apply |
michael@0 | 357 | item.clientTop; |
michael@0 | 358 | |
michael@0 | 359 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 360 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 361 | isnot(button, null, "Should have a remove button"); |
michael@0 | 362 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 363 | |
michael@0 | 364 | run_next_test(); |
michael@0 | 365 | }); |
michael@0 | 366 | }); |
michael@0 | 367 | }); |
michael@0 | 368 | |
michael@0 | 369 | // Tests that uninstalling a disabled restartless add-on from the search view can |
michael@0 | 370 | // be undone and doesn't re-enable |
michael@0 | 371 | add_test(function() { |
michael@0 | 372 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 373 | var list = gDocument.getElementById("search-list"); |
michael@0 | 374 | |
michael@0 | 375 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 376 | searchBox.value = "Uninstall"; |
michael@0 | 377 | |
michael@0 | 378 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 379 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 380 | |
michael@0 | 381 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 382 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 383 | |
michael@0 | 384 | // Make sure to show local add-ons |
michael@0 | 385 | EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
michael@0 | 386 | |
michael@0 | 387 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 388 | aAddon.userDisabled = true; |
michael@0 | 389 | |
michael@0 | 390 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 391 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 392 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 393 | |
michael@0 | 394 | var item = get_item_in_list(ID, list); |
michael@0 | 395 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 396 | |
michael@0 | 397 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 398 | isnot(button, null, "Should have a remove button"); |
michael@0 | 399 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 400 | |
michael@0 | 401 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 402 | |
michael@0 | 403 | // Force XBL to apply |
michael@0 | 404 | item.clientTop; |
michael@0 | 405 | |
michael@0 | 406 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 407 | |
michael@0 | 408 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 409 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 410 | |
michael@0 | 411 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 412 | isnot(button, null, "Should have a restart button"); |
michael@0 | 413 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 414 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 415 | isnot(button, null, "Should have an undo button"); |
michael@0 | 416 | |
michael@0 | 417 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 418 | |
michael@0 | 419 | // Force XBL to apply |
michael@0 | 420 | item.clientTop; |
michael@0 | 421 | |
michael@0 | 422 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 423 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 424 | isnot(button, null, "Should have a remove button"); |
michael@0 | 425 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 426 | |
michael@0 | 427 | aAddon.userDisabled = false; |
michael@0 | 428 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 429 | |
michael@0 | 430 | run_next_test(); |
michael@0 | 431 | }); |
michael@0 | 432 | }); |
michael@0 | 433 | }); |
michael@0 | 434 | |
michael@0 | 435 | // Tests that uninstalling a normal add-on from the details view switches back |
michael@0 | 436 | // to the list view and can be undone |
michael@0 | 437 | add_test(function() { |
michael@0 | 438 | var ID = "addon1@tests.mozilla.org"; |
michael@0 | 439 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 440 | |
michael@0 | 441 | // Select the extensions category |
michael@0 | 442 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 443 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 444 | |
michael@0 | 445 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 446 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 447 | ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
michael@0 | 448 | |
michael@0 | 449 | var item = get_item_in_list(ID, list); |
michael@0 | 450 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 451 | |
michael@0 | 452 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
michael@0 | 453 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
michael@0 | 454 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 455 | is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); |
michael@0 | 456 | |
michael@0 | 457 | var button = gDocument.getElementById("detail-uninstall-btn"); |
michael@0 | 458 | isnot(button, null, "Should have a remove button"); |
michael@0 | 459 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 460 | |
michael@0 | 461 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 462 | |
michael@0 | 463 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 464 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 465 | |
michael@0 | 466 | var item = get_item_in_list(ID, list); |
michael@0 | 467 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 468 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 469 | |
michael@0 | 470 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 471 | |
michael@0 | 472 | // Force XBL to apply |
michael@0 | 473 | item.clientTop; |
michael@0 | 474 | |
michael@0 | 475 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 476 | isnot(button, null, "Should have a restart button"); |
michael@0 | 477 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 478 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 479 | isnot(button, null, "Should have an undo button"); |
michael@0 | 480 | |
michael@0 | 481 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 482 | |
michael@0 | 483 | // Force XBL to apply |
michael@0 | 484 | item.clientTop; |
michael@0 | 485 | |
michael@0 | 486 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 487 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 488 | isnot(button, null, "Should have a remove button"); |
michael@0 | 489 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 490 | |
michael@0 | 491 | run_next_test(); |
michael@0 | 492 | }); |
michael@0 | 493 | }); |
michael@0 | 494 | }); |
michael@0 | 495 | }); |
michael@0 | 496 | }); |
michael@0 | 497 | |
michael@0 | 498 | // Tests that uninstalling a restartless add-on from the details view switches |
michael@0 | 499 | // back to the list view and can be undone |
michael@0 | 500 | add_test(function() { |
michael@0 | 501 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 502 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 503 | |
michael@0 | 504 | // Select the extensions category |
michael@0 | 505 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 506 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 507 | |
michael@0 | 508 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 509 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 510 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 511 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 512 | |
michael@0 | 513 | var item = get_item_in_list(ID, list); |
michael@0 | 514 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 515 | |
michael@0 | 516 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
michael@0 | 517 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
michael@0 | 518 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 519 | is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); |
michael@0 | 520 | |
michael@0 | 521 | var button = gDocument.getElementById("detail-uninstall-btn"); |
michael@0 | 522 | isnot(button, null, "Should have a remove button"); |
michael@0 | 523 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 524 | |
michael@0 | 525 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 526 | |
michael@0 | 527 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 528 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 529 | |
michael@0 | 530 | var item = get_item_in_list(ID, list); |
michael@0 | 531 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 532 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 533 | |
michael@0 | 534 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 535 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 536 | |
michael@0 | 537 | // Force XBL to apply |
michael@0 | 538 | item.clientTop; |
michael@0 | 539 | |
michael@0 | 540 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 541 | isnot(button, null, "Should have a restart button"); |
michael@0 | 542 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 543 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 544 | isnot(button, null, "Should have an undo button"); |
michael@0 | 545 | |
michael@0 | 546 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 547 | |
michael@0 | 548 | // Force XBL to apply |
michael@0 | 549 | item.clientTop; |
michael@0 | 550 | |
michael@0 | 551 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 552 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 553 | isnot(button, null, "Should have a remove button"); |
michael@0 | 554 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 555 | |
michael@0 | 556 | run_next_test(); |
michael@0 | 557 | }); |
michael@0 | 558 | }); |
michael@0 | 559 | }); |
michael@0 | 560 | }); |
michael@0 | 561 | }); |
michael@0 | 562 | |
michael@0 | 563 | // Tests that uninstalling a restartless add-on from the details view switches |
michael@0 | 564 | // back to the list view and can be undone and doesn't re-enable |
michael@0 | 565 | add_test(function() { |
michael@0 | 566 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 567 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 568 | |
michael@0 | 569 | // Select the extensions category |
michael@0 | 570 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 571 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 572 | |
michael@0 | 573 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 574 | aAddon.userDisabled = true; |
michael@0 | 575 | |
michael@0 | 576 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 577 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 578 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 579 | |
michael@0 | 580 | var item = get_item_in_list(ID, list); |
michael@0 | 581 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 582 | |
michael@0 | 583 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow); |
michael@0 | 584 | EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow); |
michael@0 | 585 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 586 | is(gDocument.getElementById("view-port").selectedPanel.id, "detail-view", "Should be in the detail view"); |
michael@0 | 587 | |
michael@0 | 588 | var button = gDocument.getElementById("detail-uninstall-btn"); |
michael@0 | 589 | isnot(button, null, "Should have a remove button"); |
michael@0 | 590 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 591 | |
michael@0 | 592 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 593 | |
michael@0 | 594 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 595 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 596 | |
michael@0 | 597 | var item = get_item_in_list(ID, list); |
michael@0 | 598 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 599 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 600 | |
michael@0 | 601 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 602 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 603 | |
michael@0 | 604 | // Force XBL to apply |
michael@0 | 605 | item.clientTop; |
michael@0 | 606 | |
michael@0 | 607 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 608 | isnot(button, null, "Should have a restart button"); |
michael@0 | 609 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 610 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 611 | isnot(button, null, "Should have an undo button"); |
michael@0 | 612 | |
michael@0 | 613 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 614 | |
michael@0 | 615 | // Force XBL to apply |
michael@0 | 616 | item.clientTop; |
michael@0 | 617 | |
michael@0 | 618 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 619 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 620 | isnot(button, null, "Should have a remove button"); |
michael@0 | 621 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 622 | |
michael@0 | 623 | aAddon.userDisabled = false; |
michael@0 | 624 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 625 | |
michael@0 | 626 | run_next_test(); |
michael@0 | 627 | }); |
michael@0 | 628 | }); |
michael@0 | 629 | }); |
michael@0 | 630 | }); |
michael@0 | 631 | }); |
michael@0 | 632 | |
michael@0 | 633 | // Tests that a normal add-on pending uninstall shows up in the list view |
michael@0 | 634 | add_test(function() { |
michael@0 | 635 | var ID = "addon1@tests.mozilla.org"; |
michael@0 | 636 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 637 | |
michael@0 | 638 | // Select the extensions category |
michael@0 | 639 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 640 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 641 | |
michael@0 | 642 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 643 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 644 | ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
michael@0 | 645 | |
michael@0 | 646 | var item = get_item_in_list(ID, list); |
michael@0 | 647 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 648 | |
michael@0 | 649 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 650 | isnot(button, null, "Should have a remove button"); |
michael@0 | 651 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 652 | |
michael@0 | 653 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 654 | |
michael@0 | 655 | // Force XBL to apply |
michael@0 | 656 | item.clientTop; |
michael@0 | 657 | |
michael@0 | 658 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 659 | |
michael@0 | 660 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 661 | |
michael@0 | 662 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 663 | isnot(button, null, "Should have a restart button"); |
michael@0 | 664 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 665 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 666 | isnot(button, null, "Should have an undo button"); |
michael@0 | 667 | |
michael@0 | 668 | gCategoryUtilities.openType("plugin", function() { |
michael@0 | 669 | is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin"); |
michael@0 | 670 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 671 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 672 | |
michael@0 | 673 | var item = get_item_in_list(ID, list); |
michael@0 | 674 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 675 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 676 | |
michael@0 | 677 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 678 | |
michael@0 | 679 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 680 | isnot(button, null, "Should have a restart button"); |
michael@0 | 681 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 682 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 683 | isnot(button, null, "Should have an undo button"); |
michael@0 | 684 | |
michael@0 | 685 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 686 | |
michael@0 | 687 | // Force XBL to apply |
michael@0 | 688 | item.clientTop; |
michael@0 | 689 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 690 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 691 | isnot(button, null, "Should have a remove button"); |
michael@0 | 692 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 693 | |
michael@0 | 694 | run_next_test(); |
michael@0 | 695 | }); |
michael@0 | 696 | }); |
michael@0 | 697 | }); |
michael@0 | 698 | }); |
michael@0 | 699 | }); |
michael@0 | 700 | |
michael@0 | 701 | // Tests that a normal add-on pending uninstall shows up in the search view |
michael@0 | 702 | add_test(function() { |
michael@0 | 703 | var ID = "addon1@tests.mozilla.org"; |
michael@0 | 704 | var list = gDocument.getElementById("search-list"); |
michael@0 | 705 | |
michael@0 | 706 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 707 | searchBox.value = "Uninstall"; |
michael@0 | 708 | |
michael@0 | 709 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 710 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 711 | |
michael@0 | 712 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 713 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 714 | |
michael@0 | 715 | // Make sure to show local add-ons |
michael@0 | 716 | EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
michael@0 | 717 | |
michael@0 | 718 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 719 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 720 | ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall"); |
michael@0 | 721 | |
michael@0 | 722 | var item = get_item_in_list(ID, list); |
michael@0 | 723 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 724 | |
michael@0 | 725 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 726 | isnot(button, null, "Should have a remove button"); |
michael@0 | 727 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 728 | |
michael@0 | 729 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 730 | |
michael@0 | 731 | // Force XBL to apply |
michael@0 | 732 | item.clientTop; |
michael@0 | 733 | |
michael@0 | 734 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 735 | |
michael@0 | 736 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 737 | |
michael@0 | 738 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 739 | isnot(button, null, "Should have a restart button"); |
michael@0 | 740 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 741 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 742 | isnot(button, null, "Should have an undo button"); |
michael@0 | 743 | |
michael@0 | 744 | gCategoryUtilities.openType("plugin", function() { |
michael@0 | 745 | is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin"); |
michael@0 | 746 | searchBox.value = "Uninstall"; |
michael@0 | 747 | |
michael@0 | 748 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 749 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 750 | |
michael@0 | 751 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 752 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 753 | |
michael@0 | 754 | var item = get_item_in_list(ID, list); |
michael@0 | 755 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 756 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 757 | |
michael@0 | 758 | ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall"); |
michael@0 | 759 | |
michael@0 | 760 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 761 | isnot(button, null, "Should have a restart button"); |
michael@0 | 762 | ok(!button.hidden, "Restart button should not be hidden"); |
michael@0 | 763 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 764 | isnot(button, null, "Should have an undo button"); |
michael@0 | 765 | |
michael@0 | 766 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 767 | |
michael@0 | 768 | // Force XBL to apply |
michael@0 | 769 | item.clientTop; |
michael@0 | 770 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 771 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 772 | isnot(button, null, "Should have a remove button"); |
michael@0 | 773 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 774 | |
michael@0 | 775 | run_next_test(); |
michael@0 | 776 | }); |
michael@0 | 777 | }); |
michael@0 | 778 | }); |
michael@0 | 779 | }); |
michael@0 | 780 | }); |
michael@0 | 781 | |
michael@0 | 782 | // Tests that switching away from the list view finalises the uninstall of |
michael@0 | 783 | // multiple restartless add-ons |
michael@0 | 784 | add_test(function() { |
michael@0 | 785 | var ID = "addon2@tests.mozilla.org"; |
michael@0 | 786 | var ID2 = "addon6@tests.mozilla.org"; |
michael@0 | 787 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 788 | |
michael@0 | 789 | // Select the extensions category |
michael@0 | 790 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 791 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 792 | |
michael@0 | 793 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 794 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 795 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 796 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 797 | |
michael@0 | 798 | var item = get_item_in_list(ID, list); |
michael@0 | 799 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 800 | |
michael@0 | 801 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 802 | isnot(button, null, "Should have a remove button"); |
michael@0 | 803 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 804 | |
michael@0 | 805 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 806 | |
michael@0 | 807 | // Force XBL to apply |
michael@0 | 808 | item.clientTop; |
michael@0 | 809 | |
michael@0 | 810 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 811 | |
michael@0 | 812 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 813 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 814 | |
michael@0 | 815 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 816 | isnot(button, null, "Should have a restart button"); |
michael@0 | 817 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 818 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 819 | isnot(button, null, "Should have an undo button"); |
michael@0 | 820 | |
michael@0 | 821 | item = get_item_in_list(ID2, list); |
michael@0 | 822 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 823 | |
michael@0 | 824 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 825 | isnot(button, null, "Should have a remove button"); |
michael@0 | 826 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 827 | |
michael@0 | 828 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 829 | |
michael@0 | 830 | gCategoryUtilities.openType("plugin", function() { |
michael@0 | 831 | is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension"); |
michael@0 | 832 | |
michael@0 | 833 | AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
michael@0 | 834 | is(aAddon, null, "Add-on should no longer be installed"); |
michael@0 | 835 | is(aAddon2, null, "Second add-on should no longer be installed"); |
michael@0 | 836 | |
michael@0 | 837 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 838 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 839 | |
michael@0 | 840 | var item = get_item_in_list(ID, list); |
michael@0 | 841 | is(item, null, "Should not have found the add-on in the list"); |
michael@0 | 842 | item = get_item_in_list(ID2, list); |
michael@0 | 843 | is(item, null, "Should not have found the second add-on in the list"); |
michael@0 | 844 | |
michael@0 | 845 | run_next_test(); |
michael@0 | 846 | }); |
michael@0 | 847 | }); |
michael@0 | 848 | }); |
michael@0 | 849 | }); |
michael@0 | 850 | }); |
michael@0 | 851 | }); |
michael@0 | 852 | |
michael@0 | 853 | // Tests that switching away from the search view finalises the uninstall of |
michael@0 | 854 | // multiple restartless add-ons |
michael@0 | 855 | add_test(function() { |
michael@0 | 856 | var ID = "addon3@tests.mozilla.org"; |
michael@0 | 857 | var ID2 = "addon7@tests.mozilla.org"; |
michael@0 | 858 | var list = gDocument.getElementById("search-list"); |
michael@0 | 859 | |
michael@0 | 860 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 861 | searchBox.value = "Uninstall"; |
michael@0 | 862 | |
michael@0 | 863 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 864 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 865 | |
michael@0 | 866 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 867 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 868 | |
michael@0 | 869 | // Make sure to show local add-ons |
michael@0 | 870 | EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
michael@0 | 871 | |
michael@0 | 872 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 873 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 874 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 875 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 876 | |
michael@0 | 877 | var item = get_item_in_list(ID, list); |
michael@0 | 878 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 879 | |
michael@0 | 880 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 881 | isnot(button, null, "Should have a remove button"); |
michael@0 | 882 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 883 | |
michael@0 | 884 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 885 | |
michael@0 | 886 | // Force XBL to apply |
michael@0 | 887 | item.clientTop; |
michael@0 | 888 | |
michael@0 | 889 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 890 | |
michael@0 | 891 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 892 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 893 | |
michael@0 | 894 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 895 | isnot(button, null, "Should have a restart button"); |
michael@0 | 896 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 897 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 898 | isnot(button, null, "Should have an undo button"); |
michael@0 | 899 | |
michael@0 | 900 | item = get_item_in_list(ID2, list); |
michael@0 | 901 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 902 | |
michael@0 | 903 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 904 | isnot(button, null, "Should have a remove button"); |
michael@0 | 905 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 906 | |
michael@0 | 907 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 908 | |
michael@0 | 909 | gCategoryUtilities.openType("plugin", function() { |
michael@0 | 910 | is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension"); |
michael@0 | 911 | |
michael@0 | 912 | AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
michael@0 | 913 | is(aAddon, null, "Add-on should no longer be installed"); |
michael@0 | 914 | is(aAddon2, null, "Second add-on should no longer be installed"); |
michael@0 | 915 | |
michael@0 | 916 | searchBox.value = "Uninstall"; |
michael@0 | 917 | |
michael@0 | 918 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 919 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 920 | |
michael@0 | 921 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 922 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 923 | |
michael@0 | 924 | var item = get_item_in_list(ID, list); |
michael@0 | 925 | is(item, null, "Should not have found the add-on in the list"); |
michael@0 | 926 | item = get_item_in_list(ID2, list); |
michael@0 | 927 | is(item, null, "Should not have found the second add-on in the list"); |
michael@0 | 928 | |
michael@0 | 929 | run_next_test(); |
michael@0 | 930 | }); |
michael@0 | 931 | }); |
michael@0 | 932 | }); |
michael@0 | 933 | }); |
michael@0 | 934 | }); |
michael@0 | 935 | }); |
michael@0 | 936 | |
michael@0 | 937 | // Tests that closing the manager from the list view finalises the uninstall of |
michael@0 | 938 | // multiple restartless add-ons |
michael@0 | 939 | add_test(function() { |
michael@0 | 940 | var ID = "addon4@tests.mozilla.org"; |
michael@0 | 941 | var ID2 = "addon8@tests.mozilla.org"; |
michael@0 | 942 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 943 | |
michael@0 | 944 | // Select the extensions category |
michael@0 | 945 | gCategoryUtilities.openType("extension", function() { |
michael@0 | 946 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 947 | |
michael@0 | 948 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 949 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 950 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 951 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 952 | |
michael@0 | 953 | var item = get_item_in_list(ID, list); |
michael@0 | 954 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 955 | |
michael@0 | 956 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 957 | isnot(button, null, "Should have a remove button"); |
michael@0 | 958 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 959 | |
michael@0 | 960 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 961 | |
michael@0 | 962 | // Force XBL to apply |
michael@0 | 963 | item.clientTop; |
michael@0 | 964 | |
michael@0 | 965 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 966 | |
michael@0 | 967 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 968 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 969 | |
michael@0 | 970 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 971 | isnot(button, null, "Should have a restart button"); |
michael@0 | 972 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 973 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 974 | isnot(button, null, "Should have an undo button"); |
michael@0 | 975 | |
michael@0 | 976 | item = get_item_in_list(ID2, list); |
michael@0 | 977 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 978 | |
michael@0 | 979 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 980 | isnot(button, null, "Should have a remove button"); |
michael@0 | 981 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 982 | |
michael@0 | 983 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 984 | |
michael@0 | 985 | close_manager(gManagerWindow, function() { |
michael@0 | 986 | AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
michael@0 | 987 | is(aAddon, null, "Add-on should no longer be installed"); |
michael@0 | 988 | is(aAddon2, null, "Second add-on should no longer be installed"); |
michael@0 | 989 | |
michael@0 | 990 | open_manager(null, function(aWindow) { |
michael@0 | 991 | gManagerWindow = aWindow; |
michael@0 | 992 | gDocument = gManagerWindow.document; |
michael@0 | 993 | gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
michael@0 | 994 | var list = gDocument.getElementById("addon-list"); |
michael@0 | 995 | |
michael@0 | 996 | is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension"); |
michael@0 | 997 | |
michael@0 | 998 | var item = get_item_in_list(ID, list); |
michael@0 | 999 | is(item, null, "Should not have found the add-on in the list"); |
michael@0 | 1000 | item = get_item_in_list(ID2, list); |
michael@0 | 1001 | is(item, null, "Should not have found the second add-on in the list"); |
michael@0 | 1002 | |
michael@0 | 1003 | run_next_test(); |
michael@0 | 1004 | }); |
michael@0 | 1005 | }); |
michael@0 | 1006 | }); |
michael@0 | 1007 | }); |
michael@0 | 1008 | }); |
michael@0 | 1009 | }); |
michael@0 | 1010 | |
michael@0 | 1011 | // Tests that closing the manager from the search view finalises the uninstall |
michael@0 | 1012 | // of multiple restartless add-ons |
michael@0 | 1013 | add_test(function() { |
michael@0 | 1014 | var ID = "addon5@tests.mozilla.org"; |
michael@0 | 1015 | var ID2 = "addon9@tests.mozilla.org"; |
michael@0 | 1016 | var list = gDocument.getElementById("search-list"); |
michael@0 | 1017 | |
michael@0 | 1018 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 1019 | searchBox.value = "Uninstall"; |
michael@0 | 1020 | |
michael@0 | 1021 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 1022 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 1023 | |
michael@0 | 1024 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 1025 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 1026 | |
michael@0 | 1027 | // Make sure to show local add-ons |
michael@0 | 1028 | EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow); |
michael@0 | 1029 | |
michael@0 | 1030 | AddonManager.getAddonByID(ID, function(aAddon) { |
michael@0 | 1031 | ok(aAddon.isActive, "Add-on should be active"); |
michael@0 | 1032 | ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall"); |
michael@0 | 1033 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 1034 | |
michael@0 | 1035 | var item = get_item_in_list(ID, list); |
michael@0 | 1036 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 1037 | |
michael@0 | 1038 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 1039 | isnot(button, null, "Should have a remove button"); |
michael@0 | 1040 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 1041 | |
michael@0 | 1042 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 1043 | |
michael@0 | 1044 | // Force XBL to apply |
michael@0 | 1045 | item.clientTop; |
michael@0 | 1046 | |
michael@0 | 1047 | is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling"); |
michael@0 | 1048 | |
michael@0 | 1049 | ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall"); |
michael@0 | 1050 | ok(!aAddon.isActive, "Add-on should be inactive"); |
michael@0 | 1051 | |
michael@0 | 1052 | var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn"); |
michael@0 | 1053 | isnot(button, null, "Should have a restart button"); |
michael@0 | 1054 | ok(button.hidden, "Restart button should be hidden"); |
michael@0 | 1055 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn"); |
michael@0 | 1056 | isnot(button, null, "Should have an undo button"); |
michael@0 | 1057 | |
michael@0 | 1058 | item = get_item_in_list(ID2, list); |
michael@0 | 1059 | isnot(item, null, "Should have found the add-on in the list"); |
michael@0 | 1060 | |
michael@0 | 1061 | button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn"); |
michael@0 | 1062 | isnot(button, null, "Should have a remove button"); |
michael@0 | 1063 | ok(!button.disabled, "Button should not be disabled"); |
michael@0 | 1064 | |
michael@0 | 1065 | EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow); |
michael@0 | 1066 | |
michael@0 | 1067 | close_manager(gManagerWindow, function() { |
michael@0 | 1068 | AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) { |
michael@0 | 1069 | is(aAddon, null, "Add-on should no longer be installed"); |
michael@0 | 1070 | is(aAddon2, null, "Second add-on should no longer be installed"); |
michael@0 | 1071 | |
michael@0 | 1072 | open_manager(null, function(aWindow) { |
michael@0 | 1073 | gManagerWindow = aWindow; |
michael@0 | 1074 | gDocument = gManagerWindow.document; |
michael@0 | 1075 | gCategoryUtilities = new CategoryUtilities(gManagerWindow); |
michael@0 | 1076 | var list = gDocument.getElementById("search-list"); |
michael@0 | 1077 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 1078 | |
michael@0 | 1079 | searchBox.value = "Uninstall"; |
michael@0 | 1080 | |
michael@0 | 1081 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 1082 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 1083 | |
michael@0 | 1084 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 1085 | is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search"); |
michael@0 | 1086 | |
michael@0 | 1087 | var item = get_item_in_list(ID, list); |
michael@0 | 1088 | is(item, null, "Should not have found the add-on in the list"); |
michael@0 | 1089 | item = get_item_in_list(ID2, list); |
michael@0 | 1090 | is(item, null, "Should not have found the second add-on in the list"); |
michael@0 | 1091 | |
michael@0 | 1092 | run_next_test(); |
michael@0 | 1093 | }); |
michael@0 | 1094 | }); |
michael@0 | 1095 | }); |
michael@0 | 1096 | }); |
michael@0 | 1097 | }); |
michael@0 | 1098 | }); |
michael@0 | 1099 | }); |