[tbb-commits] [tor-browser/tor-browser-38.2.1esr-5.5-2] fixup! Bug 14716: HTTP Basic Authentication prompt only displayed once
gk at torproject.org
gk at torproject.org
Mon Aug 31 10:44:20 UTC 2015
commit 313e32cf752756d9c64e05058342cdda84d550e7
Author: Kathy Brade <brade at pearlcrescent.com>
Date: Wed Aug 19 13:51:11 2015 -0400
fixup! Bug 14716: HTTP Basic Authentication prompt only displayed once
Account for ESR38 login manager changes: skip storage initialization
if security.nocertdb = true and set _storage to null upon failure.
Fixes #16842.
---
toolkit/components/passwordmgr/nsLoginManager.js | 104 +++++++++++++---------
1 file changed, 60 insertions(+), 44 deletions(-)
diff --git a/toolkit/components/passwordmgr/nsLoginManager.js b/toolkit/components/passwordmgr/nsLoginManager.js
index f2b77ac..9648f8f 100644
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -153,9 +153,25 @@ LoginManager.prototype = {
log("No alternate nsILoginManagerStorage registered");
}
- this._storage = Cc[contractID].
- createInstance(Ci.nsILoginManagerStorage);
- this.initializationPromise = this._storage.initialize();
+ // If the security.nocertdb pref. is true, we skip initialization of
+ // login manager storage since we know it will fail. In this case we
+ // pretend that initialization succeeded in order to avoid a cascade of
+ // initialization errors.
+ if (Services.prefs.getBoolPref("security.nocertdb")) {
+ this._storage = null;
+ this.initializationPromise = Promise.resolve();
+ } else {
+ this._storage = Cc[contractID].
+ createInstance(Ci.nsILoginManagerStorage);
+ try {
+ this.initializationPromise = this._storage.initialize();
+ } catch (e) {
+ // If storage is not available, set _storage to null so that we can
+ // cleanly check for a lack of storage elsewhere in this file.
+ this._storage = null;
+ this.initializationPromise = Promise.reject(e);
+ }
+ }
},
@@ -196,7 +212,8 @@ LoginManager.prototype = {
this._pwmgr = null;
} else if (topic == "passwordmgr-storage-replace") {
Task.spawn(function () {
- yield this._pwmgr._storage.terminate();
+ if (this._pwmgr._storage)
+ yield this._pwmgr._storage.terminate();
this._pwmgr._initStorage();
yield this._pwmgr.initializationPromise;
Services.obs.notifyObservers(null,
@@ -331,9 +348,8 @@ 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";
- }
+ if (!this._storage)
+ throw "No storage to add login";
log("Adding login");
return this._storage.addLogin(login);
@@ -348,10 +364,10 @@ LoginManager.prototype = {
removeLogin : function (login) {
log("Removing login");
- if (!this._storage) {
- log("No storage to remove login");
- return null;
- }
+ if (!this._storage) {
+ log("No storage to remove login");
+ return null;
+ }
return this._storage.removeLogin(login);
},
@@ -365,10 +381,10 @@ LoginManager.prototype = {
modifyLogin : function (oldLogin, newLogin) {
log("Modifying login");
- if (!this._storage) {
- log("No storage to modify login");
- return null;
- }
+ if (!this._storage) {
+ log("No storage to modify login");
+ return null;
+ }
return this._storage.modifyLogin(oldLogin, newLogin);
},
@@ -386,10 +402,10 @@ LoginManager.prototype = {
getAllLogins : function (count) {
log("Getting a list of all logins");
- if (!this._storage) {
- log("No storage to get all logins");
- return null;
- }
+ if (!this._storage) {
+ log("No storage to get all logins");
+ return null;
+ }
return this._storage.getAllLogins(count);
},
@@ -402,10 +418,10 @@ LoginManager.prototype = {
*/
removeAllLogins : function () {
log("Removing all logins");
- if (!this._storage)
- log("No storage to remove all logins");
- else
- this._storage.removeAllLogins();
+ if (!this._storage)
+ log("No storage to remove all logins");
+ else
+ this._storage.removeAllLogins();
},
/*
@@ -421,10 +437,10 @@ 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;
- }
+ if (!this._storage) {
+ log("No storage to get all disabled hosts");
+ return null;
+ }
return this._storage.getAllDisabledHosts(count);
},
@@ -439,10 +455,10 @@ LoginManager.prototype = {
log("Searching for logins matching host:", hostname,
"formSubmitURL:", formSubmitURL, "httpRealm:", httpRealm);
- if (!this._storage) {
- log("No storage to find logins");
- return null;
- }
+ if (!this._storage) {
+ log("No storage to find logins");
+ return null;
+ }
return this._storage.findLogins(count, hostname, formSubmitURL,
httpRealm);
@@ -460,10 +476,10 @@ LoginManager.prototype = {
searchLogins : function(count, matchData) {
log("Searching for logins");
- if (!this._storage) {
- log("No storage to search logins");
- return null;
- }
+ if (!this._storage) {
+ log("No storage to search logins");
+ return null;
+ }
return this._storage.searchLogins(count, matchData);
},
@@ -479,8 +495,8 @@ LoginManager.prototype = {
log("Counting logins matching host:", hostname,
"formSubmitURL:", formSubmitURL, "httpRealm:", httpRealm);
- if (!this._storage)
- return 0;
+ if (!this._storage)
+ return 0;
return this._storage.countLogins(hostname, formSubmitURL, httpRealm);
},
@@ -490,8 +506,8 @@ LoginManager.prototype = {
* uiBusy
*/
get uiBusy() {
- if (!this._storage)
- return false;
+ if (!this._storage)
+ return false;
return this._storage.uiBusy;
},
@@ -501,8 +517,8 @@ LoginManager.prototype = {
* isLoggedIn
*/
get isLoggedIn() {
- if (!this._storage)
- return false;
+ if (!this._storage)
+ return false;
return this._storage.isLoggedIn;
},
@@ -515,7 +531,7 @@ LoginManager.prototype = {
*/
getLoginSavingEnabled : function (host) {
log("Checking if logins to", host, "can be saved.");
- if (!this._remember || !this._storage)
+ if (!this._remember || !this._storage)
return false;
return this._storage.getLoginSavingEnabled(host);
@@ -532,8 +548,8 @@ LoginManager.prototype = {
if (hostname.indexOf("\0") != -1)
throw "Invalid hostname";
- if (!this._storage)
- throw "No storage to set login saving enabled";
+ 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