Commit 43b3e98f authored by Michael Schonfeld's avatar Michael Schonfeld
Browse files

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

parent 56a87d45
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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) {
+1 −0
Original line number Diff line number Diff line
@@ -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 \
+26 −0
Original line number Diff line number Diff line
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();
}