Commit 8b0a574f authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

Set form_has_autofilled_value in FormParser.

This field is set to true if at least one password field was autofilled.

Bug: 1001903
Change-Id: Iaa36a4305f1cbb30beaf991cd4dd2e1af9b7bc47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1800764Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695991}
parent 4684c535
......@@ -947,6 +947,13 @@ std::unique_ptr<PasswordForm> AssemblePasswordForm(
result->only_for_fallback = significant_fields.is_fallback;
result->submission_event = form_data.submission_event;
for (const FormFieldData& field : form_data.fields) {
if (field.form_control_type == "password" &&
(field.properties_mask & FieldPropertiesFlags::AUTOFILLED)) {
result->form_has_autofilled_value = true;
}
}
// Set data related to specific fields.
SetFields(significant_fields, result.get());
return result;
......
......@@ -97,6 +97,7 @@ struct FormParsingTestCase {
bool fallback_only = false;
SubmissionIndicatorEvent submission_event = SubmissionIndicatorEvent::NONE;
base::Optional<bool> is_new_password_reliable;
bool form_has_autofilled_value = false;
};
// Returns numbers which are distinct from each other within the scope of one
......@@ -374,6 +375,8 @@ void CheckTestData(const std::vector<FormParsingTestCase>& test_cases) {
EXPECT_EQ(*test_case.is_new_password_reliable,
parsed_form->is_new_password_reliable);
}
EXPECT_EQ(test_case.form_has_autofilled_value,
parsed_form->form_has_autofilled_value);
CheckPasswordFormFields(*parsed_form, form_data, expected_ids);
CheckAllValuesUnique(parsed_form->all_possible_passwords);
......@@ -1024,6 +1027,7 @@ TEST(FormParserTest, ReadonlyFields) {
{.form_control_type = "password", .is_readonly = true},
},
.number_of_all_possible_passwords = 3,
.form_has_autofilled_value = true,
},
{
.description_for_logging = "And passwords already filled by user or "
......@@ -1044,6 +1048,7 @@ TEST(FormParserTest, ReadonlyFields) {
{.form_control_type = "password", .is_readonly = true},
},
.number_of_all_possible_passwords = 3,
.form_has_autofilled_value = true,
},
});
}
......@@ -1261,6 +1266,7 @@ TEST(FormParserTest, Interactability) {
.is_focusable = true},
},
.number_of_all_possible_passwords = 3,
.form_has_autofilled_value = true,
},
{
"Interactability for usernames is only considered before the first "
......@@ -1279,6 +1285,7 @@ TEST(FormParserTest, Interactability) {
.is_focusable = true},
{.form_control_type = "text", .is_focusable = true, .value = ""},
},
.form_has_autofilled_value = true,
},
{
"Interactability also matters for HTML classifier.",
......@@ -1749,6 +1756,7 @@ TEST(FormParserTest, ReadonlyStatus) {
},
.readonly_status =
FormDataParser::ReadonlyPasswordFields::kNoneIgnored,
.form_has_autofilled_value = true,
},
{
"Some readonly passwords ignored.",
......
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