summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 05:54:44 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-16 05:54:44 +0000
commit8a6328365c845f3f32a9e36c3727d7ec6a118383 (patch)
treea750c784973b8ec37c35ec8148d4ad8569f727d7
parenta55231c852bff057858ccad7829ab307d083bb15 (diff)
downloadchromium_src-8a6328365c845f3f32a9e36c3727d7ec6a118383.zip
chromium_src-8a6328365c845f3f32a9e36c3727d7ec6a118383.tar.gz
chromium_src-8a6328365c845f3f32a9e36c3727d7ec6a118383.tar.bz2
Don't rely on email fields to detect section breaks for autofill.
Websites often ask for the email to be entered twice (as confirmation), so this ends up being a poor signal for where logical form section breaks are. BUG=75871 TEST=unit_tests --gtest_filter=AutofillManagerTest.FillFormWithMultipleEmails Review URL: http://codereview.chromium.org/6684023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78335 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_manager.cc5
-rw-r--r--chrome/browser/autofill/autofill_manager.h1
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc31
3 files changed, 36 insertions, 1 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index 766cb30..f29068d 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -118,10 +118,13 @@ void FindSectionBounds(const FormStructure& form,
// Forms often ask for multiple phone numbers -- e.g. both a daytime and
// evening phone number. Our phone and fax number detection is also
// generally a little off. Hence, ignore both field types as a signal here.
+ // Likewise, forms often ask for multiple email addresses, so ignore this
+ // field type as well.
AutofillType::FieldTypeGroup current_type_group =
AutofillType(current_type).group();
if (current_type_group == AutofillType::PHONE_HOME ||
- current_type_group == AutofillType::PHONE_FAX)
+ current_type_group == AutofillType::PHONE_FAX ||
+ current_type_group == AutofillType::EMAIL)
already_saw_current_type = false;
// If we are filling credit card data, the relevant section should include
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index b178f25..cf69c3d 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -230,6 +230,7 @@ class AutofillManager : public TabContentsObserver,
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillAddressForm);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillAddressAndCreditCardForm);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillFormWithMultipleSections);
+ FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillFormWithMultipleEmails);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillAutoFilledForm);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillPhoneNumber);
FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FormChangesRemoveField);
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index cea6dd3..3ec6a51d 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -1539,6 +1539,37 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) {
}
}
+// Test that we correctly fill a form that has a single logical section with
+// multiple email address fields.
+TEST_F(AutofillManagerTest, FillFormWithMultipleEmails) {
+ // Set up our form data.
+ FormData form;
+ CreateTestAddressFormData(&form);
+ FormField field;
+ autofill_test::CreateTestFormField(
+ "Confirm email", "email2", "", "text", &field);
+ form.fields.push_back(field);
+
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ // Fill the form.
+ std::string guid = "00000000-0000-0000-0000-000000000001";
+ FillAutoFillFormData(kDefaultPageID, form, form.fields[0],
+ autofill_manager_->PackGUIDs(std::string(), guid));
+
+ int page_id = 0;
+ FormData results;
+ EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
+
+ // The second email address should be filled.
+ EXPECT_EQ(ASCIIToUTF16("theking@gmail.com"), results.fields.back().value);
+
+ // The remainder of the form should be filled as usual.
+ results.fields.pop_back();
+ ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false);
+}
+
// Test that we correctly fill a previously auto-filled form.
TEST_F(AutofillManagerTest, FillAutoFilledForm) {
// Set up our form data.