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

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: Addressed comments 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
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..ebc4010aa61077cd66c145bb10a626db1fa48f81 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 synthetic forms.
Mathieu 2016/02/05 22:36:45 I would change synthetic -> formless everywhere.
sebsg 2016/02/09 01:13:57 Done.
+TEST_F(FormStructureTest, Heuristics_SyntheticNonCheckoutForm) {
+ 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 synthetic 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) {

Powered by Google App Engine
This is Rietveld 408576698