зеркало из https://github.com/mozilla/pjs.git
Bug 410042 - Clear Private Data can trigger master password prompt. r=gavin, a1.9=mconnor
This commit is contained in:
Родитель
9793d7f27f
Коммит
fe251f41fd
|
@ -210,8 +210,8 @@ Sanitizer.prototype = {
|
|||
{
|
||||
var pwmgr = Components.classes["@mozilla.org/login-manager;1"]
|
||||
.getService(Components.interfaces.nsILoginManager);
|
||||
var logins = pwmgr.getAllLogins({});
|
||||
return (logins.length > 0);
|
||||
var count = pwmgr.countLogins("", "", ""); // count all logins
|
||||
return (count > 0);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -210,8 +210,8 @@ Sanitizer.prototype = {
|
|||
{
|
||||
var pwmgr = Components.classes["@mozilla.org/login-manager;1"]
|
||||
.getService(Components.interfaces.nsILoginManager);
|
||||
var logins = pwmgr.getAllLogins({});
|
||||
return (logins.length > 0);
|
||||
var count = pwmgr.countLogins("", "", ""); // count all logins
|
||||
return (count > 0);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -185,7 +185,9 @@ interface nsILoginManager : nsISupports {
|
|||
* password to decrypt the logins.
|
||||
*
|
||||
* @param aHostname
|
||||
* The hostname to restrict searches to.
|
||||
* The hostname to restrict searches to. Specify an empty string
|
||||
* to match all hosts. A null value will not match any logins, and
|
||||
* will thus always return a count of 0.
|
||||
* @param aActionURL
|
||||
* The URL to which a form login will be submitted. To match any
|
||||
* form login, specify an empty string. To not match any form
|
||||
|
|
|
@ -209,7 +209,9 @@ interface nsILoginManagerStorage : nsISupports {
|
|||
* password to decrypt the logins.
|
||||
*
|
||||
* @param aHostname
|
||||
* The hostname to restrict searches to.
|
||||
* The hostname to restrict searches to. Specify an empty string
|
||||
* to match all hosts. A null value will not match any logins, and
|
||||
* will thus always return a count of 0.
|
||||
* @param aActionURL
|
||||
* The URL to which a form login will be submitted. To match any
|
||||
* form login, specify an empty string. To not match any form
|
||||
|
|
|
@ -377,10 +377,27 @@ LoginManagerStorage_legacy.prototype = {
|
|||
* countLogins
|
||||
*
|
||||
*/
|
||||
countLogins : function (hostname, formSubmitURL, httpRealm) {
|
||||
var logins = this._searchLogins(hostname, formSubmitURL, httpRealm);
|
||||
countLogins : function (aHostname, aFormSubmitURL, aHttpRealm) {
|
||||
var logins;
|
||||
|
||||
return logins.length;
|
||||
// Normal case: return direct results for the specified host.
|
||||
if (aHostname) {
|
||||
logins = this._searchLogins(aHostname, aFormSubmitURL, aHttpRealm);
|
||||
return logins.length
|
||||
}
|
||||
|
||||
// For consistency with how aFormSubmitURL and aHttpRealm work
|
||||
if (aHostname == null)
|
||||
return 0;
|
||||
|
||||
// aHostname == "", so loop through each known host to match with each.
|
||||
var count = 0;
|
||||
for (var hostname in this._logins) {
|
||||
logins = this._searchLogins(hostname, aFormSubmitURL, aHttpRealm);
|
||||
count += logins.length;
|
||||
}
|
||||
|
||||
return count;
|
||||
},
|
||||
|
||||
|
||||
|
|
|
@ -120,6 +120,15 @@ do_check_eq(1, storage.countLogins("http://dummyhost.mozilla.org", "foo", null))
|
|||
do_check_eq(0, storage.countLogins("http://dummyhost.mozilla.org", null, ""));
|
||||
// counting logins (don't match a bogus hostname)
|
||||
do_check_eq(0, storage.countLogins("blah", "", ""));
|
||||
// counting all logins (empty hostname)
|
||||
do_check_eq(1, storage.countLogins("", "", null));
|
||||
// counting all logins (empty hostname)
|
||||
do_check_eq(1, storage.countLogins("", "foo", null));
|
||||
// counting no logins (null hostname)
|
||||
do_check_eq(0, storage.countLogins(null, "", null));
|
||||
do_check_eq(0, storage.countLogins(null, null, ""));
|
||||
do_check_eq(0, storage.countLogins(null, "", ""));
|
||||
do_check_eq(0, storage.countLogins(null, null, null));
|
||||
|
||||
|
||||
/* ========== 9 ========== */
|
||||
|
@ -180,6 +189,17 @@ do_check_eq(0, storage.countLogins("http://dummyhost.site.org", null, ""));
|
|||
do_check_eq(1, storage.countLogins("http://dummyhost-1.site.org", "", ""));
|
||||
do_check_eq(1, storage.countLogins("http://dummyhost-1.site.org", "", null));
|
||||
do_check_eq(0, storage.countLogins("http://dummyhost-1.site.org", null, ""));
|
||||
// counting logins for all hosts
|
||||
do_check_eq(500, storage.countLogins("", "", ""));
|
||||
do_check_eq(500, storage.countLogins("", "http://cgi.site.org", ""));
|
||||
do_check_eq(500, storage.countLogins("", "http://cgi.site.org", null));
|
||||
do_check_eq(0, storage.countLogins("", "blah", ""));
|
||||
do_check_eq(0, storage.countLogins("", "", "blah"));
|
||||
// counting logins for no hosts
|
||||
do_check_eq(0, storage.countLogins(null, "", ""));
|
||||
do_check_eq(0, storage.countLogins(null, "http://cgi.site.org", ""));
|
||||
do_check_eq(0, storage.countLogins(null, "http://cgi.site.org", null));
|
||||
do_check_eq(0, storage.countLogins(null, null, null));
|
||||
|
||||
|
||||
/* ========== 12 ========== */
|
||||
|
|
Загрузка…
Ссылка в новой задаче