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

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

Issue 493393003: [Autofill] Autofill incorrectly fills credit card expiration year in 2-digit fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review comments and code indentation. Created 6 years, 4 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/credit_card_field.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/credit_card_field_unittest.cc
diff --git a/components/autofill/core/browser/credit_card_field_unittest.cc b/components/autofill/core/browser/credit_card_field_unittest.cc
index 037a302c340359eaef21595384e09f04342dddfc..39e222f305da271cfe17b9d420fdc2135257b2a2 100644
--- a/components/autofill/core/browser/credit_card_field_unittest.cc
+++ b/components/autofill/core/browser/credit_card_field_unittest.cc
@@ -347,4 +347,37 @@ TEST_F(CreditCardFieldTest, ParseMonthControl) {
field_type_map_[ASCIIToUTF16("date2")]);
}
+// Verify that heuristics <input name="ccyear" maxlength="2"/> considers
+// *maxlength* attribute while parsing 2 Digit expiration year.
+TEST_F(CreditCardFieldTest, ParseCreditCardExpYear_2DigitMaxLength) {
+ FormFieldData field;
+ field.form_control_type = "text";
+
+ field.label = ASCIIToUTF16("Card Number");
+ field.name = ASCIIToUTF16("card_number");
+ list_.push_back(new AutofillField(field, ASCIIToUTF16("number")));
+
+ field.label = ASCIIToUTF16("Expiration Date");
+ field.name = ASCIIToUTF16("ccmonth");
+ list_.push_back(new AutofillField(field, ASCIIToUTF16("month")));
+
+ field.name = ASCIIToUTF16("ccyear");
+ field.max_length = 2;
+ list_.push_back(new AutofillField(field, ASCIIToUTF16("year")));
+
+ Parse();
+ ASSERT_NE(static_cast<CreditCardField*>(NULL), field_.get());
+ EXPECT_TRUE(ClassifyField());
+ ASSERT_TRUE(field_type_map_.find(ASCIIToUTF16("number")) !=
+ field_type_map_.end());
+ EXPECT_EQ(CREDIT_CARD_NUMBER, field_type_map_[ASCIIToUTF16("number")]);
+ ASSERT_TRUE(field_type_map_.find(ASCIIToUTF16("month")) !=
+ field_type_map_.end());
+ EXPECT_EQ(CREDIT_CARD_EXP_MONTH, field_type_map_[ASCIIToUTF16("month")]);
+ ASSERT_TRUE(field_type_map_.find(ASCIIToUTF16("year")) !=
+ field_type_map_.end());
+ EXPECT_EQ(CREDIT_CARD_EXP_2_DIGIT_YEAR,
+ field_type_map_[ASCIIToUTF16("year")]);
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/credit_card_field.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698