зеркало из https://github.com/mozilla/gecko-dev.git
Bug 722636 - Only show "Undo Add to Dictionary" context menu on text fields and add separator r=ehsan
--HG-- extra : rebase_source : 85fab3254730ef89d66fe86b4a6fb6c8f392b882
This commit is contained in:
Родитель
7263196932
Коммит
aa0a90e6d3
|
@ -331,16 +331,17 @@ nsContextMenu.prototype = {
|
|||
initSpellingItems: function() {
|
||||
var canSpell = InlineSpellCheckerUI.canSpellCheck;
|
||||
var onMisspelling = InlineSpellCheckerUI.overMisspelling;
|
||||
var showUndo = canSpell && InlineSpellCheckerUI.canUndo();
|
||||
this.showItem("spell-check-enabled", canSpell);
|
||||
this.showItem("spell-separator", canSpell || this.onEditableArea);
|
||||
document.getElementById("spell-check-enabled")
|
||||
.setAttribute("checked", canSpell && InlineSpellCheckerUI.enabled);
|
||||
|
||||
this.showItem("spell-add-to-dictionary", onMisspelling);
|
||||
this.showItem("spell-undo-add-to-dictionary", InlineSpellCheckerUI.canUndo());
|
||||
this.showItem("spell-undo-add-to-dictionary", showUndo);
|
||||
|
||||
// suggestion list
|
||||
this.showItem("spell-suggestions-separator", onMisspelling);
|
||||
this.showItem("spell-suggestions-separator", onMisspelling || showUndo);
|
||||
if (onMisspelling) {
|
||||
var suggestionsSeparator =
|
||||
document.getElementById("spell-add-to-dictionary");
|
||||
|
|
|
@ -258,7 +258,7 @@ function runTest(testNum) {
|
|||
|
||||
case 2:
|
||||
// Context menu for plain text
|
||||
checkContextMenu(["context-back", false,
|
||||
plainTextItems = ["context-back", false,
|
||||
"context-forward", false,
|
||||
"context-reload", true,
|
||||
"context-stop", false,
|
||||
|
@ -272,7 +272,8 @@ function runTest(testNum) {
|
|||
"---", null,
|
||||
"context-viewsource", true,
|
||||
"context-viewinfo", true
|
||||
].concat(inspectItems));
|
||||
].concat(inspectItems);
|
||||
checkContextMenu(plainTextItems);
|
||||
closeContextMenu();
|
||||
openContextMenuFor(link); // Invoke context menu for next test.
|
||||
break;
|
||||
|
@ -513,13 +514,21 @@ function runTest(testNum) {
|
|||
].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 15:
|
||||
|
||||
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,
|
||||
|
@ -540,7 +549,7 @@ function runTest(testNum) {
|
|||
openContextMenuFor(contenteditable);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case 17:
|
||||
// Context menu for contenteditable
|
||||
checkContextMenu(["spell-no-suggestions", false,
|
||||
"spell-add-to-dictionary", true,
|
||||
|
@ -565,7 +574,7 @@ function runTest(testNum) {
|
|||
openContextMenuFor(inputspell); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 17:
|
||||
case 18:
|
||||
// Context menu for spell-check input
|
||||
checkContextMenu(["*prodigality", true, // spelling suggestion
|
||||
"spell-add-to-dictionary", true,
|
||||
|
@ -590,13 +599,13 @@ function runTest(testNum) {
|
|||
openContextMenuFor(link); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 18:
|
||||
case 19:
|
||||
executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
|
||||
closeContextMenu();
|
||||
openContextMenuFor(pagemenu); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 19:
|
||||
case 20:
|
||||
// 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},
|
||||
|
@ -639,7 +648,7 @@ function runTest(testNum) {
|
|||
openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
|
||||
break;
|
||||
|
||||
case 20:
|
||||
case 21:
|
||||
// Context menu for element with assigned content context menu
|
||||
// The shift key should bypass content context menu processing
|
||||
checkContextMenu(["context-back", false,
|
||||
|
@ -684,7 +693,7 @@ function runTest(testNum) {
|
|||
var testNum = 1;
|
||||
var subwindow, chromeWin, contextMenu, lastElement;
|
||||
var text, link, mailto, input, img, canvas, video_ok, video_bad, video_bad2,
|
||||
iframe, video_in_iframe, image_in_iframe, textarea, contenteditable, inputspell, pagemenu;
|
||||
iframe, video_in_iframe, image_in_iframe, textarea, contenteditable, inputspell, pagemenu, plainTextItems;
|
||||
|
||||
function startTest() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
||||
<!--
|
||||
XUL Widget Test for textbox with placeholder
|
||||
XUL Widget Test for textbox with Add and Undo Add to Dictionary
|
||||
-->
|
||||
<window title="Textbox Add and Undo Add Dictionary Test" width="500" height="600"
|
||||
<window title="Textbox Add and Undo Add to Dictionary Test" width="500" height="600"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
||||
|
@ -55,8 +55,11 @@ function runContextMenuTest()
|
|||
{
|
||||
case 0: // "Add to Dictionary" button
|
||||
var addToDict = contextMenu.querySelector("[anonid=spell-add-to-dictionary]");
|
||||
is(!addToDict.hidden, true, "Is Add to Dictionary visible?");
|
||||
|
||||
ok(!addToDict.hidden, "Is Add to Dictionary visible?");
|
||||
|
||||
var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
|
||||
ok(!separator.hidden, "Is separator visible?");
|
||||
|
||||
addToDict.doCommand();
|
||||
|
||||
contextMenu.hidePopup();
|
||||
|
@ -67,8 +70,11 @@ function runContextMenuTest()
|
|||
|
||||
case 1: // "Undo Add to Dictionary" button
|
||||
var undoAddDict = contextMenu.querySelector("[anonid=spell-undo-add-to-dictionary]");
|
||||
is(!undoAddDict.hidden, true, "Is Undo Add to Dictioanry visible?");
|
||||
|
||||
ok(!undoAddDict.hidden, "Is Undo Add to Dictioanry visible?");
|
||||
|
||||
var separator = contextMenu.querySelector("[anonid=spell-suggestions-separator]");
|
||||
ok(!separator.hidden, "Is separator hidden?");
|
||||
|
||||
undoAddDict.doCommand();
|
||||
|
||||
contextMenu.hidePopup();
|
||||
|
|
|
@ -592,12 +592,13 @@
|
|||
document.popupRangeOffset);
|
||||
|
||||
var enabled = spellui.enabled;
|
||||
var showUndo = spellui.canSpellCheck && spellui.canUndo();
|
||||
this._enabledCheckbox.setAttribute("checked", enabled);
|
||||
|
||||
var overMisspelling = spellui.overMisspelling;
|
||||
this._setMenuItemVisibility("spell-add-to-dictionary", overMisspelling);
|
||||
this._setMenuItemVisibility("spell-undo-add-to-dictionary", spellui.canUndo());
|
||||
this._setMenuItemVisibility("spell-suggestions-separator", overMisspelling);
|
||||
this._setMenuItemVisibility("spell-undo-add-to-dictionary", showUndo);
|
||||
this._setMenuItemVisibility("spell-suggestions-separator", overMisspelling || showUndo);
|
||||
|
||||
// suggestion list
|
||||
var numsug = spellui.addSuggestionsToMenu(popupNode, this._suggestionsSeparator, 5);
|
||||
|
|
Загрузка…
Ссылка в новой задаче