Bug 1274042 - Fix checkbox for HTTP auth dialogs in e10s. r=Dolske draft
authorSaad Quadri <saad@saadquadri.com>
Fri, 12 Aug 2016 09:35:42 -0700
changeset 400038 68f876db2221b7962efe3d3d719997aeed7fc650
parent 399190 2f24daceada71e15c03b5f90765264c720ed035a
child 400039 72dd4d72458439e0f4f370f4494f2172a96bfac1
push id26076
push usersaad@saadquadri.com
push dateFri, 12 Aug 2016 16:46:31 +0000
reviewersDolske
bugs1274042
milestone51.0a1
Bug 1274042 - Fix checkbox for HTTP auth dialogs in e10s. r=Dolske MozReview-Commit-ID: CuOBJ9m0DMW
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -505,16 +505,17 @@ LoginManagerPrompter.prototype = {
    * @param {nsIAuthInformation} aAuthInfo
    */
   promptAuth : function (aChannel, aLevel, aAuthInfo) {
     var selectedLogin = null;
     var checkbox = { value : false };
     var checkboxLabel = null;
     var epicfail = false;
     var canAutologin = false;
+    var notifyObj;
 
     try {
       this.log("===== promptAuth called =====");
 
       // If the user submits a login but it fails, we need to remove the
       // notification bar that was displayed. Conveniently, the user will
       // be prompted for authentication again, which brings us here.
       this._removeLoginNotifications();
@@ -545,18 +546,18 @@ LoginManagerPrompter.prototype = {
         checkbox.value = true;
       }
 
       var canRememberLogin = this._pwmgr.getLoginSavingEnabled(hostname);
       if (this._inPrivateBrowsing)
         canRememberLogin = false;
 
       // if checkboxLabel is null, the checkbox won't be shown at all.
-      var notifyBox = this._getNotifyBox();
-      if (canRememberLogin && !notifyBox)
+      notifyObj = this._getPopupNote() || this._getNotifyBox();
+      if (canRememberLogin && !notifyObj)
         checkboxLabel = this._getLocalizedString("rememberPassword");
     } catch (e) {
       // Ignore any errors and display the prompt anyway.
       epicfail = true;
       Components.utils.reportError("LoginManagerPrompter: " +
           "Epic fail in promptAuth: " + e + "\n");
     }
 
@@ -568,17 +569,17 @@ LoginManagerPrompter.prototype = {
                                           aChannel, aLevel, aAuthInfo,
                                           checkboxLabel, checkbox);
     }
 
     // If there's a notification box, use it to allow the user to
     // determine if the login should be saved. If there isn't a
     // notification box, only save the login if the user set the
     // checkbox to do so.
-    var rememberLogin = notifyBox ? canRememberLogin : checkbox.value;
+    var rememberLogin = notifyObj ? canRememberLogin : checkbox.value;
     if (!ok || !rememberLogin || epicfail)
       return ok;
 
     try {
       var [username, password] = this._GetAuthInfo(aAuthInfo);
 
       if (!password) {
         this.log("No password entered, so won't offer to save.");
@@ -595,25 +596,23 @@ LoginManagerPrompter.prototype = {
       let newLogin = Cc["@mozilla.org/login-manager/loginInfo;1"].
                      createInstance(Ci.nsILoginInfo);
       newLogin.init(hostname, null, httpRealm,
                     username, password, "", "");
       if (!selectedLogin) {
         this.log("New login seen for " + username +
                  " @ " + hostname + " (" + httpRealm + ")");
 
-        let notifyObj = this._getPopupNote() || notifyBox;
         if (notifyObj)
           this._showSaveLoginNotification(notifyObj, newLogin);
         else
           this._pwmgr.addLogin(newLogin);
       } else if (password != selectedLogin.password) {
         this.log("Updating password for " + username +
                  " @ " + hostname + " (" + httpRealm + ")");
-        let notifyObj = this._getPopupNote() || notifyBox;
         if (notifyObj)
           this._showChangeLoginNotification(notifyObj,
                                             selectedLogin, newLogin);
         else
           this._updateLogin(selectedLogin, newLogin);
       } else {
         this.log("Login unchanged, no further action needed.");
         this._updateLogin(selectedLogin);