Commit 9c5823d6 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Do not skip password forms with multiple inputs with the same name.

Atm in case when Password Manager tries to fill a password form
and encounters inputs with the same names it stops processing such form.
This CL implements that the first field will be filled.

Bug: 803215
Change-Id: Ia1ec0f1de8390c59308e8c70cbaebe285ae7431d
Reviewed-on: https://chromium-review.googlesource.com/886707
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533271}
parent b1b678fa
......@@ -2730,6 +2730,14 @@ TEST_F(PasswordAutofillAgentTest,
" <INPUT type='submit' />"
"</FORM>";
const char kFormWithMultipleAnonymousTextFields[] =
"<FORM action='http://www.bidule.com'>"
"<INPUT type='text' placeholder='username'/>"
"<INPUT type='password' placeholder='password'/>"
"<INPUT type='text' placeholder='captcha'/>"
"<INPUT type='text' placeholder='fakefield'/>"
"</FORM>";
const struct {
const char* html_form;
bool is_possible_change_password_form;
......@@ -2776,6 +2784,10 @@ TEST_F(PasswordAutofillAgentTest,
{kChangePasswordFormButNoAutocompleteAttribute, true, true,
kDummyUsernameField, kDummyPasswordField, kAliceUsername, kAlicePassword,
true, true},
// Sign-in form with multiple anonymous text fields.
{kFormWithMultipleAnonymousTextFields, false, true, kDummyUsernameField,
kDummyPasswordField, kAliceUsername, kAlicePassword, true, true},
};
for (const auto& test_case : test_cases) {
......
......@@ -176,24 +176,21 @@ bool FindFormInputElement(
continue;
}
// Check for a non-unique match.
if (found_input) {
// For change password form keep only the first password field entry.
if (does_password_field_has_ambigous_or_empty_name) {
if (ambiguous_or_empty_names) {
// In case of ambigous or empty names, there might be multiple
// appropriate inputs. Check if the current input is better than
// previously found one.
if (!form_util::IsWebElementVisible((*result)[field_name])) {
// If a previously chosen field was invisible then take the current
// one.
(*result)[field_name] = input_element;
}
continue;
}
found_input = false;
break;
} else {
(*result)[field_name] = input_element;
found_input = true;
}
(*result)[field_name] = input_element;
found_input = true;
}
// A required element was not found. This is not the right form.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment