Bug 433168 - Context menu is not shown for form buttons and select elements. r=gavin
authorJohan Charlez <johan.charlez@gmail.com>
Thu, 13 Dec 2012 01:09:49 -0500
changeset 115886 bc5a2f85d15ea5e57bde618df540a0f0af8cf45c
parent 115885 11965bca7513508ad256a5d018b0257981d62b39
child 115887 eddc239db46201c974c786aca1eba1fc3ddcd2ee
push id24028
push useremorley@mozilla.com
push dateThu, 13 Dec 2012 15:56:02 +0000
treeherderautoland@9db79b97abbb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs433168
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 433168 - Context menu is not shown for form buttons and select elements. r=gavin
browser/base/content/nsContextMenu.js
browser/base/content/test/browser_bug424101.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -433,18 +433,17 @@ nsContextMenu.prototype = {
       }.bind(this));
     }
   },
 
   // Set various context menu attributes based on the state of the world.
   setTarget: function (aNode, aRangeParent, aRangeOffset) {
     const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
     if (aNode.namespaceURI == xulNS ||
-        aNode.nodeType == Node.DOCUMENT_NODE ||
-        this.isTargetAFormControl(aNode)) {
+        aNode.nodeType == Node.DOCUMENT_NODE) {
       this.shouldDisplay = false;
       return;
     }
 
     // Initialize contextual info.
     this.onImage           = false;
     this.onLoadedImage     = false;
     this.onCompletedImage  = false;
@@ -1292,28 +1291,16 @@ nsContextMenu.prototype = {
     return "contextMenu.target     = " + this.target + "\n" +
            "contextMenu.onImage    = " + this.onImage + "\n" +
            "contextMenu.onLink     = " + this.onLink + "\n" +
            "contextMenu.link       = " + this.link + "\n" +
            "contextMenu.inFrame    = " + this.inFrame + "\n" +
            "contextMenu.hasBGImage = " + this.hasBGImage + "\n";
   },
 
-  // Returns true if aNode is a from control (except text boxes and images).
-  // This is used to disable the context menu for form controls.
-  isTargetAFormControl: function(aNode) {
-    if (aNode instanceof HTMLInputElement)
-      return (!aNode.mozIsTextField(false) && aNode.type != "image");
-
-    return (aNode instanceof HTMLButtonElement) ||
-           (aNode instanceof HTMLSelectElement) ||
-           (aNode instanceof HTMLOptionElement) ||
-           (aNode instanceof HTMLOptGroupElement);
-  },
-
   isTargetATextBox: function(node) {
     if (node instanceof HTMLInputElement)
       return node.mozIsTextField(false);
 
     return (node instanceof HTMLTextAreaElement);
   },
 
   isTargetAKeywordField: function(aNode) {
--- a/browser/base/content/test/browser_bug424101.js
+++ b/browser/base/content/test/browser_bug424101.js
@@ -29,25 +29,25 @@ function test() {
       let contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
 
       is(contextMenu.shouldDisplay, expected, "context menu behavior for <" + tag + "> is wrong");
     };
 
     testInput("text", true);
     testInput("password", true);
     testInput("image", true);
-    testInput("button", false);
-    testInput("submit", false);
-    testInput("reset", false);
-    testInput("checkbox", false);
-    testInput("radio", false);
-    testElement("button", false);
-    testElement("select", false);
-    testElement("option", false);
-    testElement("optgroup", false);
+    testInput("button", true);
+    testInput("submit", true);
+    testInput("reset", true);
+    testInput("checkbox", true);
+    testInput("radio", true);
+    testElement("button", true);
+    testElement("select", true);
+    testElement("option", true);
+    testElement("optgroup", true);
 
     // cleanup
     document.popupNode = null;
     gBrowser.removeCurrentTab();
     finish();
   }, true);
   content.location = "data:text/html,test";
 }