зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1551730
- Don't autofill passwords when hasBeenTypePassword but type!=password. r=sfoster
Differential Revision: https://phabricator.services.mozilla.com/D68325 --HG-- rename : toolkit/components/passwordmgr/test/mochitest/test_autocomplete_highlight.html => toolkit/components/passwordmgr/test/mochitest/test_autofill_hasBeenTypePassword.html extra : moz-landing-system : lando
This commit is contained in:
Родитель
327ceb732f
Коммит
fda04262f5
|
@ -1848,6 +1848,7 @@ this.LoginManagerChild = class LoginManagerChild extends JSWindowActorChild {
|
|||
AUTOCOMPLETE_OFF: 9,
|
||||
INSECURE: 10,
|
||||
PASSWORD_AUTOCOMPLETE_NEW_PASSWORD: 11,
|
||||
TYPE_NO_LONGER_PASSWORD: 12,
|
||||
};
|
||||
|
||||
// Heuristically determine what the user/pass fields are
|
||||
|
@ -1972,6 +1973,14 @@ this.LoginManagerChild = class LoginManagerChild extends JSWindowActorChild {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!userTriggered && passwordField.type != "password") {
|
||||
// We don't want to autofill (without user interaction) into a field
|
||||
// that's unmasked.
|
||||
log("not autofilling, password field isn't currently type=password");
|
||||
autofillResult = AUTOFILL_RESULT.TYPE_NO_LONGER_PASSWORD;
|
||||
return;
|
||||
}
|
||||
|
||||
const passwordACFieldName = passwordField.getAutocompleteInfo().fieldName;
|
||||
|
||||
// If the password field has the autocomplete value of "new-password"
|
||||
|
|
|
@ -77,6 +77,8 @@ skip-if = toolkit == 'android' # Bug 1259768
|
|||
fail-if = fission
|
||||
scheme = https
|
||||
skip-if = toolkit == 'android' # bug 1527403
|
||||
[test_autofill_hasBeenTypePassword.html]
|
||||
scheme = https
|
||||
[test_autofill_highlight.html]
|
||||
scheme = https
|
||||
skip-if = toolkit == 'android' # Bug 1531185
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test no autofill into a password field that is no longer type=password</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="pwmgr_common.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
Login Manager test: Test no autofill into a password field that is no longer type=password
|
||||
|
||||
<script>
|
||||
let readyPromise = registerRunTests();
|
||||
|
||||
runInParent(function initLogins() {
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
let login1 = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(Ci.nsILoginInfo);
|
||||
login1.init("https://example.com", "https://autofill", null, "user1", "pass1");
|
||||
Services.logins.addLogin(login1);
|
||||
});
|
||||
|
||||
/** Test for Login Manager: Test no autofill into a password field that is no longer type=password **/
|
||||
|
||||
add_task(async function setup() {
|
||||
ok(readyPromise, "check promise is available");
|
||||
await readyPromise;
|
||||
});
|
||||
|
||||
|
||||
// As a control, test that autofill is working on this page.
|
||||
add_task(async function test_autofill_control() {
|
||||
let formProcessedPromise = promiseFormsProcessed();
|
||||
// eslint-disable-next-line no-unsanitized/property
|
||||
document.querySelector("#content").innerHTML = `
|
||||
<form id="form1" action="https://autofill">
|
||||
<p>This is form 1.</p>
|
||||
<input type="text" name="uname">
|
||||
<input type="password" name="pword">
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>`;
|
||||
await formProcessedPromise;
|
||||
checkLoginForm($_(1, "uname"), "user1", $_(1, "pword"), "pass1");
|
||||
});
|
||||
|
||||
add_task(async function test_no_autofill() {
|
||||
let formProcessedPromise = promiseFormsProcessed();
|
||||
// eslint-disable-next-line no-unsanitized/property
|
||||
document.querySelector("#content").innerHTML = `
|
||||
<form id="form1" action="https://autofill">
|
||||
<p>This is form 1.</p>
|
||||
<input type="text" name="uname">
|
||||
<input type="password" name="pword">
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>`;
|
||||
// Synchronously change the password field type to text before the fill happens.
|
||||
$_(1, "pword").type = "text";
|
||||
await formProcessedPromise;
|
||||
checkLoginForm($_(1, "uname"), "", $_(1, "pword"), "");
|
||||
});
|
||||
</script>
|
||||
|
||||
<p id="display"></p>
|
||||
|
||||
<div id="content"></div>
|
||||
|
||||
<pre id="test"></pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче