diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 01cb1bb5c0d1..a81bfde73dee 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -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"); diff --git a/browser/base/content/test/test_contextmenu.html b/browser/base/content/test/test_contextmenu.html index 7df3b3e3b989..dd832d551f32 100644 --- a/browser/base/content/test/test_contextmenu.html +++ b/browser/base/content/test/test_contextmenu.html @@ -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'); diff --git a/toolkit/content/tests/chrome/test_textbox_dictionary.xul b/toolkit/content/tests/chrome/test_textbox_dictionary.xul index 53a0bb9e081c..4574df02b4ab 100644 --- a/toolkit/content/tests/chrome/test_textbox_dictionary.xul +++ b/toolkit/content/tests/chrome/test_textbox_dictionary.xul @@ -2,9 +2,9 @@ - @@ -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(); diff --git a/toolkit/content/widgets/textbox.xml b/toolkit/content/widgets/textbox.xml index b2a663dc8cc7..2c01da634007 100644 --- a/toolkit/content/widgets/textbox.xml +++ b/toolkit/content/widgets/textbox.xml @@ -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);