Commit 017745bc authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

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

This reverts of https://chromium-review.googlesource.com/c/chromium/src/+/886707.

The reason: it breaks Password Manager on almost any sites where
there are simultaneously fields with ids and without ids. Fixing this properly is
too difficult and risky for merging. And anyway processing of fields with empty
ids will be much improved in https://crbug.com/831123

Bug: 839376, 803215

Change-Id: I91b535161335844266b0559b0ac21ecaf27faddc
Reviewed-on: https://chromium-review.googlesource.com/1049926
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556791}
parent dd6696e0
......@@ -2836,14 +2836,6 @@ 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;
......@@ -2890,10 +2882,6 @@ 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) {
......
......@@ -236,21 +236,24 @@ bool FindFormInputElement(
continue;
}
// Check for a non-unique match.
if (found_input) {
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.
// For change password form keep only the first password field entry.
if (does_password_field_has_ambigous_or_empty_name) {
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;
}
} else {
(*result)[field_name] = input_element;
found_input = true;
found_input = false;
break;
}
(*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