Bug 1274042 - Fix checkbox for HTTP auth dialogs in e10s. r=Dolske a=lizzard
authorSaad Quadri <saad@saadquadri.com>
Fri, 12 Aug 2016 09:35:42 -0700
changeset 342421 fe76857ae374d0ee8a4def4cf28b5ac102de6fc2
parent 342420 29dd7d227b7b0168f62bf5819af36eef50e7199e
child 342422 0f76572d37ef02e35ba5b3001598ef19dfc21ce9
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDolske, lizzard
bugs1274042
milestone49.0
Bug 1274042 - Fix checkbox for HTTP auth dialogs in e10s. r=Dolske a=lizzard MozReview-Commit-ID: CuOBJ9m0DMW
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -506,16 +506,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();
@@ -546,18 +547,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");
     }
 
@@ -569,17 +570,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.");
@@ -596,25 +597,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);