summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 00:07:00 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 00:07:00 +0000
commitc5816849d0d7d0c68ea35109958fceb96adeac2f (patch)
treeafd15d8f66b0ec46f5245d9e338a1df621aedf28 /chrome/browser/autofill
parent5781bcf9ed18012c1bc7edc98d009c5ca0e1ae91 (diff)
downloadchromium_src-c5816849d0d7d0c68ea35109958fceb96adeac2f.zip
chromium_src-c5816849d0d7d0c68ea35109958fceb96adeac2f.tar.gz
chromium_src-c5816849d0d7d0c68ea35109958fceb96adeac2f.tar.bz2
AutoFill doesn't fill address information on www.gorillaclothing.com
Adjusts address heuristics to match "addressLine1" and "addressLine2" names. Also, cleans up the regular expressions to avoid redundancies. BUG=52126 TEST=FormStructureTest.BillingAndShippingAddresses Review URL: http://codereview.chromium.org/3159043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/address_field.cc10
-rw-r--r--chrome/browser/autofill/form_structure_unittest.cc50
2 files changed, 53 insertions, 7 deletions
diff --git a/chrome/browser/autofill/address_field.cc b/chrome/browser/autofill/address_field.cc
index f21f532..52e5193 100644
--- a/chrome/browser/autofill/address_field.cc
+++ b/chrome/browser/autofill/address_field.cc
@@ -202,7 +202,7 @@ bool AddressField::ParseAddressLines(
return false;
} else {
pattern =
- ASCIIToUTF16("street|address line|address1|street_line1|addr1");
+ ASCIIToUTF16("address.?line|address1|addr1|street");
string16 label_pattern = ASCIIToUTF16("address");
if (!ParseText(iter, pattern, &address_field->address1_))
@@ -219,7 +219,7 @@ bool AddressField::ParseAddressLines(
if (!ParseEmptyText(iter, &address_field->address2_))
ParseText(iter, pattern, &address_field->address2_);
} else {
- pattern = ASCIIToUTF16("address2|street|street_line2|addr2|suite|unit");
+ pattern = ASCIIToUTF16("address.?line2|address2|addr2|street|suite|unit");
string16 label_pattern = ASCIIToUTF16("address");
if (!ParseEmptyText(iter, &address_field->address2_))
if (!ParseText(iter, pattern, &address_field->address2_))
@@ -233,11 +233,9 @@ bool AddressField::ParseAddressLines(
kEcmlBillToAddress3, '|');
ParseText(iter, pattern);
} else {
- pattern = ASCIIToUTF16("address3|street|street_line3|addr3|line3");
- string16 label_pattern = ASCIIToUTF16("address");
+ pattern = ASCIIToUTF16("address.?line3|address3|addr3|street|line3");
if (!ParseEmptyText(iter, NULL))
- if (!ParseText(iter, pattern, NULL))
- ParseLabelText(iter, label_pattern, NULL);
+ ParseText(iter, pattern, NULL);
}
}
diff --git a/chrome/browser/autofill/form_structure_unittest.cc b/chrome/browser/autofill/form_structure_unittest.cc
index b2d0435..14fe516 100644
--- a/chrome/browser/autofill/form_structure_unittest.cc
+++ b/chrome/browser/autofill/form_structure_unittest.cc
@@ -421,7 +421,8 @@ TEST(FormStructureTest, HeuristicsSample8) {
// Zip.
EXPECT_EQ(ADDRESS_BILLING_ZIP, form_structure->field(6)->heuristic_type());
// Country.
- EXPECT_EQ(ADDRESS_BILLING_COUNTRY, form_structure->field(7)->heuristic_type());
+ EXPECT_EQ(ADDRESS_BILLING_COUNTRY,
+ form_structure->field(7)->heuristic_type());
// Phone.
EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER,
form_structure->field(8)->heuristic_type());
@@ -741,6 +742,53 @@ TEST(FormStructureTest, ThreeAddressLines) {
EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(3)->heuristic_type());
}
+// This test verifies that "addressLine1" and "addressLine2" matches heuristics.
+// This occured in https://www.gorillaclothing.com/. http://crbug.com/52126.
+TEST(FormStructureTest, BillingAndShippingAddresses) {
+ scoped_ptr<FormStructure> form_structure;
+ FormData form;
+
+ form.method = ASCIIToUTF16("post");
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
+ ASCIIToUTF16("shipping.address.addressLine1"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
+ ASCIIToUTF16("shipping.address.addressLine2"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
+ ASCIIToUTF16("billing.address.addressLine1"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form.fields.push_back(
+ webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
+ ASCIIToUTF16("billing.address.addressLine2"),
+ string16(),
+ ASCIIToUTF16("text"),
+ 0));
+ form_structure.reset(new FormStructure(form));
+ EXPECT_TRUE(form_structure->IsAutoFillable());
+ ASSERT_EQ(4U, form_structure->field_count());
+ ASSERT_EQ(4U, form_structure->autofill_count());
+
+ // Address Line 1.
+ EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(0)->heuristic_type());
+ // Address Line 2.
+ EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(1)->heuristic_type());
+ // Address Line 1.
+ EXPECT_EQ(ADDRESS_BILLING_LINE1, form_structure->field(2)->heuristic_type());
+ // Address Line 2.
+ EXPECT_EQ(ADDRESS_BILLING_LINE2, form_structure->field(3)->heuristic_type());
+}
+
+
// This example comes from expedia.com where they use a "Suite" label to
// indicate a suite or apartment number. We interpret this as address line 2.
// And the following "Street address second line" we interpret as address line