summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 02:16:53 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 02:16:53 +0000
commit44e621d061718eb36b814cda5e9fc466abb850f6 (patch)
tree4e928909169e609777576a171939856e00d8cbda
parentedb2cd3f0f88b06c6a73380110692bf201ac8472 (diff)
downloadchromium_src-44e621d061718eb36b814cda5e9fc466abb850f6.zip
chromium_src-44e621d061718eb36b814cda5e9fc466abb850f6.tar.gz
chromium_src-44e621d061718eb36b814cda5e9fc466abb850f6.tar.bz2
AutoFill heuristics extended to include multiple separator characters.
AutoFill heuristics were successfully matching labels such as "First Name" but not "First Name". Extra whitespace and other separator characters are now allowed. There are examples of this in the sample3.html test file. BUG=38257 TEST=Manual testing against sample3.html, sample6.html, and sample8.html. NameFieldTest.FirstLastMiddleWithSpaces Review URL: http://codereview.chromium.org/1993013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47111 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/name_field.cc8
-rw-r--r--chrome/browser/autofill/name_field_unittest.cc35
2 files changed, 39 insertions, 4 deletions
diff --git a/chrome/browser/autofill/name_field.cc b/chrome/browser/autofill/name_field.cc
index 7d87030..0eeb0c3 100644
--- a/chrome/browser/autofill/name_field.cc
+++ b/chrome/browser/autofill/name_field.cc
@@ -28,7 +28,7 @@ FullNameField* FullNameField::Parse(
// for example, Travelocity_Edit travel profile.html contains a field
// "Travel Profile Name".
const string16 name_match =
- ASCIIToUTF16("^name|full name|fullname|your name|customer name");
+ ASCIIToUTF16("^name|full *name|your name|customer name");
if (ParseText(iter, name_match, &field))
return new FullNameField(field);
@@ -75,7 +75,7 @@ FirstLastNameField* FirstLastNameField::Parse2(
// American-style).
// The ".*first$" matches fields ending in "first" (example in sample8.html).
string16 match =
- ASCIIToUTF16("first name|first_name|firstname|initials|fname|.*first$");
+ ASCIIToUTF16("first *name|first_name|initials|fname|.*first$");
if (!ParseText(&q, match, &v.first_name_))
return NULL;
@@ -88,12 +88,12 @@ FirstLastNameField* FirstLastNameField::Parse2(
if (ParseText(&q, match, &v.middle_name_)) {
v.middle_initial_ = true;
} else {
- match = ASCIIToUTF16("middle name|mname|middlename");
+ match = ASCIIToUTF16("middle *name|mname");
ParseText(&q, match, &v.middle_name_);
}
// The ".*last$" matches fields ending in "last" (example in sample8.html).
- match = ASCIIToUTF16("last name|last_name|lastname|lname|surname|.*last$");
+ match = ASCIIToUTF16("last *name|last_name|lname|surname|.*last$");
if (!ParseText(&q, match, &v.last_name_))
return NULL;
diff --git a/chrome/browser/autofill/name_field_unittest.cc b/chrome/browser/autofill/name_field_unittest.cc
index f8a3d1c..438bef3 100644
--- a/chrome/browser/autofill/name_field_unittest.cc
+++ b/chrome/browser/autofill/name_field_unittest.cc
@@ -147,4 +147,39 @@ TEST_F(NameFieldTest, FirstLast2) {
EXPECT_EQ(NAME_LAST, field_type_map_[ASCIIToUTF16("name2")]);
}
+TEST_F(NameFieldTest, FirstLastMiddleWithSpaces) {
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("First Name"),
+ ASCIIToUTF16("first name"),
+ string16(),
+ ASCIIToUTF16("text")),
+ ASCIIToUTF16("name1")));
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Middle Name"),
+ ASCIIToUTF16("middle name"),
+ string16(),
+ ASCIIToUTF16("text")),
+ ASCIIToUTF16("name2")));
+ list_.push_back(
+ new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Last Name"),
+ ASCIIToUTF16("last name"),
+ string16(),
+ ASCIIToUTF16("text")),
+ ASCIIToUTF16("name3")));
+ list_.push_back(NULL);
+ iter_ = list_.begin();
+ field_.reset(NameField::Parse(&iter_, false));
+ ASSERT_NE(static_cast<NameField*>(NULL), field_.get());
+ ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
+ ASSERT_TRUE(
+ field_type_map_.find(ASCIIToUTF16("name1")) != field_type_map_.end());
+ EXPECT_EQ(NAME_FIRST, field_type_map_[ASCIIToUTF16("name1")]);
+ ASSERT_TRUE(
+ field_type_map_.find(ASCIIToUTF16("name2")) != field_type_map_.end());
+ EXPECT_EQ(NAME_MIDDLE, field_type_map_[ASCIIToUTF16("name2")]);
+ ASSERT_TRUE(
+ field_type_map_.find(ASCIIToUTF16("name3")) != field_type_map_.end());
+ EXPECT_EQ(NAME_LAST, field_type_map_[ASCIIToUTF16("name3")]);
+}
+
} // namespace