Bug 1169702 - Toggle viewing the password contents in the capture doorhanger upon focus/blur. r=MattN, a=sledru
authorBernardo P. Rittmeyer <bernardo@rittme.com>
Mon, 15 Jun 2015 10:47:10 -0700
changeset 275085 06984d7e828ebc6f206cf829e840197e1e6c918d
parent 275084 984d1cdbaf25f8ddd19483a07ca75bb013cca808
child 275086 334a095aba523e21627ce957307b396814899ee9
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, sledru
bugs1169702
milestone40.0a2
Bug 1169702 - Toggle viewing the password contents in the capture doorhanger upon focus/blur. r=MattN, a=sledru
browser/base/content/popup-notifications.inc
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
--- a/browser/base/content/popup-notifications.inc
+++ b/browser/base/content/popup-notifications.inc
@@ -52,17 +52,17 @@
       <popupnotificationcontent orient="vertical" align="start">
         <label id="pointerLock-cancel">&pointerLock.notification.message;</label>
       </popupnotificationcontent>
     </popupnotification>
 
     <popupnotification id="password-notification" hidden="true">
       <popupnotificationcontent orient="vertical">
         <textbox id="password-notification-username"/>
-        <textbox id="password-notification-password" type="password"/>
+        <textbox id="password-notification-password" type="password" show-content=""/>
       </popupnotificationcontent>
     </popupnotification>
 
     <vbox id="login-fill-doorhanger" hidden="true">
       <description id="login-fill-testing"
                    value="Thanks for testing the login fill doorhanger!"/>
       <textbox id="login-fill-filter"/>
       <richlistbox id="login-fill-list"/>
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -878,16 +878,24 @@ LoginManagerPrompter.prototype = {
         chromeDoc.getElementById("password-notification-password").value;
     };
 
     let onInput = () => {
       readDataFromUI();
       updateButtonLabel();
     };
 
+    let onPasswordFocus = () => {
+      chromeDoc.getElementById("password-notification-password").type = "";
+    };
+
+    let onPasswordBlur = () => {
+      chromeDoc.getElementById("password-notification-password").type = "password";
+    };
+
     let persistData = () => {
       let foundLogins = Services.logins.findLogins({}, login.hostname,
                                                    login.formSubmitURL,
                                                    login.httpRealm);
       let logins = foundLogins.filter(l => l.username == login.username);
       if (logins.length == 0) {
         // The original login we have been provided with might have its own
         // metadata, but we don't want it propagated to the newly created one.
@@ -954,29 +962,37 @@ LoginManagerPrompter.prototype = {
         eventCallback: function (topic) {
           switch (topic) {
             case "showing":
               currentNotification = this;
               chromeDoc.getElementById("password-notification-username")
                        .addEventListener("input", onInput);
               chromeDoc.getElementById("password-notification-password")
                        .addEventListener("input", onInput);
+              chromeDoc.getElementById("password-notification-password")
+                       .addEventListener("focus", onPasswordFocus);
+              chromeDoc.getElementById("password-notification-password")
+                       .addEventListener("blur", onPasswordBlur);
               break;
             case "shown":
               writeDataToUI();
               break;
             case "dismissed":
               readDataFromUI();
               // Fall through.
             case "removed":
               currentNotification = null;
               chromeDoc.getElementById("password-notification-username")
                        .removeEventListener("input", onInput);
               chromeDoc.getElementById("password-notification-password")
                        .removeEventListener("input", onInput);
+              chromeDoc.getElementById("password-notification-password")
+                       .removeEventListener("focus", onPasswordFocus);
+              chromeDoc.getElementById("password-notification-password")
+                       .removeEventListener("blur", onPasswordBlur);
               break;
           }
           return false;
         },
       }
     );
   },