Bug 641217 - Show context menu for password fields [r+a=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Sat, 12 Mar 2011 09:10:56 -0800
changeset 67507 982e4a2728115c730531376b48f60e23b0fbccbb
parent 67506 31be3e9a5400ecc96c651d960006a80ecc4dfe60
child 67508 de07f7153c482412f799f06e68758fef340d630c
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs641217
Bug 641217 - Show context menu for password fields [r+a=mfinkle]
mobile/chrome/content/content.js
--- a/mobile/chrome/content/content.js
+++ b/mobile/chrome/content/content.js
@@ -842,27 +842,31 @@ var ContextHandler = {
 
           // Target is a link or a descendant of a link.
           state.types.push("link");
           state.label = state.linkURL = this._getLinkURL(elem);
           state.linkTitle = popupNode.textContent || popupNode.title;
           state.linkProtocol = this._getProtocol(this._getURI(state.linkURL));
           break;
         } else if ((elem instanceof Ci.nsIDOMHTMLInputElement &&
-                    elem.mozIsTextField(true)) || elem instanceof Ci.nsIDOMHTMLTextAreaElement) {
+                    elem.mozIsTextField(false)) || elem instanceof Ci.nsIDOMHTMLTextAreaElement) {
           let selectionStart = elem.selectionStart;
           let selectionEnd = elem.selectionEnd;
 
           state.types.push("input-text");
-          if (selectionStart != selectionEnd) {
-            state.types.push("copy");
-            state.string = elem.value.slice(selectionStart, selectionEnd);
-          } else if (elem.value) {
-            state.types.push("copy-all");
-            state.string = elem.value;
+
+          // Don't include "copy" for password fields.
+          if (elem.mozIsTextField(true)) {
+            if (selectionStart != selectionEnd) {
+              state.types.push("copy");
+              state.string = elem.value.slice(selectionStart, selectionEnd);
+            } else if (elem.value) {
+              state.types.push("copy-all");
+              state.string = elem.value;
+            }
           }
 
           if (selectionStart > 0 || selectionEnd < elem.textLength)
             state.types.push("select-all");
 
           let clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
           let flavors = ["text/unicode"];
           let hasData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard);