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 | // Bug 591465 - Context menu of add-ons miss context related state change entries |
michael@0 | 6 | |
michael@0 | 7 | |
michael@0 | 8 | let tempScope = {}; |
michael@0 | 9 | Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", tempScope); |
michael@0 | 10 | let LightweightThemeManager = tempScope.LightweightThemeManager; |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | const PREF_GETADDONS_MAXRESULTS = "extensions.getAddons.maxResults"; |
michael@0 | 14 | const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url"; |
michael@0 | 15 | const SEARCH_URL = TESTROOT + "browser_bug591465.xml"; |
michael@0 | 16 | const SEARCH_QUERY = "SEARCH"; |
michael@0 | 17 | |
michael@0 | 18 | var gManagerWindow; |
michael@0 | 19 | var gProvider; |
michael@0 | 20 | var gContextMenu; |
michael@0 | 21 | var gLWTheme = { |
michael@0 | 22 | id: "4", |
michael@0 | 23 | version: "1", |
michael@0 | 24 | name: "Bling", |
michael@0 | 25 | description: "SO MUCH BLING!", |
michael@0 | 26 | author: "Pixel Pusher", |
michael@0 | 27 | homepageURL: "http://mochi.test:8888/data/index.html", |
michael@0 | 28 | headerURL: "http://mochi.test:8888/data/header.png", |
michael@0 | 29 | footerURL: "http://mochi.test:8888/data/footer.png", |
michael@0 | 30 | previewURL: "http://mochi.test:8888/data/preview.png", |
michael@0 | 31 | iconURL: "http://mochi.test:8888/data/icon.png" |
michael@0 | 32 | }; |
michael@0 | 33 | |
michael@0 | 34 | |
michael@0 | 35 | function test() { |
michael@0 | 36 | waitForExplicitFinish(); |
michael@0 | 37 | |
michael@0 | 38 | gProvider = new MockProvider(); |
michael@0 | 39 | |
michael@0 | 40 | gProvider.createAddons([{ |
michael@0 | 41 | id: "addon1@tests.mozilla.org", |
michael@0 | 42 | name: "addon 1", |
michael@0 | 43 | version: "1.0" |
michael@0 | 44 | }, { |
michael@0 | 45 | id: "addon2@tests.mozilla.org", |
michael@0 | 46 | name: "addon 2", |
michael@0 | 47 | version: "1.0", |
michael@0 | 48 | _userDisabled: true |
michael@0 | 49 | }, { |
michael@0 | 50 | id: "theme1@tests.mozilla.org", |
michael@0 | 51 | name: "theme 1", |
michael@0 | 52 | version: "1.0", |
michael@0 | 53 | type: "theme" |
michael@0 | 54 | }, { |
michael@0 | 55 | id: "theme2@tests.mozilla.org", |
michael@0 | 56 | name: "theme 2", |
michael@0 | 57 | version: "1.0", |
michael@0 | 58 | type: "theme", |
michael@0 | 59 | _userDisabled: true |
michael@0 | 60 | }, { |
michael@0 | 61 | id: "theme3@tests.mozilla.org", |
michael@0 | 62 | name: "theme 3", |
michael@0 | 63 | version: "1.0", |
michael@0 | 64 | type: "theme", |
michael@0 | 65 | permissions: 0 |
michael@0 | 66 | }]); |
michael@0 | 67 | |
michael@0 | 68 | |
michael@0 | 69 | open_manager("addons://list/extension", function(aWindow) { |
michael@0 | 70 | gManagerWindow = aWindow; |
michael@0 | 71 | gContextMenu = aWindow.document.getElementById("addonitem-popup"); |
michael@0 | 72 | run_next_test(); |
michael@0 | 73 | }); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | |
michael@0 | 77 | function end_test() { |
michael@0 | 78 | close_manager(gManagerWindow, finish); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | |
michael@0 | 82 | function check_contextmenu(aIsTheme, aIsEnabled, aIsRemote, aIsDetails, aIsSingleItemCase) { |
michael@0 | 83 | if (aIsTheme || aIsEnabled || aIsRemote) |
michael@0 | 84 | is_element_hidden(gManagerWindow.document.getElementById("menuitem_enableItem"), |
michael@0 | 85 | "'Enable' should be hidden"); |
michael@0 | 86 | else |
michael@0 | 87 | is_element_visible(gManagerWindow.document.getElementById("menuitem_enableItem"), |
michael@0 | 88 | "'Enable' should be visible"); |
michael@0 | 89 | |
michael@0 | 90 | if (aIsTheme || !aIsEnabled || aIsRemote) |
michael@0 | 91 | is_element_hidden(gManagerWindow.document.getElementById("menuitem_disableItem"), |
michael@0 | 92 | "'Disable' should be hidden"); |
michael@0 | 93 | else |
michael@0 | 94 | is_element_visible(gManagerWindow.document.getElementById("menuitem_disableItem"), |
michael@0 | 95 | "'Disable' should be visible"); |
michael@0 | 96 | |
michael@0 | 97 | if (!aIsTheme || aIsEnabled || aIsRemote || aIsSingleItemCase) |
michael@0 | 98 | is_element_hidden(gManagerWindow.document.getElementById("menuitem_enableTheme"), |
michael@0 | 99 | "'Wear Theme' should be hidden"); |
michael@0 | 100 | else |
michael@0 | 101 | is_element_visible(gManagerWindow.document.getElementById("menuitem_enableTheme"), |
michael@0 | 102 | "'Wear Theme' should be visible"); |
michael@0 | 103 | |
michael@0 | 104 | if (!aIsTheme || !aIsEnabled || aIsRemote || aIsSingleItemCase) |
michael@0 | 105 | is_element_hidden(gManagerWindow.document.getElementById("menuitem_disableTheme"), |
michael@0 | 106 | "'Stop Wearing Theme' should be hidden"); |
michael@0 | 107 | else |
michael@0 | 108 | is_element_visible(gManagerWindow.document.getElementById("menuitem_disableTheme"), |
michael@0 | 109 | "'Stop Wearing Theme' should be visible"); |
michael@0 | 110 | |
michael@0 | 111 | if (aIsRemote) |
michael@0 | 112 | is_element_visible(gManagerWindow.document.getElementById("menuitem_installItem"), |
michael@0 | 113 | "'Install' should be visible"); |
michael@0 | 114 | else |
michael@0 | 115 | is_element_hidden(gManagerWindow.document.getElementById("menuitem_installItem"), |
michael@0 | 116 | "'Install' should be hidden"); |
michael@0 | 117 | |
michael@0 | 118 | if (aIsDetails) |
michael@0 | 119 | is_element_hidden(gManagerWindow.document.getElementById("menuitem_showDetails"), |
michael@0 | 120 | "'Show More Information' should be hidden in details view"); |
michael@0 | 121 | else |
michael@0 | 122 | is_element_visible(gManagerWindow.document.getElementById("menuitem_showDetails"), |
michael@0 | 123 | "'Show More Information' should be visible in list view"); |
michael@0 | 124 | |
michael@0 | 125 | if (aIsSingleItemCase) |
michael@0 | 126 | is_element_hidden(gManagerWindow.document.getElementById("addonitem-menuseparator"), |
michael@0 | 127 | "Menu separator should be hidden with only one menu item"); |
michael@0 | 128 | else |
michael@0 | 129 | is_element_visible(gManagerWindow.document.getElementById("addonitem-menuseparator"), |
michael@0 | 130 | "Menu separator should be visible with multiple menu items"); |
michael@0 | 131 | |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | |
michael@0 | 135 | add_test(function() { |
michael@0 | 136 | var el = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); |
michael@0 | 137 | isnot(el, null, "Should have found addon element"); |
michael@0 | 138 | |
michael@0 | 139 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 140 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 141 | |
michael@0 | 142 | check_contextmenu(false, true, false, false, false); |
michael@0 | 143 | |
michael@0 | 144 | gContextMenu.hidePopup(); |
michael@0 | 145 | run_next_test(); |
michael@0 | 146 | }, false); |
michael@0 | 147 | |
michael@0 | 148 | info("Opening context menu on enabled extension item"); |
michael@0 | 149 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 150 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 151 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 152 | }); |
michael@0 | 153 | |
michael@0 | 154 | add_test(function() { |
michael@0 | 155 | var el = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); |
michael@0 | 156 | isnot(el, null, "Should have found addon element"); |
michael@0 | 157 | el.mAddon.userDisabled = true; |
michael@0 | 158 | |
michael@0 | 159 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 160 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 161 | |
michael@0 | 162 | check_contextmenu(false, false, false, false, false); |
michael@0 | 163 | |
michael@0 | 164 | gContextMenu.hidePopup(); |
michael@0 | 165 | run_next_test(); |
michael@0 | 166 | }, false); |
michael@0 | 167 | |
michael@0 | 168 | info("Opening context menu on newly disabled extension item"); |
michael@0 | 169 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 170 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 171 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 172 | }); |
michael@0 | 173 | |
michael@0 | 174 | add_test(function() { |
michael@0 | 175 | var el = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org"); |
michael@0 | 176 | isnot(el, null, "Should have found addon element"); |
michael@0 | 177 | el.mAddon.userDisabled = false; |
michael@0 | 178 | |
michael@0 | 179 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 180 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 181 | |
michael@0 | 182 | check_contextmenu(false, true, false, false, false); |
michael@0 | 183 | |
michael@0 | 184 | gContextMenu.hidePopup(); |
michael@0 | 185 | run_next_test(); |
michael@0 | 186 | }, false); |
michael@0 | 187 | |
michael@0 | 188 | info("Opening context menu on newly enabled extension item"); |
michael@0 | 189 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 190 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 191 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 192 | }); |
michael@0 | 193 | |
michael@0 | 194 | add_test(function() { |
michael@0 | 195 | var el = get_addon_element(gManagerWindow, "addon2@tests.mozilla.org"); |
michael@0 | 196 | |
michael@0 | 197 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 198 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 199 | |
michael@0 | 200 | check_contextmenu(false, false, false, false, false); |
michael@0 | 201 | |
michael@0 | 202 | gContextMenu.hidePopup(); |
michael@0 | 203 | run_next_test(); |
michael@0 | 204 | }, false); |
michael@0 | 205 | |
michael@0 | 206 | info("Opening context menu on disabled extension item"); |
michael@0 | 207 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 208 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 209 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 210 | }); |
michael@0 | 211 | |
michael@0 | 212 | |
michael@0 | 213 | add_test(function() { |
michael@0 | 214 | gManagerWindow.loadView("addons://list/theme"); |
michael@0 | 215 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 216 | var el = get_addon_element(gManagerWindow, "theme1@tests.mozilla.org"); |
michael@0 | 217 | |
michael@0 | 218 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 219 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 220 | |
michael@0 | 221 | check_contextmenu(true, true, false, false, false); |
michael@0 | 222 | |
michael@0 | 223 | gContextMenu.hidePopup(); |
michael@0 | 224 | run_next_test(); |
michael@0 | 225 | }, false); |
michael@0 | 226 | |
michael@0 | 227 | info("Opening context menu on enabled theme item"); |
michael@0 | 228 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 229 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 230 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 231 | }); |
michael@0 | 232 | }); |
michael@0 | 233 | |
michael@0 | 234 | |
michael@0 | 235 | add_test(function() { |
michael@0 | 236 | var el = get_addon_element(gManagerWindow, "theme2@tests.mozilla.org"); |
michael@0 | 237 | |
michael@0 | 238 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 239 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 240 | |
michael@0 | 241 | check_contextmenu(true, false, false, false, false); |
michael@0 | 242 | |
michael@0 | 243 | gContextMenu.hidePopup(); |
michael@0 | 244 | run_next_test(); |
michael@0 | 245 | }, false); |
michael@0 | 246 | |
michael@0 | 247 | info("Opening context menu on disabled theme item"); |
michael@0 | 248 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 249 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 250 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 251 | }); |
michael@0 | 252 | |
michael@0 | 253 | |
michael@0 | 254 | add_test(function() { |
michael@0 | 255 | LightweightThemeManager.currentTheme = gLWTheme; |
michael@0 | 256 | |
michael@0 | 257 | var el = get_addon_element(gManagerWindow, "4@personas.mozilla.org"); |
michael@0 | 258 | |
michael@0 | 259 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 260 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 261 | |
michael@0 | 262 | check_contextmenu(true, true, false, false, false); |
michael@0 | 263 | |
michael@0 | 264 | gContextMenu.hidePopup(); |
michael@0 | 265 | run_next_test(); |
michael@0 | 266 | }, false); |
michael@0 | 267 | |
michael@0 | 268 | info("Opening context menu on enabled LW theme item"); |
michael@0 | 269 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 270 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 271 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 272 | }); |
michael@0 | 273 | |
michael@0 | 274 | |
michael@0 | 275 | add_test(function() { |
michael@0 | 276 | LightweightThemeManager.currentTheme = null; |
michael@0 | 277 | |
michael@0 | 278 | var el = get_addon_element(gManagerWindow, "4@personas.mozilla.org"); |
michael@0 | 279 | |
michael@0 | 280 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 281 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 282 | |
michael@0 | 283 | check_contextmenu(true, false, false, false, false); |
michael@0 | 284 | |
michael@0 | 285 | gContextMenu.hidePopup(); |
michael@0 | 286 | run_next_test(); |
michael@0 | 287 | }, false); |
michael@0 | 288 | |
michael@0 | 289 | info("Opening context menu on disabled LW theme item"); |
michael@0 | 290 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 291 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 292 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 293 | }); |
michael@0 | 294 | |
michael@0 | 295 | |
michael@0 | 296 | add_test(function() { |
michael@0 | 297 | LightweightThemeManager.currentTheme = gLWTheme; |
michael@0 | 298 | |
michael@0 | 299 | gManagerWindow.loadView("addons://detail/4@personas.mozilla.org"); |
michael@0 | 300 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 301 | |
michael@0 | 302 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 303 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 304 | |
michael@0 | 305 | check_contextmenu(true, true, false, true, false); |
michael@0 | 306 | |
michael@0 | 307 | gContextMenu.hidePopup(); |
michael@0 | 308 | run_next_test(); |
michael@0 | 309 | }, false); |
michael@0 | 310 | |
michael@0 | 311 | info("Opening context menu on enabled LW theme, in detail view"); |
michael@0 | 312 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 313 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 314 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 315 | }); |
michael@0 | 316 | }); |
michael@0 | 317 | |
michael@0 | 318 | |
michael@0 | 319 | add_test(function() { |
michael@0 | 320 | LightweightThemeManager.currentTheme = null; |
michael@0 | 321 | |
michael@0 | 322 | gManagerWindow.loadView("addons://detail/4@personas.mozilla.org"); |
michael@0 | 323 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 324 | |
michael@0 | 325 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 326 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 327 | |
michael@0 | 328 | check_contextmenu(true, false, false, true, false); |
michael@0 | 329 | |
michael@0 | 330 | gContextMenu.hidePopup(); |
michael@0 | 331 | |
michael@0 | 332 | AddonManager.getAddonByID("4@personas.mozilla.org", function(aAddon) { |
michael@0 | 333 | aAddon.uninstall(); |
michael@0 | 334 | run_next_test(); |
michael@0 | 335 | }); |
michael@0 | 336 | }, false); |
michael@0 | 337 | |
michael@0 | 338 | info("Opening context menu on disabled LW theme, in detail view"); |
michael@0 | 339 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 340 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 341 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 342 | }); |
michael@0 | 343 | }); |
michael@0 | 344 | |
michael@0 | 345 | |
michael@0 | 346 | add_test(function() { |
michael@0 | 347 | gManagerWindow.loadView("addons://detail/addon1@tests.mozilla.org"); |
michael@0 | 348 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 349 | |
michael@0 | 350 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 351 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 352 | |
michael@0 | 353 | check_contextmenu(false, true, false, true, false); |
michael@0 | 354 | |
michael@0 | 355 | gContextMenu.hidePopup(); |
michael@0 | 356 | run_next_test(); |
michael@0 | 357 | }, false); |
michael@0 | 358 | |
michael@0 | 359 | info("Opening context menu on enabled extension, in detail view"); |
michael@0 | 360 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 361 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 362 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 363 | }); |
michael@0 | 364 | }); |
michael@0 | 365 | |
michael@0 | 366 | |
michael@0 | 367 | add_test(function() { |
michael@0 | 368 | gManagerWindow.loadView("addons://detail/addon2@tests.mozilla.org"); |
michael@0 | 369 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 370 | |
michael@0 | 371 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 372 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 373 | |
michael@0 | 374 | check_contextmenu(false, false, false, true, false); |
michael@0 | 375 | |
michael@0 | 376 | gContextMenu.hidePopup(); |
michael@0 | 377 | run_next_test(); |
michael@0 | 378 | }, false); |
michael@0 | 379 | |
michael@0 | 380 | info("Opening context menu on disabled extension, in detail view"); |
michael@0 | 381 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 382 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 383 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 384 | }); |
michael@0 | 385 | }); |
michael@0 | 386 | |
michael@0 | 387 | |
michael@0 | 388 | add_test(function() { |
michael@0 | 389 | gManagerWindow.loadView("addons://detail/theme1@tests.mozilla.org"); |
michael@0 | 390 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 391 | |
michael@0 | 392 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 393 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 394 | |
michael@0 | 395 | check_contextmenu(true, true, false, true, false); |
michael@0 | 396 | |
michael@0 | 397 | gContextMenu.hidePopup(); |
michael@0 | 398 | run_next_test(); |
michael@0 | 399 | }, false); |
michael@0 | 400 | |
michael@0 | 401 | info("Opening context menu on enabled theme, in detail view"); |
michael@0 | 402 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 403 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 404 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 405 | }); |
michael@0 | 406 | }); |
michael@0 | 407 | |
michael@0 | 408 | |
michael@0 | 409 | add_test(function() { |
michael@0 | 410 | gManagerWindow.loadView("addons://detail/theme2@tests.mozilla.org"); |
michael@0 | 411 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 412 | |
michael@0 | 413 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 414 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 415 | |
michael@0 | 416 | check_contextmenu(true, false, false, true, false); |
michael@0 | 417 | |
michael@0 | 418 | gContextMenu.hidePopup(); |
michael@0 | 419 | run_next_test(); |
michael@0 | 420 | }, false); |
michael@0 | 421 | |
michael@0 | 422 | info("Opening context menu on disabled theme, in detail view"); |
michael@0 | 423 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 424 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 425 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 426 | }); |
michael@0 | 427 | }); |
michael@0 | 428 | |
michael@0 | 429 | add_test(function() { |
michael@0 | 430 | gManagerWindow.loadView("addons://detail/theme3@tests.mozilla.org"); |
michael@0 | 431 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 432 | |
michael@0 | 433 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 434 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 435 | |
michael@0 | 436 | check_contextmenu(true, true, false, true, true); |
michael@0 | 437 | |
michael@0 | 438 | gContextMenu.hidePopup(); |
michael@0 | 439 | run_next_test(); |
michael@0 | 440 | }, false); |
michael@0 | 441 | |
michael@0 | 442 | info("Opening context menu with single menu item on enabled theme, in detail view"); |
michael@0 | 443 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 444 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 445 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 446 | }); |
michael@0 | 447 | }); |
michael@0 | 448 | |
michael@0 | 449 | add_test(function() { |
michael@0 | 450 | info("Searching for remote addons"); |
michael@0 | 451 | |
michael@0 | 452 | Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL); |
michael@0 | 453 | Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15); |
michael@0 | 454 | |
michael@0 | 455 | var searchBox = gManagerWindow.document.getElementById("header-search"); |
michael@0 | 456 | searchBox.value = SEARCH_QUERY; |
michael@0 | 457 | |
michael@0 | 458 | EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow); |
michael@0 | 459 | EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow); |
michael@0 | 460 | |
michael@0 | 461 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 462 | var filter = gManagerWindow.document.getElementById("search-filter-remote"); |
michael@0 | 463 | EventUtils.synthesizeMouseAtCenter(filter, { }, gManagerWindow); |
michael@0 | 464 | executeSoon(function() { |
michael@0 | 465 | |
michael@0 | 466 | var el = get_addon_element(gManagerWindow, "remote1@tests.mozilla.org"); |
michael@0 | 467 | |
michael@0 | 468 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 469 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 470 | |
michael@0 | 471 | check_contextmenu(false, false, true, false, false); |
michael@0 | 472 | |
michael@0 | 473 | gContextMenu.hidePopup(); |
michael@0 | 474 | run_next_test(); |
michael@0 | 475 | }, false); |
michael@0 | 476 | |
michael@0 | 477 | info("Opening context menu on remote extension item"); |
michael@0 | 478 | el.parentNode.ensureElementIsVisible(el); |
michael@0 | 479 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 480 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 481 | |
michael@0 | 482 | }); |
michael@0 | 483 | }); |
michael@0 | 484 | }); |
michael@0 | 485 | |
michael@0 | 486 | |
michael@0 | 487 | add_test(function() { |
michael@0 | 488 | gManagerWindow.loadView("addons://detail/remote1@tests.mozilla.org"); |
michael@0 | 489 | wait_for_view_load(gManagerWindow, function() { |
michael@0 | 490 | |
michael@0 | 491 | gContextMenu.addEventListener("popupshown", function() { |
michael@0 | 492 | gContextMenu.removeEventListener("popupshown", arguments.callee, false); |
michael@0 | 493 | |
michael@0 | 494 | check_contextmenu(false, false, true, true, false); |
michael@0 | 495 | |
michael@0 | 496 | gContextMenu.hidePopup(); |
michael@0 | 497 | |
michael@0 | 498 | // Delete the created install |
michael@0 | 499 | AddonManager.getAllInstalls(function(aInstalls) { |
michael@0 | 500 | is(aInstalls.length, 1, "Should be one available install"); |
michael@0 | 501 | aInstalls[0].cancel(); |
michael@0 | 502 | |
michael@0 | 503 | run_next_test(); |
michael@0 | 504 | }); |
michael@0 | 505 | }, false); |
michael@0 | 506 | |
michael@0 | 507 | info("Opening context menu on remote extension, in detail view"); |
michael@0 | 508 | var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container"); |
michael@0 | 509 | EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow); |
michael@0 | 510 | EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow); |
michael@0 | 511 | }); |
michael@0 | 512 | }); |