зеркало из https://github.com/mozilla/gecko-dev.git
Bug 583578 - Auto-fill password fields even if the username field is disabled or read-only. r=dolske
This commit is contained in:
Родитель
c3deaa87e3
Коммит
c5396f4401
|
@ -594,11 +594,9 @@ var LoginManagerContent = {
|
||||||
if (passwordField == null)
|
if (passwordField == null)
|
||||||
return [false, foundLogins];
|
return [false, foundLogins];
|
||||||
|
|
||||||
// If the fields are disabled or read-only, there's nothing to do.
|
// If the password field is disabled or read-only, there's nothing to do.
|
||||||
if (passwordField.disabled || passwordField.readOnly ||
|
if (passwordField.disabled || passwordField.readOnly) {
|
||||||
usernameField && (usernameField.disabled ||
|
log("not filling form, password field disabled or read-only");
|
||||||
usernameField.readOnly)) {
|
|
||||||
log("not filling form, login fields disabled");
|
|
||||||
return [false, foundLogins];
|
return [false, foundLogins];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,8 +676,8 @@ var LoginManagerContent = {
|
||||||
// should be firing notifications if and only if we can fill the form.
|
// should be firing notifications if and only if we can fill the form.
|
||||||
var selectedLogin = null;
|
var selectedLogin = null;
|
||||||
|
|
||||||
if (usernameField && usernameField.value) {
|
if (usernameField && (usernameField.value || usernameField.disabled || usernameField.readOnly)) {
|
||||||
// If username was specified in the form, only fill in the
|
// If username was specified in the field, it's disabled or it's readOnly, only fill in the
|
||||||
// password if we find a matching login.
|
// password if we find a matching login.
|
||||||
var username = usernameField.value.toLowerCase();
|
var username = usernameField.value.toLowerCase();
|
||||||
|
|
||||||
|
@ -714,7 +712,8 @@ var LoginManagerContent = {
|
||||||
var didFillForm = false;
|
var didFillForm = false;
|
||||||
if (selectedLogin && autofillForm && !isFormDisabled) {
|
if (selectedLogin && autofillForm && !isFormDisabled) {
|
||||||
// Fill the form
|
// Fill the form
|
||||||
if (usernameField)
|
// Don't modify the username field if it's disabled or readOnly so we preserve its case.
|
||||||
|
if (usernameField && !(usernameField.disabled || usernameField.readOnly))
|
||||||
usernameField.value = selectedLogin.username;
|
usernameField.value = selectedLogin.username;
|
||||||
passwordField.value = selectedLogin.password;
|
passwordField.value = selectedLogin.password;
|
||||||
didFillForm = true;
|
didFillForm = true;
|
||||||
|
|
|
@ -63,6 +63,18 @@ Login Manager test: forms with 1 password field, part 2
|
||||||
<button type='submit'>Submit</button>
|
<button type='submit'>Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<form id='form10' action='formtest.js'> 10
|
||||||
|
<input type='text' name='uname' value='TESTUSER' readonly>
|
||||||
|
<input type='password' name='pname' value=''>
|
||||||
|
<button type='submit'>Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form id='form11' action='formtest.js'> 11
|
||||||
|
<input type='text' name='uname' value='TESTUSER' disabled>
|
||||||
|
<input type='password' name='pname' value=''>
|
||||||
|
<button type='submit'>Submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
|
@ -83,6 +95,8 @@ function startTest() {
|
||||||
for (f = 5; f <= 8; f++) { checkUnmodifiedForm(f); }
|
for (f = 5; f <= 8; f++) { checkUnmodifiedForm(f); }
|
||||||
// Test case-insensitive comparison of username field
|
// Test case-insensitive comparison of username field
|
||||||
checkForm(9, "testuser", "testpass");
|
checkForm(9, "testuser", "testpass");
|
||||||
|
checkForm(10, "TESTUSER", "testpass");
|
||||||
|
checkForm(11, "TESTUSER", "testpass");
|
||||||
|
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче