Commit 6b32c1d4 authored by Hao Zhang's avatar Hao Zhang Committed by Commit Bot

[Exp date fix flow] Remove duplicate lines causing incorrect logic

These lines should be imported which caused a bug.
https://chromium-review.googlesource.com/c/chromium/src/+/1300314/39/components/autofill/core/browser/form_data_importer.cc

The line 445 to 449 should be removed and the line 451 to 455 is the right place. They shouldn't be kept both from this patch.
https://chromium-review.googlesource.com/c/chromium/src/+/1300314/18

It will auto-reject offering upload of expiration date fix flow cards as long as you have 1+ server cards on the device.

Bug: 899057
Change-Id: I55504fce3fe67ef57ad772c73e5026e793d3f033
Reviewed-on: https://chromium-review.googlesource.com/c/1329847
Commit-Queue: Hao Zhang <hozhng@google.com>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607421}
parent a537a905
......@@ -442,11 +442,6 @@ bool FormDataImporter::ImportCreditCard(
// there is for local cards.
for (const CreditCard* card :
personal_data_manager_->GetServerCreditCards()) {
// Don't update card if the expiration date is missing
if (candidate_credit_card.expiration_month() == 0 ||
candidate_credit_card.expiration_year() == 0) {
return false;
}
if (candidate_credit_card.HasSameNumberAs(*card)) {
// Don't update card if the expiration date is missing
if (candidate_credit_card.expiration_month() == 0 ||
......
......@@ -202,6 +202,10 @@ class FormDataImporter {
FRIEND_TEST_ALL_PREFIXES(
FormDataImporterTest,
Metrics_SubmittedServerCardExpirationStatus_EmptyExpirationYear);
FRIEND_TEST_ALL_PREFIXES(
FormDataImporterTest,
Metrics_SubmittedDifferentServerCardExpirationStatus_EmptyExpirationYear);
DISALLOW_COPY_AND_ASSIGN(FormDataImporter);
};
......
......@@ -2992,6 +2992,55 @@ TEST_F(FormDataImporterTest,
EXPECT_FALSE(imported_credit_card);
}
// Ensure that we still offer to save if we have different cards stored as a
// server card and user submitted an invalid expiration date year.
TEST_F(
FormDataImporterTest,
Metrics_SubmittedDifferentServerCardExpirationStatus_EmptyExpirationYear) {
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillUpstreamEditableExpirationDate);
EnableWalletCardImport();
std::vector<CreditCard> server_cards;
server_cards.push_back(CreditCard(CreditCard::FULL_SERVER_CARD, "c789"));
test::SetCreditCardInfo(&server_cards.back(), "Clyde Barrow",
"4111111111111111" /* Visa */, "04", "2111", "1");
test::SetServerCreditCards(autofill_table_, server_cards);
// Make sure everything is set up correctly.
personal_data_manager_->Refresh();
WaitForOnPersonalDataChanged();
EXPECT_EQ(1U, personal_data_manager_->GetCreditCards().size());
// A user fills/enters the card's information on a checkout form with an empty
// expiration date.
FormData form;
form.origin = GURL("https://wwww.foo.com");
FormFieldData field;
test::CreateTestFormField("Name on card:", "name_on_card", "Clyde Barrow",
"text", &field);
form.fields.push_back(field);
test::CreateTestFormField("Card Number:", "card_number", "4444333322221111",
"text", &field);
form.fields.push_back(field);
test::CreateTestFormField("Exp Month:", "exp_month", "08", "text", &field);
form.fields.push_back(field);
test::CreateTestFormField("Exp Year:", "exp_year", "", "text", &field);
form.fields.push_back(field);
FormStructure form_structure(form);
form_structure.DetermineHeuristicTypes();
std::unique_ptr<CreditCard> imported_credit_card;
EXPECT_TRUE(form_data_importer_->ImportFormData(
form_structure,
/*profile_autofill_enabled=*/true,
/*credit_card_autofill_enabled=*/true,
/*should_return_local_card=*/false, &imported_credit_card));
EXPECT_TRUE(imported_credit_card);
}
TEST_F(FormDataImporterTest,
Metrics_SubmittedServerCardExpirationStatus_FullServerCardMismatch) {
EnableWalletCardImport();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment