Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: components/autofill/core/browser/form_structure_unittest.cc

Issue 1671753004: [Autofill] Fill fields that have an autocomplete attributes even if not in a form. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added IPC Trait for new attribute Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | components/autofill/core/common/form_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/form_structure_unittest.cc
diff --git a/components/autofill/core/browser/form_structure_unittest.cc b/components/autofill/core/browser/form_structure_unittest.cc
index 4d1812a3e88f58796042e7029f7c07fbefb2335c..21e9945456f52488d9573626f8f347ff8d9802df 100644
--- a/components/autofill/core/browser/form_structure_unittest.cc
+++ b/components/autofill/core/browser/form_structure_unittest.cc
@@ -451,6 +451,58 @@ TEST_F(FormStructureTest, HeuristicsAutocompleteAttribute) {
EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type());
}
+// Verify that the heuristics are not run for non checkout formless forms.
+TEST_F(FormStructureTest, Heuristics_FormlessNonCheckoutForm) {
+ scoped_ptr<FormStructure> form_structure;
+ FormData form;
+
+ FormFieldData field;
+ field.form_control_type = "text";
+
+ field.label = ASCIIToUTF16("First Name:");
+ field.name = ASCIIToUTF16("firstname");
+ field.autocomplete_attribute = "given-name";
+ form.fields.push_back(field);
+
+ field.label = ASCIIToUTF16("Last Name:");
+ field.name = ASCIIToUTF16("lastname");
+ field.autocomplete_attribute = "family-name";
+ form.fields.push_back(field);
+
+ field.label = ASCIIToUTF16("Email:");
+ field.name = ASCIIToUTF16("email");
+ field.autocomplete_attribute = "email";
+ form.fields.push_back(field);
+
+ form_structure.reset(new FormStructure(form));
+ form_structure->DetermineHeuristicTypes();
+ EXPECT_TRUE(form_structure->IsAutofillable());
+
+ // Expect the correct number of fields.
+ ASSERT_EQ(3U, form_structure->field_count());
+ ASSERT_EQ(3U, form_structure->autofill_count());
+
+ // The heuristic type should be good.
+ EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
+ EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
+
+ // Set the form as a formless non checkout form.
+ form.is_formless_checkout = false;
+ form.is_form_tag = false;
+
+ form_structure.reset(new FormStructure(form));
+ form_structure->DetermineHeuristicTypes();
+ EXPECT_TRUE(form_structure->IsAutofillable());
+
+ // Expect the correct number of fields.
+ ASSERT_EQ(3U, form_structure->field_count());
+ ASSERT_EQ(3U, form_structure->autofill_count());
+
+ // The heuristic type should be Unknown.
+ EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type());
+ EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
+}
+
// All fields share a common prefix which could confuse the heuristics. Test
// that the common prefix is stripped out before running heuristics.
TEST_F(FormStructureTest, StripCommonNamePrefix) {
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | components/autofill/core/common/form_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698