Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Tests for browser context menu</title> |
michael@0 | 5 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 7 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 8 | <script type="text/javascript" src="head_plain.js"></script> |
michael@0 | 9 | </head> |
michael@0 | 10 | <body> |
michael@0 | 11 | Browser context menu tests. |
michael@0 | 12 | <p id="display"></p> |
michael@0 | 13 | |
michael@0 | 14 | <div id="content"> |
michael@0 | 15 | </div> |
michael@0 | 16 | |
michael@0 | 17 | <pre id="test"> |
michael@0 | 18 | <script> var perWindowPrivateBrowsing = false; </script> |
michael@0 | 19 | <script type="text/javascript" src="privateBrowsingMode.js"></script> |
michael@0 | 20 | <script type="text/javascript" src="contextmenu_common.js"></script> |
michael@0 | 21 | <script class="testbody" type="text/javascript"> |
michael@0 | 22 | |
michael@0 | 23 | SpecialPowers.Cu.import("resource://gre/modules/InlineSpellChecker.jsm", window); |
michael@0 | 24 | SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window); |
michael@0 | 25 | |
michael@0 | 26 | const Ci = SpecialPowers.Ci; |
michael@0 | 27 | |
michael@0 | 28 | function executeCopyCommand(command, expectedValue) |
michael@0 | 29 | { |
michael@0 | 30 | // Just execute the command directly rather than simulating a context menu |
michael@0 | 31 | // press to avoid having to deal with its asynchronous nature |
michael@0 | 32 | SpecialPowers.wrap(subwindow).controllers.getControllerForCommand(command).doCommand(command); |
michael@0 | 33 | |
michael@0 | 34 | // The easiest way to check the clipboard is to paste the contents into a |
michael@0 | 35 | // textbox |
michael@0 | 36 | input.focus(); |
michael@0 | 37 | input.value = ""; |
michael@0 | 38 | SpecialPowers.wrap(input).controllers.getControllerForCommand("cmd_paste").doCommand("cmd_paste"); |
michael@0 | 39 | is(input.value, expectedValue, "paste for command " + command); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function invokeItemAction(generatedItemId) |
michael@0 | 43 | { |
michael@0 | 44 | var item = contextMenu.getElementsByAttribute("generateditemid", |
michael@0 | 45 | generatedItemId)[0]; |
michael@0 | 46 | ok(item, "Got generated XUL menu item"); |
michael@0 | 47 | item.doCommand(); |
michael@0 | 48 | ok(!pagemenu.hasAttribute("hopeless"), "attribute got removed"); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function selectText(element) { |
michael@0 | 52 | // Clear any previous selections before selecting new element. |
michael@0 | 53 | subwindow.getSelection().removeAllRanges(); |
michael@0 | 54 | |
michael@0 | 55 | var div = subwindow.document.createRange(); |
michael@0 | 56 | div.setStartBefore(element); |
michael@0 | 57 | div.setEndAfter(element); |
michael@0 | 58 | subwindow.getSelection().addRange(div); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function selectInputText(element) { |
michael@0 | 62 | // Clear any previous selections before selecting new element. |
michael@0 | 63 | subwindow.getSelection().removeAllRanges(); |
michael@0 | 64 | |
michael@0 | 65 | element.select(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | /* |
michael@0 | 69 | * runTest |
michael@0 | 70 | * |
michael@0 | 71 | * Called by a popupshowing event handler. Each test checks for expected menu |
michael@0 | 72 | * contents, closes the popup, and finally triggers the popup on a new element |
michael@0 | 73 | * (thus kicking off another cycle). |
michael@0 | 74 | * |
michael@0 | 75 | */ |
michael@0 | 76 | function runTest(testNum) { |
michael@0 | 77 | // Seems we need to enable this again, or sendKeyEvent() complaints. |
michael@0 | 78 | ok(true, "Starting test #" + testNum); |
michael@0 | 79 | |
michael@0 | 80 | var inspectItems = []; |
michael@0 | 81 | if (SpecialPowers.getBoolPref("devtools.inspector.enabled")) { |
michael@0 | 82 | inspectItems = ["---", null, |
michael@0 | 83 | "context-inspect", true]; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | switch (testNum) { |
michael@0 | 87 | case 1: |
michael@0 | 88 | // Invoke context menu for next test. |
michael@0 | 89 | openContextMenuFor(text); |
michael@0 | 90 | break; |
michael@0 | 91 | |
michael@0 | 92 | case 2: |
michael@0 | 93 | // Context menu for plain text |
michael@0 | 94 | plainTextItems = ["context-back", false, |
michael@0 | 95 | "context-forward", false, |
michael@0 | 96 | "context-reload", true, |
michael@0 | 97 | "---", null, |
michael@0 | 98 | "context-bookmarkpage", true, |
michael@0 | 99 | "context-savepage", true, |
michael@0 | 100 | "---", null, |
michael@0 | 101 | "context-viewbgimage", false, |
michael@0 | 102 | "context-selectall", true, |
michael@0 | 103 | "---", null, |
michael@0 | 104 | "context-viewsource", true, |
michael@0 | 105 | "context-viewinfo", true |
michael@0 | 106 | ].concat(inspectItems); |
michael@0 | 107 | checkContextMenu(plainTextItems); |
michael@0 | 108 | closeContextMenu(); |
michael@0 | 109 | openContextMenuFor(link); // Invoke context menu for next test. |
michael@0 | 110 | break; |
michael@0 | 111 | |
michael@0 | 112 | case 3: |
michael@0 | 113 | // Context menu for text link |
michael@0 | 114 | if (perWindowPrivateBrowsing) { |
michael@0 | 115 | checkContextMenu(["context-openlinkintab", true, |
michael@0 | 116 | "context-openlink", true, |
michael@0 | 117 | "context-openlinkprivate", true, |
michael@0 | 118 | "---", null, |
michael@0 | 119 | "context-bookmarklink", true, |
michael@0 | 120 | "context-savelink", true, |
michael@0 | 121 | "context-copylink", true, |
michael@0 | 122 | "context-searchselect", true |
michael@0 | 123 | ].concat(inspectItems)); |
michael@0 | 124 | } else { |
michael@0 | 125 | checkContextMenu(["context-openlinkintab", true, |
michael@0 | 126 | "context-openlink", true, |
michael@0 | 127 | "---", null, |
michael@0 | 128 | "context-bookmarklink", true, |
michael@0 | 129 | "context-savelink", true, |
michael@0 | 130 | "context-copylink", true, |
michael@0 | 131 | "context-searchselect", true |
michael@0 | 132 | ].concat(inspectItems)); |
michael@0 | 133 | } |
michael@0 | 134 | closeContextMenu(); |
michael@0 | 135 | openContextMenuFor(mailto); // Invoke context menu for next test. |
michael@0 | 136 | break; |
michael@0 | 137 | |
michael@0 | 138 | case 4: |
michael@0 | 139 | // Context menu for text mailto-link |
michael@0 | 140 | checkContextMenu(["context-copyemail", true, |
michael@0 | 141 | "context-searchselect", true |
michael@0 | 142 | ].concat(inspectItems)); |
michael@0 | 143 | closeContextMenu(); |
michael@0 | 144 | openContextMenuFor(img); // Invoke context menu for next test. |
michael@0 | 145 | break; |
michael@0 | 146 | |
michael@0 | 147 | case 5: |
michael@0 | 148 | // Context menu for an image |
michael@0 | 149 | checkContextMenu(["context-viewimage", true, |
michael@0 | 150 | "context-copyimage-contents", true, |
michael@0 | 151 | "context-copyimage", true, |
michael@0 | 152 | "---", null, |
michael@0 | 153 | "context-saveimage", true, |
michael@0 | 154 | "context-sendimage", true, |
michael@0 | 155 | "context-setDesktopBackground", true, |
michael@0 | 156 | "context-viewimageinfo", true |
michael@0 | 157 | ].concat(inspectItems)); |
michael@0 | 158 | closeContextMenu(); |
michael@0 | 159 | openContextMenuFor(canvas); // Invoke context menu for next test. |
michael@0 | 160 | break; |
michael@0 | 161 | |
michael@0 | 162 | case 6: |
michael@0 | 163 | // Context menu for a canvas |
michael@0 | 164 | checkContextMenu(["context-viewimage", true, |
michael@0 | 165 | "context-saveimage", true, |
michael@0 | 166 | "context-bookmarkpage", true, |
michael@0 | 167 | "context-selectall", true |
michael@0 | 168 | ].concat(inspectItems)); |
michael@0 | 169 | closeContextMenu(); |
michael@0 | 170 | openContextMenuFor(video_ok); // Invoke context menu for next test. |
michael@0 | 171 | break; |
michael@0 | 172 | |
michael@0 | 173 | case 7: |
michael@0 | 174 | // Context menu for a video (with a VALID media source) |
michael@0 | 175 | checkContextMenu(["context-media-play", true, |
michael@0 | 176 | "context-media-mute", true, |
michael@0 | 177 | "context-media-playbackrate", null, |
michael@0 | 178 | ["context-media-playbackrate-050x", true, |
michael@0 | 179 | "context-media-playbackrate-100x", true, |
michael@0 | 180 | "context-media-playbackrate-150x", true, |
michael@0 | 181 | "context-media-playbackrate-200x", true], null, |
michael@0 | 182 | "context-media-hidecontrols", true, |
michael@0 | 183 | "context-video-showstats", true, |
michael@0 | 184 | "context-video-fullscreen", true, |
michael@0 | 185 | "---", null, |
michael@0 | 186 | "context-viewvideo", true, |
michael@0 | 187 | "context-copyvideourl", true, |
michael@0 | 188 | "---", null, |
michael@0 | 189 | "context-savevideo", true, |
michael@0 | 190 | "context-video-saveimage", true, |
michael@0 | 191 | "context-sendvideo", true |
michael@0 | 192 | ].concat(inspectItems)); |
michael@0 | 193 | closeContextMenu(); |
michael@0 | 194 | openContextMenuFor(audio_in_video); // Invoke context menu for next test. |
michael@0 | 195 | break; |
michael@0 | 196 | |
michael@0 | 197 | case 8: |
michael@0 | 198 | // Context menu for a video (with an audio-only file) |
michael@0 | 199 | checkContextMenu(["context-media-play", true, |
michael@0 | 200 | "context-media-mute", true, |
michael@0 | 201 | "context-media-playbackrate", null, |
michael@0 | 202 | ["context-media-playbackrate-050x", true, |
michael@0 | 203 | "context-media-playbackrate-100x", true, |
michael@0 | 204 | "context-media-playbackrate-150x", true, |
michael@0 | 205 | "context-media-playbackrate-200x", true], null, |
michael@0 | 206 | "context-media-showcontrols", true, |
michael@0 | 207 | "---", null, |
michael@0 | 208 | "context-copyaudiourl", true, |
michael@0 | 209 | "---", null, |
michael@0 | 210 | "context-saveaudio", true, |
michael@0 | 211 | "context-sendaudio", true |
michael@0 | 212 | ].concat(inspectItems)); |
michael@0 | 213 | closeContextMenu(); |
michael@0 | 214 | openContextMenuFor(video_bad); // Invoke context menu for next test. |
michael@0 | 215 | break; |
michael@0 | 216 | |
michael@0 | 217 | case 9: |
michael@0 | 218 | // Context menu for a video (with an INVALID media source) |
michael@0 | 219 | checkContextMenu(["context-media-play", false, |
michael@0 | 220 | "context-media-mute", false, |
michael@0 | 221 | "context-media-playbackrate", null, |
michael@0 | 222 | ["context-media-playbackrate-050x", false, |
michael@0 | 223 | "context-media-playbackrate-100x", false, |
michael@0 | 224 | "context-media-playbackrate-150x", false, |
michael@0 | 225 | "context-media-playbackrate-200x", false], null, |
michael@0 | 226 | "context-media-hidecontrols", false, |
michael@0 | 227 | "context-video-showstats", false, |
michael@0 | 228 | "context-video-fullscreen", false, |
michael@0 | 229 | "---", null, |
michael@0 | 230 | "context-viewvideo", true, |
michael@0 | 231 | "context-copyvideourl", true, |
michael@0 | 232 | "---", null, |
michael@0 | 233 | "context-savevideo", true, |
michael@0 | 234 | "context-video-saveimage", false, |
michael@0 | 235 | "context-sendvideo", true |
michael@0 | 236 | ].concat(inspectItems)); |
michael@0 | 237 | closeContextMenu(); |
michael@0 | 238 | openContextMenuFor(video_bad2); // Invoke context menu for next test. |
michael@0 | 239 | break; |
michael@0 | 240 | |
michael@0 | 241 | case 10: |
michael@0 | 242 | // Context menu for a video (with an INVALID media source) |
michael@0 | 243 | checkContextMenu(["context-media-play", false, |
michael@0 | 244 | "context-media-mute", false, |
michael@0 | 245 | "context-media-playbackrate", null, |
michael@0 | 246 | ["context-media-playbackrate-050x", false, |
michael@0 | 247 | "context-media-playbackrate-100x", false, |
michael@0 | 248 | "context-media-playbackrate-150x", false, |
michael@0 | 249 | "context-media-playbackrate-200x", false], null, |
michael@0 | 250 | "context-media-hidecontrols", false, |
michael@0 | 251 | "context-video-showstats", false, |
michael@0 | 252 | "context-video-fullscreen", false, |
michael@0 | 253 | "---", null, |
michael@0 | 254 | "context-viewvideo", false, |
michael@0 | 255 | "context-copyvideourl", false, |
michael@0 | 256 | "---", null, |
michael@0 | 257 | "context-savevideo", false, |
michael@0 | 258 | "context-video-saveimage", false, |
michael@0 | 259 | "context-sendvideo", false |
michael@0 | 260 | ].concat(inspectItems)); |
michael@0 | 261 | closeContextMenu(); |
michael@0 | 262 | openContextMenuFor(iframe); // Invoke context menu for next test. |
michael@0 | 263 | break; |
michael@0 | 264 | |
michael@0 | 265 | case 11: |
michael@0 | 266 | // Context menu for an iframe |
michael@0 | 267 | checkContextMenu(["context-back", false, |
michael@0 | 268 | "context-forward", false, |
michael@0 | 269 | "context-reload", true, |
michael@0 | 270 | "---", null, |
michael@0 | 271 | "context-bookmarkpage", true, |
michael@0 | 272 | "context-savepage", true, |
michael@0 | 273 | "---", null, |
michael@0 | 274 | "context-viewbgimage", false, |
michael@0 | 275 | "context-selectall", true, |
michael@0 | 276 | "frame", null, |
michael@0 | 277 | ["context-showonlythisframe", true, |
michael@0 | 278 | "context-openframeintab", true, |
michael@0 | 279 | "context-openframe", true, |
michael@0 | 280 | "---", null, |
michael@0 | 281 | "context-reloadframe", true, |
michael@0 | 282 | "---", null, |
michael@0 | 283 | "context-bookmarkframe", true, |
michael@0 | 284 | "context-saveframe", true, |
michael@0 | 285 | "---", null, |
michael@0 | 286 | "context-printframe", true, |
michael@0 | 287 | "---", null, |
michael@0 | 288 | "context-viewframesource", true, |
michael@0 | 289 | "context-viewframeinfo", true], null, |
michael@0 | 290 | "---", null, |
michael@0 | 291 | "context-viewsource", true, |
michael@0 | 292 | "context-viewinfo", true |
michael@0 | 293 | ].concat(inspectItems)); |
michael@0 | 294 | closeContextMenu(); |
michael@0 | 295 | openContextMenuFor(video_in_iframe); // Invoke context menu for next test. |
michael@0 | 296 | break; |
michael@0 | 297 | |
michael@0 | 298 | case 12: |
michael@0 | 299 | // Context menu for a video in an iframe |
michael@0 | 300 | checkContextMenu(["context-media-play", true, |
michael@0 | 301 | "context-media-mute", true, |
michael@0 | 302 | "context-media-playbackrate", null, |
michael@0 | 303 | ["context-media-playbackrate-050x", true, |
michael@0 | 304 | "context-media-playbackrate-100x", true, |
michael@0 | 305 | "context-media-playbackrate-150x", true, |
michael@0 | 306 | "context-media-playbackrate-200x", true], null, |
michael@0 | 307 | "context-media-hidecontrols", true, |
michael@0 | 308 | "context-video-showstats", true, |
michael@0 | 309 | "context-video-fullscreen", true, |
michael@0 | 310 | "---", null, |
michael@0 | 311 | "context-viewvideo", true, |
michael@0 | 312 | "context-copyvideourl", true, |
michael@0 | 313 | "---", null, |
michael@0 | 314 | "context-savevideo", true, |
michael@0 | 315 | "context-video-saveimage", true, |
michael@0 | 316 | "context-sendvideo", true, |
michael@0 | 317 | "frame", null, |
michael@0 | 318 | ["context-showonlythisframe", true, |
michael@0 | 319 | "context-openframeintab", true, |
michael@0 | 320 | "context-openframe", true, |
michael@0 | 321 | "---", null, |
michael@0 | 322 | "context-reloadframe", true, |
michael@0 | 323 | "---", null, |
michael@0 | 324 | "context-bookmarkframe", true, |
michael@0 | 325 | "context-saveframe", true, |
michael@0 | 326 | "---", null, |
michael@0 | 327 | "context-printframe", true, |
michael@0 | 328 | "---", null, |
michael@0 | 329 | "context-viewframeinfo", true], null].concat(inspectItems)); |
michael@0 | 330 | closeContextMenu(); |
michael@0 | 331 | openContextMenuFor(image_in_iframe); // Invoke context menu for next test. |
michael@0 | 332 | break; |
michael@0 | 333 | |
michael@0 | 334 | case 13: |
michael@0 | 335 | // Context menu for an image in an iframe |
michael@0 | 336 | checkContextMenu(["context-viewimage", true, |
michael@0 | 337 | "context-copyimage-contents", true, |
michael@0 | 338 | "context-copyimage", true, |
michael@0 | 339 | "---", null, |
michael@0 | 340 | "context-saveimage", true, |
michael@0 | 341 | "context-sendimage", true, |
michael@0 | 342 | "context-setDesktopBackground", true, |
michael@0 | 343 | "context-viewimageinfo", true, |
michael@0 | 344 | "frame", null, |
michael@0 | 345 | ["context-showonlythisframe", true, |
michael@0 | 346 | "context-openframeintab", true, |
michael@0 | 347 | "context-openframe", true, |
michael@0 | 348 | "---", null, |
michael@0 | 349 | "context-reloadframe", true, |
michael@0 | 350 | "---", null, |
michael@0 | 351 | "context-bookmarkframe", true, |
michael@0 | 352 | "context-saveframe", true, |
michael@0 | 353 | "---", null, |
michael@0 | 354 | "context-printframe", true, |
michael@0 | 355 | "---", null, |
michael@0 | 356 | "context-viewframeinfo", true], null].concat(inspectItems)); |
michael@0 | 357 | closeContextMenu(); |
michael@0 | 358 | openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck. |
michael@0 | 359 | break; |
michael@0 | 360 | |
michael@0 | 361 | case 14: |
michael@0 | 362 | // Context menu for textarea |
michael@0 | 363 | checkContextMenu(["*chubbiness", true, // spelling suggestion |
michael@0 | 364 | "spell-add-to-dictionary", true, |
michael@0 | 365 | "---", null, |
michael@0 | 366 | "context-undo", false, |
michael@0 | 367 | "---", null, |
michael@0 | 368 | "context-cut", false, |
michael@0 | 369 | "context-copy", false, |
michael@0 | 370 | "context-paste", null, // ignore clipboard state |
michael@0 | 371 | "context-delete", false, |
michael@0 | 372 | "---", null, |
michael@0 | 373 | "context-selectall", true, |
michael@0 | 374 | "---", null, |
michael@0 | 375 | "spell-check-enabled", true, |
michael@0 | 376 | "spell-dictionaries", true, |
michael@0 | 377 | ["spell-check-dictionary-en-US", true, |
michael@0 | 378 | "---", null, |
michael@0 | 379 | "spell-add-dictionaries", true], null |
michael@0 | 380 | ].concat(inspectItems)); |
michael@0 | 381 | contextMenu.ownerDocument.getElementById("spell-add-to-dictionary").doCommand(); // Add to dictionary |
michael@0 | 382 | closeContextMenu(); |
michael@0 | 383 | openContextMenuFor(text); // Invoke context menu for next test. |
michael@0 | 384 | break; |
michael@0 | 385 | |
michael@0 | 386 | case 15: |
michael@0 | 387 | // Re-check context menu for plain text to make sure it hasn't changed |
michael@0 | 388 | checkContextMenu(plainTextItems); |
michael@0 | 389 | closeContextMenu(); |
michael@0 | 390 | openContextMenuFor(textarea, false, true); // Invoke context menu for next test. |
michael@0 | 391 | break; |
michael@0 | 392 | |
michael@0 | 393 | case 16: |
michael@0 | 394 | // Context menu for textarea after a word has been added |
michael@0 | 395 | // to the dictionary |
michael@0 | 396 | checkContextMenu(["spell-undo-add-to-dictionary", true, |
michael@0 | 397 | "---", null, |
michael@0 | 398 | "context-undo", false, |
michael@0 | 399 | "---", null, |
michael@0 | 400 | "context-cut", false, |
michael@0 | 401 | "context-copy", false, |
michael@0 | 402 | "context-paste", null, // ignore clipboard state |
michael@0 | 403 | "context-delete", false, |
michael@0 | 404 | "---", null, |
michael@0 | 405 | "context-selectall", true, |
michael@0 | 406 | "---", null, |
michael@0 | 407 | "spell-check-enabled", true, |
michael@0 | 408 | "spell-dictionaries", true, |
michael@0 | 409 | ["spell-check-dictionary-en-US", true, |
michael@0 | 410 | "---", null, |
michael@0 | 411 | "spell-add-dictionaries", true], null |
michael@0 | 412 | ].concat(inspectItems)); |
michael@0 | 413 | contextMenu.ownerDocument.getElementById("spell-undo-add-to-dictionary").doCommand(); // Undo add to dictionary |
michael@0 | 414 | closeContextMenu(); |
michael@0 | 415 | openContextMenuFor(contenteditable, false, true); |
michael@0 | 416 | break; |
michael@0 | 417 | |
michael@0 | 418 | case 17: |
michael@0 | 419 | // Context menu for contenteditable |
michael@0 | 420 | checkContextMenu(["spell-no-suggestions", false, |
michael@0 | 421 | "spell-add-to-dictionary", true, |
michael@0 | 422 | "---", null, |
michael@0 | 423 | "context-undo", false, |
michael@0 | 424 | "---", null, |
michael@0 | 425 | "context-cut", false, |
michael@0 | 426 | "context-copy", false, |
michael@0 | 427 | "context-paste", null, // ignore clipboard state |
michael@0 | 428 | "context-delete", false, |
michael@0 | 429 | "---", null, |
michael@0 | 430 | "context-selectall", true, |
michael@0 | 431 | "---", null, |
michael@0 | 432 | "spell-check-enabled", true, |
michael@0 | 433 | "spell-dictionaries", true, |
michael@0 | 434 | ["spell-check-dictionary-en-US", true, |
michael@0 | 435 | "---", null, |
michael@0 | 436 | "spell-add-dictionaries", true], null |
michael@0 | 437 | ].concat(inspectItems)); |
michael@0 | 438 | |
michael@0 | 439 | closeContextMenu(); |
michael@0 | 440 | openContextMenuFor(link); // Invoke context menu for next test. |
michael@0 | 441 | break; |
michael@0 | 442 | |
michael@0 | 443 | case 18: |
michael@0 | 444 | executeCopyCommand("cmd_copyLink", "http://mozilla.com/"); |
michael@0 | 445 | closeContextMenu(); |
michael@0 | 446 | openContextMenuFor(pagemenu); // Invoke context menu for next test. |
michael@0 | 447 | break; |
michael@0 | 448 | |
michael@0 | 449 | case 19: |
michael@0 | 450 | // Context menu for element with assigned content context menu |
michael@0 | 451 | checkContextMenu(["+Plain item", {type: "", icon: "", checked: false, disabled: false}, |
michael@0 | 452 | "+Disabled item", {type: "", icon: "", checked: false, disabled: true}, |
michael@0 | 453 | "+Item w/ textContent", {type: "", icon: "", checked: false, disabled: false}, |
michael@0 | 454 | "---", null, |
michael@0 | 455 | "+Checkbox", {type: "checkbox", icon: "", checked: true, disabled: false}, |
michael@0 | 456 | "---", null, |
michael@0 | 457 | "+Radio1", {type: "checkbox", icon: "", checked: true, disabled: false}, |
michael@0 | 458 | "+Radio2", {type: "checkbox", icon: "", checked: false, disabled: false}, |
michael@0 | 459 | "+Radio3", {type: "checkbox", icon: "", checked: false, disabled: false}, |
michael@0 | 460 | "---", null, |
michael@0 | 461 | "+Item w/ icon", {type: "", icon: "favicon.ico", checked: false, disabled: false}, |
michael@0 | 462 | "+Item w/ bad icon", {type: "", icon: "", checked: false, disabled: false}, |
michael@0 | 463 | "---", null, |
michael@0 | 464 | "generated-submenu-1", true, |
michael@0 | 465 | ["+Radio1", {type: "checkbox", icon: "", checked: false, disabled: false}, |
michael@0 | 466 | "+Radio2", {type: "checkbox", icon: "", checked: true, disabled: false}, |
michael@0 | 467 | "+Radio3", {type: "checkbox", icon: "", checked: false, disabled: false}, |
michael@0 | 468 | "---", null, |
michael@0 | 469 | "+Checkbox", {type: "checkbox", icon: "", checked: false, disabled: false}], null, |
michael@0 | 470 | "---", null, |
michael@0 | 471 | "context-back", false, |
michael@0 | 472 | "context-forward", false, |
michael@0 | 473 | "context-reload", true, |
michael@0 | 474 | "---", null, |
michael@0 | 475 | "context-bookmarkpage", true, |
michael@0 | 476 | "context-savepage", true, |
michael@0 | 477 | "---", null, |
michael@0 | 478 | "context-viewbgimage", false, |
michael@0 | 479 | "context-selectall", true, |
michael@0 | 480 | "---", null, |
michael@0 | 481 | "context-viewsource", true, |
michael@0 | 482 | "context-viewinfo", true |
michael@0 | 483 | ].concat(inspectItems)); |
michael@0 | 484 | |
michael@0 | 485 | invokeItemAction("0"); |
michael@0 | 486 | closeContextMenu(); |
michael@0 | 487 | |
michael@0 | 488 | // run mozRequestFullScreen on the element we're testing |
michael@0 | 489 | var full_screen_element = subwindow.document.getElementById("test-dom-full-screen"); |
michael@0 | 490 | var openDomFullScreen = function() { |
michael@0 | 491 | subwindow.removeEventListener("mozfullscreenchange", openDomFullScreen, false); |
michael@0 | 492 | openContextMenuFor(dom_full_screen, true); // Invoke context menu for next test. |
michael@0 | 493 | } |
michael@0 | 494 | subwindow.addEventListener("mozfullscreenchange", openDomFullScreen, false); |
michael@0 | 495 | SpecialPowers.setBoolPref("full-screen-api.approval-required", false); |
michael@0 | 496 | SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false); |
michael@0 | 497 | full_screen_element.mozRequestFullScreen(); |
michael@0 | 498 | break; |
michael@0 | 499 | |
michael@0 | 500 | case 20: |
michael@0 | 501 | // Context menu for DOM Fullscreen mode (NOTE: this is *NOT* on an img) |
michael@0 | 502 | checkContextMenu(["context-leave-dom-fullscreen", true, |
michael@0 | 503 | "---", null, |
michael@0 | 504 | "context-back", false, |
michael@0 | 505 | "context-forward", false, |
michael@0 | 506 | "context-reload", true, |
michael@0 | 507 | "---", null, |
michael@0 | 508 | "context-bookmarkpage", true, |
michael@0 | 509 | "context-savepage", true, |
michael@0 | 510 | "---", null, |
michael@0 | 511 | "context-viewbgimage", false, |
michael@0 | 512 | "context-selectall", true, |
michael@0 | 513 | "---", null, |
michael@0 | 514 | "context-viewsource", true, |
michael@0 | 515 | "context-viewinfo", true |
michael@0 | 516 | ].concat(inspectItems)); |
michael@0 | 517 | closeContextMenu(); |
michael@0 | 518 | var full_screen_element = subwindow.document.getElementById("test-dom-full-screen"); |
michael@0 | 519 | var openPagemenu = function() { |
michael@0 | 520 | subwindow.removeEventListener("mozfullscreenchange", openPagemenu, false); |
michael@0 | 521 | SpecialPowers.clearUserPref("full-screen-api.approval-required"); |
michael@0 | 522 | SpecialPowers.clearUserPref("full-screen-api.allow-trusted-requests-only"); |
michael@0 | 523 | openContextMenuFor(pagemenu, true); // Invoke context menu for next test. |
michael@0 | 524 | } |
michael@0 | 525 | subwindow.addEventListener("mozfullscreenchange", openPagemenu, false); |
michael@0 | 526 | subwindow.document.mozCancelFullScreen(); |
michael@0 | 527 | break; |
michael@0 | 528 | |
michael@0 | 529 | case 21: |
michael@0 | 530 | // Context menu for element with assigned content context menu |
michael@0 | 531 | // The shift key should bypass content context menu processing |
michael@0 | 532 | checkContextMenu(["context-back", false, |
michael@0 | 533 | "context-forward", false, |
michael@0 | 534 | "context-reload", true, |
michael@0 | 535 | "---", null, |
michael@0 | 536 | "context-bookmarkpage", true, |
michael@0 | 537 | "context-savepage", true, |
michael@0 | 538 | "---", null, |
michael@0 | 539 | "context-viewbgimage", false, |
michael@0 | 540 | "context-selectall", true, |
michael@0 | 541 | "---", null, |
michael@0 | 542 | "context-viewsource", true, |
michael@0 | 543 | "context-viewinfo", true |
michael@0 | 544 | ].concat(inspectItems)); |
michael@0 | 545 | closeContextMenu(); |
michael@0 | 546 | selectText(selecttext); // Select text prior to opening context menu. |
michael@0 | 547 | openContextMenuFor(selecttext); // Invoke context menu for next test. |
michael@0 | 548 | return; |
michael@0 | 549 | |
michael@0 | 550 | case 22: |
michael@0 | 551 | // Context menu for selected text |
michael@0 | 552 | if (SpecialPowers.Services.appinfo.OS == "Darwin") { |
michael@0 | 553 | // This test is only enabled on Mac due to bug 736399. |
michael@0 | 554 | checkContextMenu(["context-copy", true, |
michael@0 | 555 | "context-selectall", true, |
michael@0 | 556 | "---", null, |
michael@0 | 557 | "context-searchselect", true, |
michael@0 | 558 | "context-viewpartialsource-selection", true |
michael@0 | 559 | ].concat(inspectItems)); |
michael@0 | 560 | } |
michael@0 | 561 | closeContextMenu(); |
michael@0 | 562 | selectText(selecttextlink); // Select text prior to opening context menu. |
michael@0 | 563 | openContextMenuFor(selecttextlink); // Invoke context menu for next test. |
michael@0 | 564 | return; |
michael@0 | 565 | |
michael@0 | 566 | case 23: |
michael@0 | 567 | // Context menu for selected text which matches valid URL pattern |
michael@0 | 568 | if (SpecialPowers.Services.appinfo.OS == "Darwin") { |
michael@0 | 569 | // This test is only enabled on Mac due to bug 736399. |
michael@0 | 570 | if (perWindowPrivateBrowsing) { |
michael@0 | 571 | checkContextMenu(["context-openlinkincurrent", true, |
michael@0 | 572 | "context-openlinkintab", true, |
michael@0 | 573 | "context-openlink", true, |
michael@0 | 574 | "context-openlinkprivate", true, |
michael@0 | 575 | "---", null, |
michael@0 | 576 | "context-bookmarklink", true, |
michael@0 | 577 | "context-savelink", true, |
michael@0 | 578 | "context-copy", true, |
michael@0 | 579 | "context-selectall", true, |
michael@0 | 580 | "---", null, |
michael@0 | 581 | "context-searchselect", true, |
michael@0 | 582 | "context-viewpartialsource-selection", true |
michael@0 | 583 | ].concat(inspectItems)); |
michael@0 | 584 | } else { |
michael@0 | 585 | checkContextMenu(["context-openlinkincurrent", true, |
michael@0 | 586 | "context-openlinkintab", true, |
michael@0 | 587 | "context-openlink", true, |
michael@0 | 588 | "---", null, |
michael@0 | 589 | "context-bookmarklink", true, |
michael@0 | 590 | "context-savelink", true, |
michael@0 | 591 | "context-copy", true, |
michael@0 | 592 | "context-selectall", true, |
michael@0 | 593 | "---", null, |
michael@0 | 594 | "context-searchselect", true, |
michael@0 | 595 | "context-viewpartialsource-selection", true |
michael@0 | 596 | ].concat(inspectItems)); |
michael@0 | 597 | } |
michael@0 | 598 | } |
michael@0 | 599 | closeContextMenu(); |
michael@0 | 600 | // clear the selection because following tests don't expect any selection |
michael@0 | 601 | subwindow.getSelection().removeAllRanges(); |
michael@0 | 602 | |
michael@0 | 603 | openContextMenuFor(imagelink) |
michael@0 | 604 | break; |
michael@0 | 605 | |
michael@0 | 606 | case 24: |
michael@0 | 607 | // Context menu for image link |
michael@0 | 608 | if (perWindowPrivateBrowsing) { |
michael@0 | 609 | checkContextMenu(["context-openlinkintab", true, |
michael@0 | 610 | "context-openlink", true, |
michael@0 | 611 | "context-openlinkprivate", true, |
michael@0 | 612 | "---", null, |
michael@0 | 613 | "context-bookmarklink", true, |
michael@0 | 614 | "context-savelink", true, |
michael@0 | 615 | "context-copylink", true, |
michael@0 | 616 | "---", null, |
michael@0 | 617 | "context-viewimage", true, |
michael@0 | 618 | "context-copyimage-contents", true, |
michael@0 | 619 | "context-copyimage", true, |
michael@0 | 620 | "---", null, |
michael@0 | 621 | "context-saveimage", true, |
michael@0 | 622 | "context-sendimage", true, |
michael@0 | 623 | "context-setDesktopBackground", true, |
michael@0 | 624 | "context-viewimageinfo", true |
michael@0 | 625 | ].concat(inspectItems)); |
michael@0 | 626 | } else { |
michael@0 | 627 | checkContextMenu(["context-openlinkintab", true, |
michael@0 | 628 | "context-openlink", true, |
michael@0 | 629 | "---", null, |
michael@0 | 630 | "context-bookmarklink", true, |
michael@0 | 631 | "context-savelink", true, |
michael@0 | 632 | "context-copylink", true, |
michael@0 | 633 | "---", null, |
michael@0 | 634 | "context-viewimage", true, |
michael@0 | 635 | "context-copyimage-contents", true, |
michael@0 | 636 | "context-copyimage", true, |
michael@0 | 637 | "---", null, |
michael@0 | 638 | "context-saveimage", true, |
michael@0 | 639 | "context-sendimage", true, |
michael@0 | 640 | "context-setDesktopBackground", true, |
michael@0 | 641 | "context-viewimageinfo", true |
michael@0 | 642 | ].concat(inspectItems)); |
michael@0 | 643 | } |
michael@0 | 644 | closeContextMenu(); |
michael@0 | 645 | selectInputText(select_inputtext); // Select text prior to opening context menu. |
michael@0 | 646 | openContextMenuFor(select_inputtext); // Invoke context menu for next test. |
michael@0 | 647 | return; |
michael@0 | 648 | |
michael@0 | 649 | case 25: |
michael@0 | 650 | // Context menu for selected text in input |
michael@0 | 651 | checkContextMenu(["context-undo", false, |
michael@0 | 652 | "---", null, |
michael@0 | 653 | "context-cut", true, |
michael@0 | 654 | "context-copy", true, |
michael@0 | 655 | "context-paste", null, // ignore clipboard state |
michael@0 | 656 | "context-delete", true, |
michael@0 | 657 | "---", null, |
michael@0 | 658 | "context-selectall", true, |
michael@0 | 659 | "context-searchselect",true, |
michael@0 | 660 | "---", null, |
michael@0 | 661 | "spell-check-enabled", true |
michael@0 | 662 | ].concat(inspectItems)); |
michael@0 | 663 | closeContextMenu(); |
michael@0 | 664 | selectInputText(select_inputtext_password); // Select text prior to opening context menu. |
michael@0 | 665 | openContextMenuFor(select_inputtext_password); // Invoke context menu for next test. |
michael@0 | 666 | return; |
michael@0 | 667 | |
michael@0 | 668 | case 26: |
michael@0 | 669 | // Context menu for selected text in input[type="password"] |
michael@0 | 670 | checkContextMenu(["context-undo", false, |
michael@0 | 671 | "---", null, |
michael@0 | 672 | "context-cut", true, |
michael@0 | 673 | "context-copy", true, |
michael@0 | 674 | "context-paste", null, // ignore clipboard state |
michael@0 | 675 | "context-delete", true, |
michael@0 | 676 | "---", null, |
michael@0 | 677 | "context-selectall", true, |
michael@0 | 678 | "---", null, |
michael@0 | 679 | "spell-check-enabled", true, |
michael@0 | 680 | //spell checker is shown on input[type="password"] on this testcase |
michael@0 | 681 | "spell-dictionaries", true, |
michael@0 | 682 | ["spell-check-dictionary-en-US", true, |
michael@0 | 683 | "---", null, |
michael@0 | 684 | "spell-add-dictionaries", true], null |
michael@0 | 685 | ].concat(inspectItems)); |
michael@0 | 686 | closeContextMenu(); |
michael@0 | 687 | subwindow.getSelection().removeAllRanges(); |
michael@0 | 688 | openContextMenuFor(plugin); |
michael@0 | 689 | return; |
michael@0 | 690 | |
michael@0 | 691 | case 27: |
michael@0 | 692 | // Context menu for click-to-play blocked plugin |
michael@0 | 693 | checkContextMenu(["context-ctp-play", true, |
michael@0 | 694 | "context-ctp-hide", true, |
michael@0 | 695 | "---", null, |
michael@0 | 696 | "context-back", false, |
michael@0 | 697 | "context-forward", false, |
michael@0 | 698 | "context-reload", true, |
michael@0 | 699 | "---", null, |
michael@0 | 700 | "context-bookmarkpage", true, |
michael@0 | 701 | "context-savepage", true, |
michael@0 | 702 | "---", null, |
michael@0 | 703 | "context-viewbgimage", false, |
michael@0 | 704 | "context-selectall", true, |
michael@0 | 705 | "---", null, |
michael@0 | 706 | "context-viewsource", true, |
michael@0 | 707 | "context-viewinfo", true |
michael@0 | 708 | ].concat(inspectItems)); |
michael@0 | 709 | closeContextMenu(); |
michael@0 | 710 | SpecialPowers.clearUserPref("plugins.click_to_play"); |
michael@0 | 711 | getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED; |
michael@0 | 712 | openContextMenuFor(longdesc); |
michael@0 | 713 | return; |
michael@0 | 714 | |
michael@0 | 715 | case 28: |
michael@0 | 716 | // Context menu for an image with longdesc |
michael@0 | 717 | checkContextMenu(["context-viewimage", true, |
michael@0 | 718 | "context-copyimage-contents", true, |
michael@0 | 719 | "context-copyimage", true, |
michael@0 | 720 | "---", null, |
michael@0 | 721 | "context-saveimage", true, |
michael@0 | 722 | "context-sendimage", true, |
michael@0 | 723 | "context-setDesktopBackground", true, |
michael@0 | 724 | "context-viewimageinfo", true, |
michael@0 | 725 | "context-viewimagedesc", true |
michael@0 | 726 | ].concat(inspectItems)); |
michael@0 | 727 | closeContextMenu(); |
michael@0 | 728 | openContextMenuFor(srcdoc); |
michael@0 | 729 | return; |
michael@0 | 730 | |
michael@0 | 731 | case 29: |
michael@0 | 732 | // Context menu for an iframe with srcdoc attribute set |
michael@0 | 733 | checkContextMenu(["context-back", false, |
michael@0 | 734 | "context-forward", false, |
michael@0 | 735 | "context-reload", true, |
michael@0 | 736 | "---", null, |
michael@0 | 737 | "context-bookmarkpage", true, |
michael@0 | 738 | "context-savepage", true, |
michael@0 | 739 | "---", null, |
michael@0 | 740 | "context-viewbgimage", false, |
michael@0 | 741 | "context-selectall", true, |
michael@0 | 742 | "frame", null, |
michael@0 | 743 | ["context-reloadframe", true, |
michael@0 | 744 | "---", null, |
michael@0 | 745 | "context-saveframe", true, |
michael@0 | 746 | "---", null, |
michael@0 | 747 | "context-printframe", true, |
michael@0 | 748 | "---", null, |
michael@0 | 749 | "context-viewframesource", true, |
michael@0 | 750 | "context-viewframeinfo", true], null, |
michael@0 | 751 | "---", null, |
michael@0 | 752 | "context-viewsource", true, |
michael@0 | 753 | "context-viewinfo", true |
michael@0 | 754 | ].concat(inspectItems)); |
michael@0 | 755 | closeContextMenu(); |
michael@0 | 756 | openContextMenuFor(inputspellfalse, false, true); // Invoke context menu for next test. |
michael@0 | 757 | break; |
michael@0 | 758 | |
michael@0 | 759 | case 30: |
michael@0 | 760 | // Context menu for text input field with spellcheck=false |
michael@0 | 761 | checkContextMenu(["context-undo", false, |
michael@0 | 762 | "---", null, |
michael@0 | 763 | "context-cut", false, |
michael@0 | 764 | "context-copy", false, |
michael@0 | 765 | "context-paste", null, // ignore clipboard state |
michael@0 | 766 | "context-delete", false, |
michael@0 | 767 | "---", null, |
michael@0 | 768 | "context-selectall", true, |
michael@0 | 769 | "---", null, |
michael@0 | 770 | "spell-add-dictionaries-main", true, |
michael@0 | 771 | ].concat(inspectItems)); |
michael@0 | 772 | |
michael@0 | 773 | // finish test |
michael@0 | 774 | subwindow.close(); |
michael@0 | 775 | SimpleTest.finish(); |
michael@0 | 776 | return; |
michael@0 | 777 | |
michael@0 | 778 | /* |
michael@0 | 779 | * Other things that would be nice to test: |
michael@0 | 780 | * - check state of disabled items |
michael@0 | 781 | * - test execution of menu items (maybe as a separate test?) |
michael@0 | 782 | */ |
michael@0 | 783 | |
michael@0 | 784 | default: |
michael@0 | 785 | ok(false, "Unexpected invocation of test #" + testNum); |
michael@0 | 786 | subwindow.close(); |
michael@0 | 787 | SimpleTest.finish(); |
michael@0 | 788 | return; |
michael@0 | 789 | } |
michael@0 | 790 | |
michael@0 | 791 | } |
michael@0 | 792 | |
michael@0 | 793 | |
michael@0 | 794 | var testNum = 1; |
michael@0 | 795 | var subwindow, chromeWin, contextMenu; |
michael@0 | 796 | var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2, |
michael@0 | 797 | iframe, video_in_iframe, image_in_iframe, textarea, contenteditable, |
michael@0 | 798 | pagemenu, dom_full_screen, plainTextItems, audio_in_video, |
michael@0 | 799 | selecttext, selecttextlink, imagelink, select_inputtext, select_inputtext_password, |
michael@0 | 800 | plugin, longdesc, iframe, inputspellfalse; |
michael@0 | 801 | |
michael@0 | 802 | function startTest() { |
michael@0 | 803 | chromeWin = SpecialPowers.wrap(subwindow) |
michael@0 | 804 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 805 | .getInterface(Ci.nsIWebNavigation) |
michael@0 | 806 | .QueryInterface(Ci.nsIDocShellTreeItem) |
michael@0 | 807 | .rootTreeItem |
michael@0 | 808 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 809 | .getInterface(Ci.nsIDOMWindow) |
michael@0 | 810 | .QueryInterface(Ci.nsIDOMChromeWindow); |
michael@0 | 811 | contextMenu = chromeWin.document.getElementById("contentAreaContextMenu"); |
michael@0 | 812 | ok(contextMenu, "Got context menu XUL"); |
michael@0 | 813 | |
michael@0 | 814 | if (chromeWin.document.getElementById("Browser:Stop").getAttribute("disabled") != "true") { |
michael@0 | 815 | todo(false, "Wait for subwindow to load... (This should usually happen once.)"); |
michael@0 | 816 | SimpleTest.executeSoon(startTest); |
michael@0 | 817 | return; |
michael@0 | 818 | } |
michael@0 | 819 | |
michael@0 | 820 | subwindow.allowFullscreen = true; |
michael@0 | 821 | lastElement = null; |
michael@0 | 822 | |
michael@0 | 823 | text = subwindow.document.getElementById("test-text"); |
michael@0 | 824 | link = subwindow.document.getElementById("test-link"); |
michael@0 | 825 | imagelink = subwindow.document.getElementById("test-image-link"); |
michael@0 | 826 | mailto = subwindow.document.getElementById("test-mailto"); |
michael@0 | 827 | input = subwindow.document.getElementById("test-input"); |
michael@0 | 828 | img = subwindow.document.getElementById("test-image"); |
michael@0 | 829 | canvas = subwindow.document.getElementById("test-canvas"); |
michael@0 | 830 | video_ok = subwindow.document.getElementById("test-video-ok"); |
michael@0 | 831 | audio_in_video = subwindow.document.getElementById("test-audio-in-video"); |
michael@0 | 832 | video_bad = subwindow.document.getElementById("test-video-bad"); |
michael@0 | 833 | video_bad2 = subwindow.document.getElementById("test-video-bad2"); |
michael@0 | 834 | iframe = subwindow.document.getElementById("test-iframe"); |
michael@0 | 835 | video_in_iframe = subwindow.document.getElementById("test-video-in-iframe").contentDocument.getElementsByTagName("video")[0]; |
michael@0 | 836 | video_in_iframe.pause(); |
michael@0 | 837 | image_in_iframe = subwindow.document.getElementById("test-image-in-iframe").contentDocument.getElementsByTagName("img")[0]; |
michael@0 | 838 | textarea = subwindow.document.getElementById("test-textarea"); |
michael@0 | 839 | contenteditable = subwindow.document.getElementById("test-contenteditable"); |
michael@0 | 840 | contenteditable.focus(); // content editable needs to be focused to enable spellcheck |
michael@0 | 841 | inputspellfalse = subwindow.document.getElementById("test-contenteditable-spellcheck-false"); |
michael@0 | 842 | inputspellfalse.focus(); // content editable needs to be focused to enable spellcheck |
michael@0 | 843 | pagemenu = subwindow.document.getElementById("test-pagemenu"); |
michael@0 | 844 | dom_full_screen = subwindow.document.getElementById("test-dom-full-screen"); |
michael@0 | 845 | selecttext = subwindow.document.getElementById("test-select-text"); |
michael@0 | 846 | selecttextlink = subwindow.document.getElementById("test-select-text-link"); |
michael@0 | 847 | select_inputtext = subwindow.document.getElementById("test-select-input-text"); |
michael@0 | 848 | select_inputtext_password = subwindow.document.getElementById("test-select-input-text-type-password"); |
michael@0 | 849 | plugin = subwindow.document.getElementById("test-plugin"); |
michael@0 | 850 | longdesc = subwindow.document.getElementById("test-longdesc"); |
michael@0 | 851 | srcdoc = subwindow.document.getElementById("test-srcdoc"); |
michael@0 | 852 | |
michael@0 | 853 | contextMenu.addEventListener("popupshown", function() { runTest(++testNum); }, false); |
michael@0 | 854 | runTest(1); |
michael@0 | 855 | } |
michael@0 | 856 | |
michael@0 | 857 | // We open this in a separate window, because the Mochitests run inside a frame. |
michael@0 | 858 | // The frame causes an extra menu item, and prevents running the test |
michael@0 | 859 | // standalone (ie, clicking the test name in the Mochitest window) to see |
michael@0 | 860 | // success/failure messages. |
michael@0 | 861 | var painted = false, loaded = false; |
michael@0 | 862 | |
michael@0 | 863 | function waitForEvents(event) |
michael@0 | 864 | { |
michael@0 | 865 | if (event.type == "MozAfterPaint") |
michael@0 | 866 | painted = true; |
michael@0 | 867 | else if (event.type == "load") |
michael@0 | 868 | loaded = true; |
michael@0 | 869 | if (painted && loaded) { |
michael@0 | 870 | subwindow.removeEventListener("MozAfterPaint", waitForEvents, false); |
michael@0 | 871 | subwindow.onload = null; |
michael@0 | 872 | startTest(); |
michael@0 | 873 | } |
michael@0 | 874 | } |
michael@0 | 875 | |
michael@0 | 876 | const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1; |
michael@0 | 877 | |
michael@0 | 878 | if (isOSXMtnLion) { |
michael@0 | 879 | todo(false, "Mountain Lion doesn't like this test (bug 792304)"); |
michael@0 | 880 | } else { |
michael@0 | 881 | SpecialPowers.setBoolPref("plugins.click_to_play", true); |
michael@0 | 882 | setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY); |
michael@0 | 883 | |
michael@0 | 884 | var subwindow = window.open("./subtst_contextmenu.html", "contextmenu-subtext", "width=600,height=800"); |
michael@0 | 885 | subwindow.addEventListener("MozAfterPaint", waitForEvents, false); |
michael@0 | 886 | subwindow.onload = waitForEvents; |
michael@0 | 887 | |
michael@0 | 888 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 889 | } |
michael@0 | 890 | </script> |
michael@0 | 891 | </pre> |
michael@0 | 892 | </body> |
michael@0 | 893 | </html> |