зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1852745 - modernize test_autocomplete_hasBeenTypePassword.html - r=credential-management-reviewers,dimi
Differential Revision: https://phabricator.services.mozilla.com/D190593
This commit is contained in:
Родитель
c55d0f391a
Коммит
80bb9c6927
|
@ -10,59 +10,49 @@
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Login Manager test: Test that passwords are autocompleted into fields that were previously type=password
|
|
||||||
<p id="display"></p>
|
<p id="display"></p>
|
||||||
|
|
||||||
<!-- we presumably can't hide the content for this test. -->
|
|
||||||
<div id="content"></div>
|
<div id="content"></div>
|
||||||
<pre id="test">
|
<pre id="test">
|
||||||
|
Login Manager test: Test that passwords are autocompleted into fields that were
|
||||||
|
previously type=password
|
||||||
|
|
||||||
|
Usually the autocomplete login form only operates on password fields which are
|
||||||
|
of type `password`. But when a password fields type has been changed to `text`
|
||||||
|
via JavaScript, the password manager should still fill this form, because this
|
||||||
|
is often used in real world forms to handle masking/unmasking of password
|
||||||
|
fields.
|
||||||
|
|
||||||
|
<template id="form1-template">
|
||||||
|
<form id="form1" action="https://www.example.com/formtest.js">
|
||||||
|
<input type="text" name="uname">
|
||||||
|
<input type="password" name="pword">
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
<script class="testbody" type="text/javascript">
|
<script class="testbody" type="text/javascript">
|
||||||
|
const formTemplate = document.getElementById("form1-template");
|
||||||
|
|
||||||
// Restore the form to the default state.
|
add_setup(async () => {
|
||||||
function restoreForm(form) {
|
|
||||||
form.uname.value = "";
|
|
||||||
form.pword.value = "";
|
|
||||||
form.uname.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
function spinEventLoop() {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_setup(async () => {
|
|
||||||
const origin = window.location.origin;
|
const origin = window.location.origin;
|
||||||
await setStoredLoginsAsync(
|
await setStoredLoginsDuringTest(
|
||||||
[origin, origin, null, "user1", "pass1"],
|
[origin, origin, null, "user1", "pass1"],
|
||||||
[origin, origin, null, "user2", "pass2"]
|
[origin, origin, null, "user2", "pass2"]
|
||||||
);
|
);
|
||||||
listenForUnexpectedPopupShown();
|
listenForUnexpectedPopupShown();
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_form1_initial_empty() {
|
|
||||||
const form = createLoginForm({
|
|
||||||
action: "https://www.example.com/formtest.js"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await SimpleTest.promiseFocus(window);
|
add_named_task("autofill operates on a password field made text", async () => {
|
||||||
|
const form = setContentForTask(formTemplate);
|
||||||
|
|
||||||
// Make sure initial form is empty.
|
// initial consume autofill event
|
||||||
checkLoginForm(form.uname, "", form.pword, "");
|
await formAutofillResult(form.id);
|
||||||
const popupState = await getPopupState();
|
|
||||||
is(popupState.open, false, "Check popup is initially closed");
|
|
||||||
});
|
|
||||||
|
|
||||||
add_task(async function test_form1_password_to_type_text() {
|
|
||||||
const form = createLoginForm({
|
|
||||||
action: "https://www.example.com/formtest.js"
|
|
||||||
});
|
|
||||||
|
|
||||||
await SimpleTest.promiseFocus(window);
|
|
||||||
info("Setting the password field type to text");
|
info("Setting the password field type to text");
|
||||||
// This is similar to a site implementing their own password visibility/unmasking toggle
|
// This is similar to a site implementing their own password visibility/unmasking toggle
|
||||||
form.pword.type = "text";
|
form.pword.type = "text";
|
||||||
|
|
||||||
// Trigger autocomplete popup
|
// Trigger autocomplete popup
|
||||||
restoreForm(form);
|
form.uname.focus();
|
||||||
const autocompleteItems = await popupByArrowDown();
|
const autocompleteItems = await popupByArrowDown();
|
||||||
|
|
||||||
const popupState = await getPopupState();
|
const popupState = await getPopupState();
|
||||||
|
@ -72,29 +62,31 @@ add_task(async function test_form1_password_to_type_text() {
|
||||||
"Check all menuitems are displayed correctly.");
|
"Check all menuitems are displayed correctly.");
|
||||||
|
|
||||||
synthesizeKey("KEY_ArrowDown"); // first item
|
synthesizeKey("KEY_ArrowDown"); // first item
|
||||||
checkLoginForm(form.uname, "", form.pword, ""); // value shouldn't update just by selecting
|
// value shouldn't update just by selecting
|
||||||
|
is(form.uname.value, "", "username is empty");
|
||||||
|
is(form.pword.value, "", "password is empty");
|
||||||
|
|
||||||
synthesizeKey("KEY_Enter");
|
synthesizeKey("KEY_Enter");
|
||||||
|
|
||||||
await promiseFormsProcessedInSameProcess();
|
const autofillResult1 = await formAutofillResult(form.id);
|
||||||
is(form.uname.value, "user1", "username should match the login, not the password");
|
is(autofillResult1, "filled", "form has been filled");
|
||||||
is(form.pword.value, "pass1", "password should match the login, not the username");
|
|
||||||
checkLoginForm(form.uname, "user1", form.pword, "pass1");
|
is(form.uname.value, "user1", "username should match the login");
|
||||||
|
is(form.pword.value, "pass1", "password should match the login");
|
||||||
|
|
||||||
|
form.reset();
|
||||||
|
|
||||||
restoreForm(form);
|
|
||||||
info("Focusing the password field");
|
|
||||||
form.pword.focus();
|
form.pword.focus();
|
||||||
|
|
||||||
await popupByArrowDown();
|
await popupByArrowDown();
|
||||||
|
|
||||||
synthesizeKey("KEY_ArrowDown"); // first item
|
synthesizeKey("KEY_ArrowDown"); // first item
|
||||||
checkLoginForm(form.uname, "", form.pword, ""); // value shouldn't update just by selecting
|
// value shouldn't update just by selecting
|
||||||
|
is(form.uname.value, "", "username is empty");
|
||||||
|
is(form.pword.value, "", "password is empty");
|
||||||
|
|
||||||
synthesizeKey("KEY_Enter");
|
synthesizeKey("KEY_Enter");
|
||||||
await spinEventLoop();
|
is(form.uname.value, "", "username should stay empty");
|
||||||
is(form.pword.value, "pass1", "Password should match the login that was selected");
|
is(form.pword.value, "pass1", "Password should match the login that was selected");
|
||||||
checkLoginForm(form.uname, "", form.pword, "pass1");
|
});
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</pre>
|
</pre>
|
||||||
</body>
|
</body>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче