mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
890 lines
44 KiB
HTML
890 lines
44 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Tests for browser context menu</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
<script type="text/javascript" src="head_plain.js"></script>
|
|
</head>
|
|
<body>
|
|
Browser context menu tests.
|
|
<p id="display"></p>
|
|
|
|
<div id="content">
|
|
</div>
|
|
|
|
<pre id="test">
|
|
<script> var perWindowPrivateBrowsing = false; </script>
|
|
<script type="text/javascript" src="privateBrowsingMode.js"></script>
|
|
<script type="text/javascript" src="contextmenu_common.js"></script>
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
SpecialPowers.Cu.import("resource://gre/modules/InlineSpellChecker.jsm", window);
|
|
SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm", window);
|
|
|
|
const Ci = SpecialPowers.Ci;
|
|
|
|
function executeCopyCommand(command, expectedValue)
|
|
{
|
|
// Just execute the command directly rather than simulating a context menu
|
|
// press to avoid having to deal with its asynchronous nature
|
|
SpecialPowers.wrap(subwindow).controllers.getControllerForCommand(command).doCommand(command);
|
|
|
|
// The easiest way to check the clipboard is to paste the contents into a
|
|
// textbox
|
|
input.focus();
|
|
input.value = "";
|
|
SpecialPowers.wrap(input).controllers.getControllerForCommand("cmd_paste").doCommand("cmd_paste");
|
|
is(input.value, expectedValue, "paste for command " + command);
|
|
}
|
|
|
|
function invokeItemAction(generatedItemId)
|
|
{
|
|
var item = contextMenu.getElementsByAttribute("generateditemid",
|
|
generatedItemId)[0];
|
|
ok(item, "Got generated XUL menu item");
|
|
item.doCommand();
|
|
ok(!pagemenu.hasAttribute("hopeless"), "attribute got removed");
|
|
}
|
|
|
|
function selectText(element) {
|
|
// Clear any previous selections before selecting new element.
|
|
subwindow.getSelection().removeAllRanges();
|
|
|
|
var div = subwindow.document.createRange();
|
|
div.setStartBefore(element);
|
|
div.setEndAfter(element);
|
|
subwindow.getSelection().addRange(div);
|
|
}
|
|
|
|
function selectInputText(element) {
|
|
// Clear any previous selections before selecting new element.
|
|
subwindow.getSelection().removeAllRanges();
|
|
|
|
element.select();
|
|
}
|
|
|
|
/*
|
|
* runTest
|
|
*
|
|
* Called by a popupshowing event handler. Each test checks for expected menu
|
|
* contents, closes the popup, and finally triggers the popup on a new element
|
|
* (thus kicking off another cycle).
|
|
*
|
|
*/
|
|
function runTest(testNum) {
|
|
// Seems we need to enable this again, or sendKeyEvent() complaints.
|
|
ok(true, "Starting test #" + testNum);
|
|
|
|
var inspectItems = [];
|
|
if (SpecialPowers.getBoolPref("devtools.inspector.enabled")) {
|
|
inspectItems = ["---", null,
|
|
"context-inspect", true];
|
|
}
|
|
|
|
switch (testNum) {
|
|
case 1:
|
|
// Invoke context menu for next test.
|
|
openContextMenuFor(text);
|
|
break;
|
|
|
|
case 2:
|
|
// Context menu for plain text
|
|
plainTextItems = ["context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems);
|
|
checkContextMenu(plainTextItems);
|
|
closeContextMenu();
|
|
openContextMenuFor(link); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 3:
|
|
// Context menu for text link
|
|
if (perWindowPrivateBrowsing) {
|
|
checkContextMenu(["context-openlinkintab", true,
|
|
"context-openlink", true,
|
|
"context-openlinkprivate", true,
|
|
"---", null,
|
|
"context-bookmarklink", true,
|
|
"context-savelink", true,
|
|
"context-copylink", true
|
|
].concat(inspectItems));
|
|
} else {
|
|
checkContextMenu(["context-openlinkintab", true,
|
|
"context-openlink", true,
|
|
"---", null,
|
|
"context-bookmarklink", true,
|
|
"context-savelink", true,
|
|
"context-copylink", true
|
|
].concat(inspectItems));
|
|
}
|
|
closeContextMenu();
|
|
openContextMenuFor(mailto); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 4:
|
|
// Context menu for text mailto-link
|
|
checkContextMenu(["context-copyemail", true].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(img); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 5:
|
|
// Context menu for an image
|
|
checkContextMenu(["context-viewimage", true,
|
|
"context-copyimage-contents", true,
|
|
"context-copyimage", true,
|
|
"---", null,
|
|
"context-saveimage", true,
|
|
"context-sendimage", true,
|
|
"context-setDesktopBackground", true,
|
|
"context-viewimageinfo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(canvas); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 6:
|
|
// Context menu for a canvas
|
|
checkContextMenu(["context-viewimage", true,
|
|
"context-saveimage", true,
|
|
"context-bookmarkpage", true,
|
|
"context-selectall", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(video_ok); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 7:
|
|
// Context menu for a video (with a VALID media source)
|
|
checkContextMenu(["context-media-play", true,
|
|
"context-media-mute", true,
|
|
"context-media-playbackrate", null,
|
|
["context-media-playbackrate-050x", true,
|
|
"context-media-playbackrate-100x", true,
|
|
"context-media-playbackrate-150x", true,
|
|
"context-media-playbackrate-200x", true], null,
|
|
"context-media-hidecontrols", true,
|
|
"context-video-showstats", true,
|
|
"context-video-fullscreen", true,
|
|
"---", null,
|
|
"context-viewvideo", true,
|
|
"context-copyvideourl", true,
|
|
"---", null,
|
|
"context-savevideo", true,
|
|
"context-video-saveimage", true,
|
|
"context-sendvideo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(audio_in_video); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 8:
|
|
// Context menu for a video (with an audio-only file)
|
|
checkContextMenu(["context-media-play", true,
|
|
"context-media-mute", true,
|
|
"context-media-playbackrate", null,
|
|
["context-media-playbackrate-050x", true,
|
|
"context-media-playbackrate-100x", true,
|
|
"context-media-playbackrate-150x", true,
|
|
"context-media-playbackrate-200x", true], null,
|
|
"context-media-showcontrols", true,
|
|
"---", null,
|
|
"context-copyaudiourl", true,
|
|
"---", null,
|
|
"context-saveaudio", true,
|
|
"context-sendaudio", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(video_bad); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 9:
|
|
// Context menu for a video (with an INVALID media source)
|
|
checkContextMenu(["context-media-play", false,
|
|
"context-media-mute", false,
|
|
"context-media-playbackrate", null,
|
|
["context-media-playbackrate-050x", false,
|
|
"context-media-playbackrate-100x", false,
|
|
"context-media-playbackrate-150x", false,
|
|
"context-media-playbackrate-200x", false], null,
|
|
"context-media-hidecontrols", false,
|
|
"context-video-showstats", false,
|
|
"context-video-fullscreen", false,
|
|
"---", null,
|
|
"context-viewvideo", true,
|
|
"context-copyvideourl", true,
|
|
"---", null,
|
|
"context-savevideo", true,
|
|
"context-video-saveimage", false,
|
|
"context-sendvideo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(video_bad2); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 10:
|
|
// Context menu for a video (with an INVALID media source)
|
|
checkContextMenu(["context-media-play", false,
|
|
"context-media-mute", false,
|
|
"context-media-playbackrate", null,
|
|
["context-media-playbackrate-050x", false,
|
|
"context-media-playbackrate-100x", false,
|
|
"context-media-playbackrate-150x", false,
|
|
"context-media-playbackrate-200x", false], null,
|
|
"context-media-hidecontrols", false,
|
|
"context-video-showstats", false,
|
|
"context-video-fullscreen", false,
|
|
"---", null,
|
|
"context-viewvideo", false,
|
|
"context-copyvideourl", false,
|
|
"---", null,
|
|
"context-savevideo", false,
|
|
"context-video-saveimage", false,
|
|
"context-sendvideo", false
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(iframe); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 11:
|
|
// Context menu for an iframe
|
|
checkContextMenu(["context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"frame", null,
|
|
["context-showonlythisframe", true,
|
|
"context-openframeintab", true,
|
|
"context-openframe", true,
|
|
"---", null,
|
|
"context-reloadframe", true,
|
|
"---", null,
|
|
"context-bookmarkframe", true,
|
|
"context-saveframe", true,
|
|
"---", null,
|
|
"context-printframe", true,
|
|
"---", null,
|
|
"context-viewframesource", true,
|
|
"context-viewframeinfo", true], null,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(video_in_iframe); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 12:
|
|
// Context menu for a video in an iframe
|
|
checkContextMenu(["context-media-play", true,
|
|
"context-media-mute", true,
|
|
"context-media-playbackrate", null,
|
|
["context-media-playbackrate-050x", true,
|
|
"context-media-playbackrate-100x", true,
|
|
"context-media-playbackrate-150x", true,
|
|
"context-media-playbackrate-200x", true], null,
|
|
"context-media-hidecontrols", true,
|
|
"context-video-showstats", true,
|
|
"context-video-fullscreen", true,
|
|
"---", null,
|
|
"context-viewvideo", true,
|
|
"context-copyvideourl", true,
|
|
"---", null,
|
|
"context-savevideo", true,
|
|
"context-video-saveimage", true,
|
|
"context-sendvideo", true,
|
|
"frame", null,
|
|
["context-showonlythisframe", true,
|
|
"context-openframeintab", true,
|
|
"context-openframe", true,
|
|
"---", null,
|
|
"context-reloadframe", true,
|
|
"---", null,
|
|
"context-bookmarkframe", true,
|
|
"context-saveframe", true,
|
|
"---", null,
|
|
"context-printframe", true,
|
|
"---", null,
|
|
"context-viewframeinfo", true], null].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(image_in_iframe); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 13:
|
|
// Context menu for an image in an iframe
|
|
checkContextMenu(["context-viewimage", true,
|
|
"context-copyimage-contents", true,
|
|
"context-copyimage", true,
|
|
"---", null,
|
|
"context-saveimage", true,
|
|
"context-sendimage", true,
|
|
"context-setDesktopBackground", true,
|
|
"context-viewimageinfo", true,
|
|
"frame", null,
|
|
["context-showonlythisframe", true,
|
|
"context-openframeintab", true,
|
|
"context-openframe", true,
|
|
"---", null,
|
|
"context-reloadframe", true,
|
|
"---", null,
|
|
"context-bookmarkframe", true,
|
|
"context-saveframe", true,
|
|
"---", null,
|
|
"context-printframe", true,
|
|
"---", null,
|
|
"context-viewframeinfo", true], null].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(textarea, false, true); // Invoke context menu for next test, but wait for the spellcheck.
|
|
break;
|
|
|
|
case 14:
|
|
// Context menu for textarea
|
|
checkContextMenu(["*chubbiness", true, // spelling suggestion
|
|
"spell-add-to-dictionary", true,
|
|
"---", null,
|
|
"context-undo", false,
|
|
"---", null,
|
|
"context-cut", false,
|
|
"context-copy", false,
|
|
"context-paste", null, // ignore clipboard state
|
|
"context-delete", false,
|
|
"---", null,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"spell-check-enabled", true,
|
|
"spell-dictionaries", true,
|
|
["spell-check-dictionary-en-US", true,
|
|
"---", null,
|
|
"spell-add-dictionaries", true], null
|
|
].concat(inspectItems));
|
|
contextMenu.ownerDocument.getElementById("spell-add-to-dictionary").doCommand(); // Add to dictionary
|
|
closeContextMenu();
|
|
openContextMenuFor(text); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 15:
|
|
// Re-check context menu for plain text to make sure it hasn't changed
|
|
checkContextMenu(plainTextItems);
|
|
closeContextMenu();
|
|
openContextMenuFor(textarea, false, true); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 16:
|
|
// Context menu for textarea after a word has been added
|
|
// to the dictionary
|
|
checkContextMenu(["spell-undo-add-to-dictionary", true,
|
|
"---", null,
|
|
"context-undo", false,
|
|
"---", null,
|
|
"context-cut", false,
|
|
"context-copy", false,
|
|
"context-paste", null, // ignore clipboard state
|
|
"context-delete", false,
|
|
"---", null,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"spell-check-enabled", true,
|
|
"spell-dictionaries", true,
|
|
["spell-check-dictionary-en-US", true,
|
|
"---", null,
|
|
"spell-add-dictionaries", true], null
|
|
].concat(inspectItems));
|
|
contextMenu.ownerDocument.getElementById("spell-undo-add-to-dictionary").doCommand(); // Undo add to dictionary
|
|
closeContextMenu();
|
|
openContextMenuFor(contenteditable, false, true);
|
|
break;
|
|
|
|
case 17:
|
|
// Context menu for contenteditable
|
|
checkContextMenu(["spell-no-suggestions", false,
|
|
"spell-add-to-dictionary", true,
|
|
"---", null,
|
|
"context-undo", false,
|
|
"---", null,
|
|
"context-cut", false,
|
|
"context-copy", false,
|
|
"context-paste", null, // ignore clipboard state
|
|
"context-delete", false,
|
|
"---", null,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"spell-check-enabled", true,
|
|
"spell-dictionaries", true,
|
|
["spell-check-dictionary-en-US", true,
|
|
"---", null,
|
|
"spell-add-dictionaries", true], null
|
|
].concat(inspectItems));
|
|
|
|
closeContextMenu();
|
|
openContextMenuFor(link); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 18:
|
|
executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
|
|
closeContextMenu();
|
|
openContextMenuFor(pagemenu); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 19:
|
|
// Context menu for element with assigned content context menu
|
|
checkContextMenu(["+Plain item", {type: "", icon: "", checked: false, disabled: false},
|
|
"+Disabled item", {type: "", icon: "", checked: false, disabled: true},
|
|
"+Item w/ textContent", {type: "", icon: "", checked: false, disabled: false},
|
|
"---", null,
|
|
"+Checkbox", {type: "checkbox", icon: "", checked: true, disabled: false},
|
|
"---", null,
|
|
"+Radio1", {type: "checkbox", icon: "", checked: true, disabled: false},
|
|
"+Radio2", {type: "checkbox", icon: "", checked: false, disabled: false},
|
|
"+Radio3", {type: "checkbox", icon: "", checked: false, disabled: false},
|
|
"---", null,
|
|
"+Item w/ icon", {type: "", icon: "favicon.ico", checked: false, disabled: false},
|
|
"+Item w/ bad icon", {type: "", icon: "", checked: false, disabled: false},
|
|
"---", null,
|
|
"generated-submenu-1", true,
|
|
["+Radio1", {type: "checkbox", icon: "", checked: false, disabled: false},
|
|
"+Radio2", {type: "checkbox", icon: "", checked: true, disabled: false},
|
|
"+Radio3", {type: "checkbox", icon: "", checked: false, disabled: false},
|
|
"---", null,
|
|
"+Checkbox", {type: "checkbox", icon: "", checked: false, disabled: false}], null,
|
|
"---", null,
|
|
"context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems));
|
|
|
|
invokeItemAction("0");
|
|
closeContextMenu();
|
|
|
|
// run mozRequestFullScreen on the element we're testing
|
|
var full_screen_element = subwindow.document.getElementById("test-dom-full-screen");
|
|
var openDomFullScreen = function() {
|
|
subwindow.removeEventListener("mozfullscreenchange", openDomFullScreen, false);
|
|
openContextMenuFor(dom_full_screen, true); // Invoke context menu for next test.
|
|
}
|
|
subwindow.addEventListener("mozfullscreenchange", openDomFullScreen, false);
|
|
SpecialPowers.setBoolPref("full-screen-api.approval-required", false);
|
|
SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only", false);
|
|
full_screen_element.mozRequestFullScreen();
|
|
break;
|
|
|
|
case 20:
|
|
// Context menu for DOM Fullscreen mode (NOTE: this is *NOT* on an img)
|
|
checkContextMenu(["context-leave-dom-fullscreen", true,
|
|
"---", null,
|
|
"context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
var full_screen_element = subwindow.document.getElementById("test-dom-full-screen");
|
|
var openPagemenu = function() {
|
|
subwindow.removeEventListener("mozfullscreenchange", openPagemenu, false);
|
|
SpecialPowers.clearUserPref("full-screen-api.approval-required");
|
|
SpecialPowers.clearUserPref("full-screen-api.allow-trusted-requests-only");
|
|
openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
|
|
}
|
|
subwindow.addEventListener("mozfullscreenchange", openPagemenu, false);
|
|
subwindow.document.mozCancelFullScreen();
|
|
break;
|
|
|
|
case 21:
|
|
// Context menu for element with assigned content context menu
|
|
// The shift key should bypass content context menu processing
|
|
checkContextMenu(["context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
selectText(selecttext); // Select text prior to opening context menu.
|
|
openContextMenuFor(selecttext); // Invoke context menu for next test.
|
|
return;
|
|
|
|
case 22:
|
|
// Context menu for selected text
|
|
if (SpecialPowers.Services.appinfo.OS == "Darwin") {
|
|
// This test is only enabled on Mac due to bug 736399.
|
|
checkContextMenu(["context-copy", true,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-searchselect", true,
|
|
"context-viewpartialsource-selection", true
|
|
].concat(inspectItems));
|
|
}
|
|
closeContextMenu();
|
|
selectText(selecttextlink); // Select text prior to opening context menu.
|
|
openContextMenuFor(selecttextlink); // Invoke context menu for next test.
|
|
return;
|
|
|
|
case 23:
|
|
// Context menu for selected text which matches valid URL pattern
|
|
if (SpecialPowers.Services.appinfo.OS == "Darwin") {
|
|
// This test is only enabled on Mac due to bug 736399.
|
|
if (perWindowPrivateBrowsing) {
|
|
checkContextMenu(["context-openlinkincurrent", true,
|
|
"context-openlinkintab", true,
|
|
"context-openlink", true,
|
|
"context-openlinkprivate", true,
|
|
"---", null,
|
|
"context-bookmarklink", true,
|
|
"context-savelink", true,
|
|
"context-copy", true,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-searchselect", true,
|
|
"context-viewpartialsource-selection", true
|
|
].concat(inspectItems));
|
|
} else {
|
|
checkContextMenu(["context-openlinkincurrent", true,
|
|
"context-openlinkintab", true,
|
|
"context-openlink", true,
|
|
"---", null,
|
|
"context-bookmarklink", true,
|
|
"context-savelink", true,
|
|
"context-copy", true,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-searchselect", true,
|
|
"context-viewpartialsource-selection", true
|
|
].concat(inspectItems));
|
|
}
|
|
}
|
|
closeContextMenu();
|
|
// clear the selection because following tests don't expect any selection
|
|
subwindow.getSelection().removeAllRanges();
|
|
|
|
openContextMenuFor(imagelink)
|
|
break;
|
|
|
|
case 24:
|
|
// Context menu for image link
|
|
if (perWindowPrivateBrowsing) {
|
|
checkContextMenu(["context-openlinkintab", true,
|
|
"context-openlink", true,
|
|
"context-openlinkprivate", true,
|
|
"---", null,
|
|
"context-bookmarklink", true,
|
|
"context-savelink", true,
|
|
"context-copylink", true,
|
|
"---", null,
|
|
"context-viewimage", true,
|
|
"context-copyimage-contents", true,
|
|
"context-copyimage", true,
|
|
"---", null,
|
|
"context-saveimage", true,
|
|
"context-sendimage", true,
|
|
"context-setDesktopBackground", true,
|
|
"context-viewimageinfo", true
|
|
].concat(inspectItems));
|
|
} else {
|
|
checkContextMenu(["context-openlinkintab", true,
|
|
"context-openlink", true,
|
|
"---", null,
|
|
"context-bookmarklink", true,
|
|
"context-savelink", true,
|
|
"context-copylink", true,
|
|
"---", null,
|
|
"context-viewimage", true,
|
|
"context-copyimage-contents", true,
|
|
"context-copyimage", true,
|
|
"---", null,
|
|
"context-saveimage", true,
|
|
"context-sendimage", true,
|
|
"context-setDesktopBackground", true,
|
|
"context-viewimageinfo", true
|
|
].concat(inspectItems));
|
|
}
|
|
closeContextMenu();
|
|
selectInputText(select_inputtext); // Select text prior to opening context menu.
|
|
openContextMenuFor(select_inputtext); // Invoke context menu for next test.
|
|
return;
|
|
|
|
case 25:
|
|
// Context menu for selected text in input
|
|
checkContextMenu(["context-undo", false,
|
|
"---", null,
|
|
"context-cut", true,
|
|
"context-copy", true,
|
|
"context-paste", null, // ignore clipboard state
|
|
"context-delete", true,
|
|
"---", null,
|
|
"context-selectall", true,
|
|
"context-searchselect",true,
|
|
"---", null,
|
|
"spell-check-enabled", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
selectInputText(select_inputtext_password); // Select text prior to opening context menu.
|
|
openContextMenuFor(select_inputtext_password); // Invoke context menu for next test.
|
|
return;
|
|
|
|
case 26:
|
|
// Context menu for selected text in input[type="password"]
|
|
checkContextMenu(["context-undo", false,
|
|
"---", null,
|
|
"context-cut", true,
|
|
"context-copy", true,
|
|
"context-paste", null, // ignore clipboard state
|
|
"context-delete", true,
|
|
"---", null,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"spell-check-enabled", true,
|
|
//spell checker is shown on input[type="password"] on this testcase
|
|
"spell-dictionaries", true,
|
|
["spell-check-dictionary-en-US", true,
|
|
"---", null,
|
|
"spell-add-dictionaries", true], null
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
subwindow.getSelection().removeAllRanges();
|
|
openContextMenuFor(plugin);
|
|
return;
|
|
|
|
case 27:
|
|
// Context menu for click-to-play blocked plugin
|
|
checkContextMenu(["context-ctp-play", true,
|
|
"context-ctp-hide", true,
|
|
"---", null,
|
|
"context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
SpecialPowers.clearUserPref("plugins.click_to_play");
|
|
getTestPlugin().enabledState = Ci.nsIPluginTag.STATE_ENABLED;
|
|
openContextMenuFor(longdesc);
|
|
return;
|
|
|
|
case 28:
|
|
// Context menu for an image with longdesc
|
|
checkContextMenu(["context-viewimage", true,
|
|
"context-copyimage-contents", true,
|
|
"context-copyimage", true,
|
|
"---", null,
|
|
"context-saveimage", true,
|
|
"context-sendimage", true,
|
|
"context-setDesktopBackground", true,
|
|
"context-viewimageinfo", true,
|
|
"context-viewimagedesc", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(srcdoc);
|
|
return;
|
|
|
|
case 29:
|
|
// Context menu for an iframe with srcdoc attribute set
|
|
checkContextMenu(["context-back", false,
|
|
"context-forward", false,
|
|
"context-reload", true,
|
|
"---", null,
|
|
"context-bookmarkpage", true,
|
|
"context-savepage", true,
|
|
"---", null,
|
|
"context-viewbgimage", false,
|
|
"context-selectall", true,
|
|
"frame", null,
|
|
["context-reloadframe", true,
|
|
"---", null,
|
|
"context-saveframe", true,
|
|
"---", null,
|
|
"context-printframe", true,
|
|
"---", null,
|
|
"context-viewframesource", true,
|
|
"context-viewframeinfo", true], null,
|
|
"---", null,
|
|
"context-viewsource", true,
|
|
"context-viewinfo", true
|
|
].concat(inspectItems));
|
|
closeContextMenu();
|
|
openContextMenuFor(inputspellfalse, false, true); // Invoke context menu for next test.
|
|
break;
|
|
|
|
case 30:
|
|
// Context menu for text input field with spellcheck=false
|
|
checkContextMenu(["context-undo", false,
|
|
"---", null,
|
|
"context-cut", false,
|
|
"context-copy", false,
|
|
"context-paste", null, // ignore clipboard state
|
|
"context-delete", false,
|
|
"---", null,
|
|
"context-selectall", true,
|
|
"---", null,
|
|
"spell-add-dictionaries-main", true,
|
|
].concat(inspectItems));
|
|
|
|
// finish test
|
|
subwindow.close();
|
|
SimpleTest.finish();
|
|
return;
|
|
|
|
/*
|
|
* Other things that would be nice to test:
|
|
* - check state of disabled items
|
|
* - test execution of menu items (maybe as a separate test?)
|
|
*/
|
|
|
|
default:
|
|
ok(false, "Unexpected invocation of test #" + testNum);
|
|
subwindow.close();
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
var testNum = 1;
|
|
var subwindow, chromeWin, contextMenu;
|
|
var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2,
|
|
iframe, video_in_iframe, image_in_iframe, textarea, contenteditable,
|
|
pagemenu, dom_full_screen, plainTextItems, audio_in_video,
|
|
selecttext, selecttextlink, imagelink, select_inputtext, select_inputtext_password,
|
|
plugin, longdesc, iframe, inputspellfalse;
|
|
|
|
function startTest() {
|
|
chromeWin = SpecialPowers.wrap(subwindow)
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
.QueryInterface(Ci.nsIDocShellTreeItem)
|
|
.rootTreeItem
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
.getInterface(Ci.nsIDOMWindow)
|
|
.QueryInterface(Ci.nsIDOMChromeWindow);
|
|
contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");
|
|
ok(contextMenu, "Got context menu XUL");
|
|
|
|
if (chromeWin.document.getElementById("Browser:Stop").getAttribute("disabled") != "true") {
|
|
todo(false, "Wait for subwindow to load... (This should usually happen once.)");
|
|
SimpleTest.executeSoon(startTest);
|
|
return;
|
|
}
|
|
|
|
subwindow.allowFullscreen = true;
|
|
lastElement = null;
|
|
|
|
text = subwindow.document.getElementById("test-text");
|
|
link = subwindow.document.getElementById("test-link");
|
|
imagelink = subwindow.document.getElementById("test-image-link");
|
|
mailto = subwindow.document.getElementById("test-mailto");
|
|
input = subwindow.document.getElementById("test-input");
|
|
img = subwindow.document.getElementById("test-image");
|
|
canvas = subwindow.document.getElementById("test-canvas");
|
|
video_ok = subwindow.document.getElementById("test-video-ok");
|
|
audio_in_video = subwindow.document.getElementById("test-audio-in-video");
|
|
video_bad = subwindow.document.getElementById("test-video-bad");
|
|
video_bad2 = subwindow.document.getElementById("test-video-bad2");
|
|
iframe = subwindow.document.getElementById("test-iframe");
|
|
video_in_iframe = subwindow.document.getElementById("test-video-in-iframe").contentDocument.getElementsByTagName("video")[0];
|
|
video_in_iframe.pause();
|
|
image_in_iframe = subwindow.document.getElementById("test-image-in-iframe").contentDocument.getElementsByTagName("img")[0];
|
|
textarea = subwindow.document.getElementById("test-textarea");
|
|
contenteditable = subwindow.document.getElementById("test-contenteditable");
|
|
contenteditable.focus(); // content editable needs to be focused to enable spellcheck
|
|
inputspellfalse = subwindow.document.getElementById("test-contenteditable-spellcheck-false");
|
|
inputspellfalse.focus(); // content editable needs to be focused to enable spellcheck
|
|
pagemenu = subwindow.document.getElementById("test-pagemenu");
|
|
dom_full_screen = subwindow.document.getElementById("test-dom-full-screen");
|
|
selecttext = subwindow.document.getElementById("test-select-text");
|
|
selecttextlink = subwindow.document.getElementById("test-select-text-link");
|
|
select_inputtext = subwindow.document.getElementById("test-select-input-text");
|
|
select_inputtext_password = subwindow.document.getElementById("test-select-input-text-type-password");
|
|
plugin = subwindow.document.getElementById("test-plugin");
|
|
longdesc = subwindow.document.getElementById("test-longdesc");
|
|
srcdoc = subwindow.document.getElementById("test-srcdoc");
|
|
|
|
contextMenu.addEventListener("popupshown", function() { runTest(++testNum); }, false);
|
|
runTest(1);
|
|
}
|
|
|
|
// We open this in a separate window, because the Mochitests run inside a frame.
|
|
// The frame causes an extra menu item, and prevents running the test
|
|
// standalone (ie, clicking the test name in the Mochitest window) to see
|
|
// success/failure messages.
|
|
var painted = false, loaded = false;
|
|
|
|
function waitForEvents(event)
|
|
{
|
|
if (event.type == "MozAfterPaint")
|
|
painted = true;
|
|
else if (event.type == "load")
|
|
loaded = true;
|
|
if (painted && loaded) {
|
|
subwindow.removeEventListener("MozAfterPaint", waitForEvents, false);
|
|
subwindow.onload = null;
|
|
startTest();
|
|
}
|
|
}
|
|
|
|
const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1;
|
|
|
|
if (isOSXMtnLion) {
|
|
todo(false, "Mountain Lion doesn't like this test (bug 792304)");
|
|
} else {
|
|
SpecialPowers.setBoolPref("plugins.click_to_play", true);
|
|
setTestPluginEnabledState(Ci.nsIPluginTag.STATE_CLICKTOPLAY);
|
|
|
|
var subwindow = window.open("./subtst_contextmenu.html", "contextmenu-subtext", "width=600,height=800");
|
|
subwindow.addEventListener("MozAfterPaint", waitForEvents, false);
|
|
subwindow.onload = waitForEvents;
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
}
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|