Commit 20c7806a authored by Roger McFarlane's avatar Roger McFarlane Committed by Commit Bot

[autofill] Treat autocomplete=false the same as autocomplete=off

This CL makes Chrome treat a field with autocomplete=false the same
as one with autocomplete=off, instread of treating autocomplete=false
as an unrecognized/unsupported type identifier.

Bug: 789193
Change-Id: I80b4690e904b549775a0f055fa7f5df13d519e14
Reviewed-on: https://chromium-review.googlesource.com/794034
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Commit-Queue: Sebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519783}
parent 4a56735d
......@@ -879,7 +879,8 @@ void FormStructure::ParseFieldTypesFromAutocompleteAttributes() {
// type hint or whether autocomplete should be enabled at all. Ignore the
// latter type of attribute value.
if (tokens.empty() ||
(tokens.size() == 1 && (tokens[0] == "on" || tokens[0] == "off"))) {
(tokens.size() == 1 &&
(tokens[0] == "on" || tokens[0] == "off" || tokens[0] == "false"))) {
continue;
}
......
......@@ -440,6 +440,41 @@ TEST_F(FormStructureTest, ShouldBeParsed_TwoFields_HasAutocomplete) {
EXPECT_TRUE(form_structure->ShouldBeParsed());
}
// Tests that ShouldBeParsed returns true for a form containing less than three
// fields if at least one has an autocomplete attribute.
TEST_F(FormStructureTest, DetermineHeuristicTypes_AutocompleteFalse) {
std::unique_ptr<FormStructure> form_structure;
FormData form;
FormFieldData field;
field.label = ASCIIToUTF16("Name");
field.name = ASCIIToUTF16("name");
field.form_control_type = "text";
field.autocomplete_attribute = "false";
form.fields.push_back(field);
field.label = ASCIIToUTF16("Email");
field.name = ASCIIToUTF16("email");
field.form_control_type = "text";
field.autocomplete_attribute = "false";
form.fields.push_back(field);
field.label = ASCIIToUTF16("State");
field.name = ASCIIToUTF16("state");
field.form_control_type = "select-one";
field.autocomplete_attribute = "false";
form.fields.push_back(field);
form_structure.reset(new FormStructure(form));
form_structure->DetermineHeuristicTypes(nullptr);
EXPECT_TRUE(form_structure->ShouldBeParsed());
EXPECT_EQ(3U, form_structure->autofill_count());
EXPECT_EQ(NAME_FULL, form_structure->field(0)->Type().GetStorableType());
EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(1)->Type().GetStorableType());
EXPECT_EQ(ADDRESS_HOME_STATE,
form_structure->field(2)->Type().GetStorableType());
}
TEST_F(FormStructureTest, HeuristicsContactInfo) {
std::unique_ptr<FormStructure> form_structure;
FormData 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