Commit b0a64211 authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

FormData parser tries to find missing username

When parsing FormData into PasswordForm, the new parser tries to keep
results from different types of analysis separate: if autocomplete
attributes or server hints only provide the password fields, the
parser currently does not try to figure out username with structural
analysis.

The server data currently lack username quite often, and also
autocomplete mark-up often lacks the username. As a result, the new
parser fails to find the username in many cases when the old parser
could.

Once server data improve, this issue will get much smaller (the
autocomplete data will also get replaced by server hints). However, it
is unlikely that this happens soon enough. Therefore, to keep the
effect of the change of parsers in M69 small, this CL adds the ability
to merge username from structural analysis / HTML classifier with the
results from server hints or autocomplete attributes.

The CL also renames ParseResult to SignificantFields, because both
"parse" and "result" are somewhat overloaded in this file. The CL
further does a few similar minor changes to naming, comments and
code structure, in an attempt to increase readability

Bug: 845426
Change-Id: Ie5a6297a2f7eb1a0d89421ea91a93bdd5a7112b5
Reviewed-on: https://chromium-review.googlesource.com/1117183
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarVadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571937}
parent a1981d69
...@@ -698,18 +698,6 @@ TEST(FormParserTest, TestAutocomplete) { ...@@ -698,18 +698,6 @@ TEST(FormParserTest, TestAutocomplete) {
.form_control_type = "password"}, .form_control_type = "password"},
}, },
}, },
{
"Partial autocomplete analysis is not complemented by basic "
"heuristics",
// Username not found because there was a valid autocomplete mark-up
// but it did not include the plain text field.
{
{.form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD,
.form_control_type = "password",
.autocomplete_attribute = "current-password"},
},
},
{ {
"Partial autocomplete analysis fails if no passwords are found", "Partial autocomplete analysis fails if no passwords are found",
// The attribute 'username' is ignored, because there was no password // The attribute 'username' is ignored, because there was no password
...@@ -1198,6 +1186,53 @@ TEST(FormParserTest, UsernamePredictions) { ...@@ -1198,6 +1186,53 @@ TEST(FormParserTest, UsernamePredictions) {
}); });
} }
// In some situations, server hints or autocomplete mark-up do not provide the
// username might be omitted. Sometimes this is a truthful signal (there might
// be no username despite the presence of plain text fields), but often this is
// just incomplete data. In the long term, the server hints should be complete
// and also cover cases when the autocomplete mark-up is lacking; at that point,
// the parser should just trust that the signal is truthful. Until then,
// however, the parser is trying to complement the signal with its structural
// heuristics.
TEST(FormParserTest, ComplementingResults) {
CheckTestData({
{
"Current password from autocomplete analysis, username from basic "
"heuristics",
{
{.role = ElementRole::USERNAME, .form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD,
.form_control_type = "password",
.autocomplete_attribute = "current-password"},
},
},
{
"New and confirmation passwords from server, username from basic "
"heuristics",
{
{.role = ElementRole::USERNAME, .form_control_type = "text"},
{.role = ElementRole::CONFIRMATION_PASSWORD,
.prediction = {.type = autofill::CONFIRMATION_PASSWORD},
.form_control_type = "password"},
{.form_control_type = "text"},
{.role = ElementRole::NEW_PASSWORD,
.prediction = {.type = autofill::NEW_PASSWORD},
.form_control_type = "password"},
},
},
{
"No password from server still means that serve hints are ignored.",
{
{.prediction = {.type = autofill::USERNAME_AND_EMAIL_ADDRESS},
.form_control_type = "text"},
{.role = ElementRole::USERNAME, .form_control_type = "text"},
{.role = ElementRole::CURRENT_PASSWORD,
.form_control_type = "password"},
},
},
});
}
} // namespace } // namespace
} // namespace password_manager } // namespace password_manager
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