diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index 22abb601e1cf..9804b096563e 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -261,16 +261,18 @@ nsContextMenu.prototype = { }, initMiscItems: function CM_initMiscItems() { + var isTextSelected = this.isTextSelected; + // Use "Bookmark This Link" if on a link. this.showItem("context-bookmarkpage", !(this.isContentSelected || this.onTextInput || this.onLink || this.onImage || this.onVideo || this.onAudio)); this.showItem("context-bookmarklink", this.onLink && !this.onMailtoLink); - this.showItem("context-searchselect", this.isTextSelected); + this.showItem("context-searchselect", isTextSelected); this.showItem("context-keywordfield", this.onTextInput && this.onKeywordField); this.showItem("frame", this.inFrame); - this.showItem("frame-sep", this.inFrame); + this.showItem("frame-sep", this.inFrame && isTextSelected); // Hide menu entries for images, show otherwise if (this.inFrame) { diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 9c1e48993f4e..e25d71dab665 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -86,6 +86,7 @@ _BROWSER_FILES = \ browser_bug405137.js \ browser_bug409481.js \ browser_bug413915.js \ + browser_bug417483.js \ browser_bug419612.js \ browser_bug420160.js \ browser_bug424101.js \ diff --git a/browser/base/content/test/browser_bug417483.js b/browser/base/content/test/browser_bug417483.js new file mode 100644 index 000000000000..0f1d6c760fd2 --- /dev/null +++ b/browser/base/content/test/browser_bug417483.js @@ -0,0 +1,26 @@ +function test() { + waitForExplicitFinish(); + + var htmlContent = "data:text/html, "; + gBrowser.addEventListener("pageshow", onPageShow, false); + gBrowser.loadURI(htmlContent); +} + +function onPageShow() { + gBrowser.removeEventListener("pageshow", onPageShow, false); + var frame = gBrowser.contentWindow.frames[0]; + var sel = frame.getSelection(); + var range = frame.document.createRange(); + var tn = frame.document.body.childNodes[0]; + range.setStart(tn , 4); + range.setEnd(tn , 5); + sel.addRange(range); + frame.focus(); + + document.popupNode = frame.document.body; + var contentAreaContextMenu = document.getElementById("contentAreaContextMenu"); + var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser); + + ok(document.getElementById("frame-sep").hidden, "'frame-sep' should be hidden if the selection contains only spaces"); + finish(); +}