[tbb-commits] [tor-browser/tor-browser-31.6.0esr-4.5-1] Bug 14716: HTTP Basic Authentication prompt only displayed once

mikeperry at torproject.org mikeperry at torproject.org
Tue Apr 21 01:01:18 UTC 2015


commit f0fe46bcec5946e94fd66792983b1f081913a74f
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Fri Apr 17 16:31:28 2015 -0400

    Bug 14716: HTTP Basic Authentication prompt only displayed once
    
    Modify the login manager implementation to handle the situation
    where storage is not available.
---
 toolkit/components/passwordmgr/nsLoginManager.js |   57 +++++++++++++++++++++-
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/toolkit/components/passwordmgr/nsLoginManager.js b/toolkit/components/passwordmgr/nsLoginManager.js
index a4cbdb0..19024fd 100644
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -243,6 +243,10 @@ LoginManager.prototype = {
         if (logins.some(function(l) login.matches(l, true)))
             throw "This login already exists.";
 
+        if (!this._storage) {
+            throw "No storage to add login";
+        }
+
         log("Adding login");
         return this._storage.addLogin(login);
     },
@@ -255,6 +259,12 @@ LoginManager.prototype = {
      */
     removeLogin : function (login) {
         log("Removing login");
+
+        if (!this._storage) {
+            log("No storage to remove login");
+            return null;
+        }
+
         return this._storage.removeLogin(login);
     },
 
@@ -266,6 +276,12 @@ LoginManager.prototype = {
      */
     modifyLogin : function (oldLogin, newLogin) {
         log("Modifying login");
+
+        if (!this._storage) {
+            log("No storage to modify login");
+            return null;
+        }
+
         return this._storage.modifyLogin(oldLogin, newLogin);
     },
 
@@ -281,6 +297,12 @@ LoginManager.prototype = {
      */
     getAllLogins : function (count) {
         log("Getting a list of all logins");
+
+        if (!this._storage) {
+            log("No storage to get all logins");
+            return null;
+        }
+
         return this._storage.getAllLogins(count);
     },
 
@@ -292,7 +314,10 @@ LoginManager.prototype = {
      */
     removeAllLogins : function () {
         log("Removing all logins");
-        this._storage.removeAllLogins();
+        if (!this._storage)
+            log("No storage to remove all logins");
+        else
+            this._storage.removeAllLogins();
     },
 
     /*
@@ -307,6 +332,12 @@ LoginManager.prototype = {
      */
     getAllDisabledHosts : function (count) {
         log("Getting a list of all disabled hosts");
+
+        if (!this._storage) {
+            log("No storage to get all disabled hosts");
+            return null;
+        }
+
         return this._storage.getAllDisabledHosts(count);
     },
 
@@ -320,6 +351,11 @@ LoginManager.prototype = {
         log("Searching for logins matching host:", hostname,
             "formSubmitURL:", formSubmitURL, "httpRealm:", httpRealm);
 
+        if (!this._storage) {
+            log("No storage to find logins");
+            return null;
+        }
+
         return this._storage.findLogins(count, hostname, formSubmitURL,
                                         httpRealm);
     },
@@ -336,6 +372,11 @@ LoginManager.prototype = {
     searchLogins : function(count, matchData) {
        log("Searching for logins");
 
+        if (!this._storage) {
+            log("No storage to search logins");
+            return null;
+        }
+
         return this._storage.searchLogins(count, matchData);
     },
 
@@ -350,6 +391,9 @@ LoginManager.prototype = {
         log("Counting logins matching host:", hostname,
             "formSubmitURL:", formSubmitURL, "httpRealm:", httpRealm);
 
+        if (!this._storage)
+            return 0;
+
         return this._storage.countLogins(hostname, formSubmitURL, httpRealm);
     },
 
@@ -358,6 +402,9 @@ LoginManager.prototype = {
      * uiBusy
      */
     get uiBusy() {
+        if (!this._storage)
+            return false;
+
         return this._storage.uiBusy;
     },
 
@@ -366,6 +413,9 @@ LoginManager.prototype = {
      * isLoggedIn
      */
     get isLoggedIn() {
+        if (!this._storage)
+            return false;
+
         return this._storage.isLoggedIn;
     },
 
@@ -377,7 +427,7 @@ LoginManager.prototype = {
      */
     getLoginSavingEnabled : function (host) {
         log("Checking if logins to", host, "can be saved.");
-        if (!this._remember)
+        if (!this._remember || !this._storage)
             return false;
 
         return this._storage.getLoginSavingEnabled(host);
@@ -394,6 +444,9 @@ LoginManager.prototype = {
         if (hostname.indexOf("\0") != -1)
             throw "Invalid hostname";
 
+        if (!this._storage)
+            throw "No storage to set login saving enabled";
+
         log("Login saving for", hostname, "now enabled?", enabled);
         return this._storage.setLoginSavingEnabled(hostname, enabled);
     },



More information about the tbb-commits mailing list