зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1155390 - Don't prompt to update a password when there is no username field and the password is identical. r=dolske
subtst_notifications_2pw_0un.html was updated so it could be re-used for case 27 and 28 with the existing test logins there. --HG-- extra : rebase_source : 70cdbab1fd4c6c5f0f67d744ea2c32be96e3a1f5
This commit is contained in:
Родитель
1ffb06aa28
Коммит
527bdf11de
|
@ -1,4 +1,3 @@
|
|||
/* vim: set ts=2 sts=2 sw=2 et tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
@ -408,6 +407,15 @@ var LoginManagerParent = {
|
|||
return prompterSvc;
|
||||
}
|
||||
|
||||
function recordLoginUse(login) {
|
||||
// Update the lastUsed timestamp and increment the use count.
|
||||
let propBag = Cc["@mozilla.org/hash-property-bag;1"].
|
||||
createInstance(Ci.nsIWritablePropertyBag);
|
||||
propBag.setProperty("timeLastUsed", Date.now());
|
||||
propBag.setProperty("timesUsedIncrement", 1);
|
||||
Services.logins.modifyLogin(login, propBag);
|
||||
}
|
||||
|
||||
if (!Services.logins.getLoginSavingEnabled(hostname)) {
|
||||
log("(form submission ignored -- saving is disabled for:", hostname, ")");
|
||||
return;
|
||||
|
@ -431,6 +439,14 @@ var LoginManagerParent = {
|
|||
|
||||
if (logins.length == 1) {
|
||||
var oldLogin = logins[0];
|
||||
|
||||
if (oldLogin.password == formLogin.password) {
|
||||
recordLoginUse(oldLogin);
|
||||
log("(Not prompting to save/change since we have no username and the " +
|
||||
"only saved password matches the new password)");
|
||||
return;
|
||||
}
|
||||
|
||||
formLogin.username = oldLogin.username;
|
||||
formLogin.usernameField = oldLogin.usernameField;
|
||||
|
||||
|
@ -481,12 +497,7 @@ var LoginManagerParent = {
|
|||
prompter = getPrompter();
|
||||
prompter.promptToChangePassword(existingLogin, formLogin);
|
||||
} else {
|
||||
// Update the lastUsed timestamp.
|
||||
var propBag = Cc["@mozilla.org/hash-property-bag;1"].
|
||||
createInstance(Ci.nsIWritablePropertyBag);
|
||||
propBag.setProperty("timeLastUsed", Date.now());
|
||||
propBag.setProperty("timesUsedIncrement", 1);
|
||||
Services.logins.modifyLogin(existingLogin, propBag);
|
||||
recordLoginUse(existingLogin);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<script>
|
||||
function submitForm() {
|
||||
pass.value = "notifyp2";
|
||||
pass.value = "notifyp1";
|
||||
form.submit();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ var subtests = [
|
|||
"subtst_notifications_2pw_0un.html", // 24
|
||||
"subtst_notifications_2pw_0un.html", // 25
|
||||
"subtst_notifications_2pw_0un.html", // 26
|
||||
"subtst_notifications_2pw_0un.html", // 27
|
||||
"subtst_notifications_2pw_0un.html", // 28
|
||||
];
|
||||
|
||||
|
||||
|
@ -147,7 +149,7 @@ function checkTest() {
|
|||
ok(!popup, "checking for no notification popup");
|
||||
|
||||
// Check to make sure we updated the timestamps and use count on the
|
||||
// existing loging that was submitted for this form.
|
||||
// existing login that was submitted for this form.
|
||||
var logins = pwmgr.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
ok(SpecialPowers.call_Instanceof(logins[0], Ci.nsILoginMetaInfo), "metainfo QI");
|
||||
|
@ -385,25 +387,25 @@ function checkTest() {
|
|||
// Check for notification popup when a form with 2 password fields (no username) is
|
||||
// submitted and there are no saved logins.
|
||||
is(gotUser, "null", "Checking submitted username");
|
||||
is(gotPass, "notifyp2", "Checking submitted password");
|
||||
is(gotPass, "notifyp1", "Checking submitted password");
|
||||
popup = getPopup(popupNotifications, "password-save");
|
||||
ok(popup, "got notification popup");
|
||||
popup.remove();
|
||||
|
||||
// Add login for the next test
|
||||
pwmgr.addLogin(login1);
|
||||
pwmgr.addLogin(login1B);
|
||||
break;
|
||||
|
||||
case 25:
|
||||
// Check for notification popup when a form with 2 password fields (no username) is
|
||||
// submitted and there is a saved login with a username and different password.
|
||||
is(gotUser, "null", "Checking submitted username");
|
||||
is(gotPass, "notifyp2", "Checking submitted password");
|
||||
is(gotPass, "notifyp1", "Checking submitted password");
|
||||
popup = getPopup(popupNotifications, "password-change");
|
||||
ok(popup, "got notification popup");
|
||||
popup.remove();
|
||||
// remove that login
|
||||
pwmgr.removeLogin(login1);
|
||||
pwmgr.removeLogin(login1B);
|
||||
|
||||
// Add login for the next test
|
||||
pwmgr.addLogin(login2B);
|
||||
|
@ -413,12 +415,61 @@ function checkTest() {
|
|||
// Check for notification popup when a form with 2 password fields (no username) is
|
||||
// submitted and there is a saved login with no username and a different password.
|
||||
is(gotUser, "null", "Checking submitted username");
|
||||
is(gotPass, "notifyp2", "Checking submitted password");
|
||||
is(gotPass, "notifyp1", "Checking submitted password");
|
||||
popup = getPopup(popupNotifications, "password-change");
|
||||
ok(popup, "got notification popup");
|
||||
popup.remove();
|
||||
// remove that login
|
||||
pwmgr.removeLogin(login2B);
|
||||
|
||||
// Add login for the next test
|
||||
pwmgr.addLogin(login1);
|
||||
|
||||
break;
|
||||
|
||||
case 27:
|
||||
// Check for no notification popup when a form with 2 password fields (no username) is
|
||||
// submitted and there is a saved login with a username and the same password.
|
||||
is(gotUser, "null", "Checking submitted username");
|
||||
is(gotPass, "notifyp1", "Checking submitted password");
|
||||
popup = getPopup(popupNotifications, "password-change");
|
||||
ok(!popup, "checking for no notification popup");
|
||||
|
||||
// Check to make sure we updated the timestamps and use count on the
|
||||
// existing login that was submitted for this form.
|
||||
var logins = pwmgr.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
ok(SpecialPowers.call_Instanceof(logins[0], Ci.nsILoginMetaInfo), "metainfo QI");
|
||||
is(logins[0].timesUsed, 2, "check .timesUsed for existing login submission");
|
||||
ok(logins[0].timeLastUsed > logins[0].timeCreated, "timeLastUsed bumped");
|
||||
ok(logins[0].timeCreated == logins[0].timePasswordChanged, "timeChanged not updated");
|
||||
|
||||
// remove that login
|
||||
pwmgr.removeLogin(login1);
|
||||
|
||||
// Add login for the next test
|
||||
pwmgr.addLogin(login2);
|
||||
break;
|
||||
|
||||
case 28:
|
||||
// Check for no notification popup when a form with 2 password fields (no username) is
|
||||
// submitted and there is a saved login with no username and the same password.
|
||||
is(gotUser, "null", "Checking submitted username");
|
||||
is(gotPass, "notifyp1", "Checking submitted password");
|
||||
popup = getPopup(popupNotifications, "password-change");
|
||||
ok(!popup, "checking for no notification popup");
|
||||
|
||||
// Check to make sure we updated the timestamps and use count on the
|
||||
// existing login that was submitted for this form.
|
||||
var logins = pwmgr.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
ok(SpecialPowers.call_Instanceof(logins[0], Ci.nsILoginMetaInfo), "metainfo QI");
|
||||
is(logins[0].timesUsed, 2, "check .timesUsed for existing login submission");
|
||||
ok(logins[0].timeLastUsed > logins[0].timeCreated, "timeLastUsed bumped");
|
||||
ok(logins[0].timeCreated == logins[0].timePasswordChanged, "timeChanged not updated");
|
||||
|
||||
// remove that login
|
||||
pwmgr.removeLogin(login2);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Загрузка…
Ссылка в новой задаче