Bug 417483 - Double separator in context menu when selecting empty text & using iframes r=gavin

This commit is contained in:
Michael Schonfeld 2009-09-14 11:19:58 -04:00
parent 56a87d458e
commit 43b3e98f73
3 changed files with 31 additions and 2 deletions

View File

@ -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) {

View File

@ -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 \

View File

@ -0,0 +1,26 @@
function test() {
waitForExplicitFinish();
var htmlContent = "data:text/html, <iframe src='data:text/html,text text'></iframe>";
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();
}