Bug 1178855 - Hide password visibility toggle when capture doorhanger is closed. r=MattN draft
authorSaad Quadri <saad@saadquadri.com>
Wed, 08 Jun 2016 14:18:59 -0700
changeset 380086 98ea1e065d1dda200a3e9a23b10acfcc242b09d1
parent 376593 f8ad071a6e14331d73fa44c8d3108bc2b66b2174
child 523638 b2fb80f1741629453d483e6454520842ef796c5b
push id21129
push usersaad@saadquadri.com
push dateMon, 20 Jun 2016 16:05:43 +0000
reviewersMattN
bugs1178855
milestone50.0a1
Bug 1178855 - Hide password visibility toggle when capture doorhanger is closed. r=MattN MozReview-Commit-ID: 75Pz7jG0RLW
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -970,21 +970,26 @@ LoginManagerPrompter.prototype = {
               let toggleBtn = chromeDoc.getElementById("password-notification-visibilityToggle");
 
               if (Services.prefs.getBoolPref("signon.rememberSignons.visibilityToggle")) {
                 toggleBtn.addEventListener("command", onVisibilityToggle);
                 toggleBtn.setAttribute("label", togglePasswordLabel);
                 toggleBtn.setAttribute("accesskey", togglePasswordAccessKey);
                 toggleBtn.setAttribute("hidden", LoginHelper.isMasterPasswordSet());
               }
+              if (this.wasDismissed) {
+                chromeDoc.getElementById("password-notification-visibilityToggle")
+                         .setAttribute("hidden", true);
+              }
               break;
             case "shown":
               writeDataToUI();
               break;
             case "dismissed":
+              this.wasDismissed = true;
               readDataFromUI();
               // Fall through.
             case "removed":
               currentNotification = null;
               chromeDoc.getElementById("password-notification-username")
                        .removeEventListener("input", onInput);
               chromeDoc.getElementById("password-notification-password")
                        .removeEventListener("input", onInput);
--- a/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
+++ b/toolkit/components/passwordmgr/test/browser/browser_capture_doorhanger.js
@@ -548,10 +548,33 @@ add_task(function* test_recipeCaptureFie
   let login = SpecialPowers.wrap(logins[0]).QueryInterface(Ci.nsILoginMetaInfo);
   is(login.username, "notifyu1", "Check the username unchanged");
   is(login.password, "notifyp1", "Check the password unchanged");
   is(login.timesUsed, 2, "Check times used incremented");
 
   Services.logins.removeAllLogins();
 });
 
+add_task(function* test_noShowPasswordOnDismissal() {
+  info("Check for no Show Password field when the doorhanger is dismissed");
+
+  yield testSubmittingLoginForm("subtst_notifications_1.html", function*(fieldValues) {
+    info("Opening popup");
+    let notif = getCaptureDoorhanger("password-save");
+    let { panel } = PopupNotifications;
+
+    info("Hiding popup.");
+    let promiseHidden = BrowserTestUtils.waitForEvent(panel, "popuphidden");
+    panel.hidePopup();
+    yield promiseHidden;
+
+    info("Clicking on anchor to reshow popup.")
+    let promiseShown = BrowserTestUtils.waitForEvent(panel, "popupshown");
+    notif.anchorElement.click();
+    yield promiseShown;
+
+    let passwordVisiblityToggle = panel.querySelector("#password-notification-visibilityToggle");
+    is(passwordVisiblityToggle.hidden, true, "Check that the Show Password field is Hidden");
+  });
+});
+
 // TODO:
 // * existing login test, form has different password --> change password, no save prompt