Bug 1178855 - Hide password visibility toggle when capture doorhanger is closed. r=MattN
MozReview-Commit-ID: 75Pz7jG0RLW
--- 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