Commit aec8ae48 authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

[FormParser] |NOT_PASSWORD| prediction is honored despite

autofill_attribute=*password.

Change-Id: I98c70ff7cc4f3f64777a1e46a67c5491d4fe3f4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1712679Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Commit-Queue: Matthias Körber <koerber@google.com>
Cr-Commit-Position: refs/heads/master@{#680348}
parent 439ef651
...@@ -390,17 +390,18 @@ void ParseUsingAutocomplete(const std::vector<ProcessedField>& processed_fields, ...@@ -390,17 +390,18 @@ void ParseUsingAutocomplete(const std::vector<ProcessedField>& processed_fields,
case AutocompleteFlag::kUsername: case AutocompleteFlag::kUsername:
if (processed_field.is_password || result->username) if (processed_field.is_password || result->username)
continue; continue;
username_fields_found++; username_fields_found++;
field_marked_as_username = processed_field.field; field_marked_as_username = processed_field.field;
break; break;
case AutocompleteFlag::kCurrentPassword: case AutocompleteFlag::kCurrentPassword:
if (!processed_field.is_password || result->password) if (!processed_field.is_password || result->password ||
processed_field.server_hints_not_password)
continue; continue;
result->password = processed_field.field; result->password = processed_field.field;
break; break;
case AutocompleteFlag::kNewPassword: case AutocompleteFlag::kNewPassword:
if (!processed_field.is_password || new_password_found_by_server) if (!processed_field.is_password || new_password_found_by_server ||
processed_field.server_hints_not_password)
continue; continue;
// The first field with autocomplete=new-password is considered to be // The first field with autocomplete=new-password is considered to be
// new_password and the second is confirmation_password. // new_password and the second is confirmation_password.
......
...@@ -1520,6 +1520,40 @@ TEST(FormParserTest, NotPasswordField) { ...@@ -1520,6 +1520,40 @@ TEST(FormParserTest, NotPasswordField) {
}); });
} }
// The parser should avoid identifying NOT_PASSWORD fields as passwords.
TEST(FormParserTest, NotPasswordFieldDespiteAutocompleteAttribute) {
CheckTestData({
{
"Server hints: NOT_PASSWORD.",
{
{.role = ElementRole::USERNAME, .form_control_type = "text"},
{.form_control_type = "password",
.prediction = {.type = autofill::NOT_PASSWORD},
.autocomplete_attribute = "current-password"},
{.form_control_type = "password",
.prediction = {.type = autofill::NOT_PASSWORD},
.autocomplete_attribute = "new-password"},
{.form_control_type = "password",
.prediction = {.type = autofill::NOT_PASSWORD},
.autocomplete_attribute = "password"},
{.role = ElementRole::CURRENT_PASSWORD,
.form_control_type = "password"},
},
.fallback_only = false,
},
{
"Server hints: NOT_PASSWORD on only password.",
{
{.role = ElementRole::USERNAME, .form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD,
.prediction = {.type = autofill::NOT_PASSWORD},
.form_control_type = "password"},
},
.fallback_only = true,
},
});
}
// Check that "readonly status" is reported accordingly. // Check that "readonly status" is reported accordingly.
TEST(FormParserTest, ReadonlyStatus) { TEST(FormParserTest, ReadonlyStatus) {
CheckTestData({ CheckTestData({
......
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