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

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

Issue 2676513007: Do not show Scan or Sign In options when credit card form is non-secure (Closed)
Patch Set: Add unit tests Created 3 years, 10 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/autofill_manager.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/autofill_manager_unittest.cc
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index 7442b0b64e767a1da5b950928cc83a246d6231d3..219ef8e088b802a04f34691ff0573be7d800eb18 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -5361,6 +5361,66 @@ TEST_F(AutofillManagerTest,
prefs::kAutofillCreditCardSigninPromoImpressionCount));
}
+// Test that ShouldShowCreditCardSigninPromo behaves as expected for a credit
+// card form on a non-secure page.
+TEST_F(AutofillManagerTest,
+ ShouldShowCreditCardSigninPromo_CreditCardField_NonSecureContext) {
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, false, false);
+ form.origin = GURL("http://myform.com/form.html");
+ form.action = GURL("https://myform.com/submit.html");
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ FormFieldData field;
+ test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field);
+
+ // Both calls will now return false, regardless of the mock implementation of
+ // ShouldShowSigninPromo().
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillOnce(testing::Return(true));
+ EXPECT_FALSE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillOnce(testing::Return(false));
+ EXPECT_FALSE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+
+ // Number of impressions should remain at zero.
+ EXPECT_EQ(0, autofill_client_.GetPrefs()->GetInteger(
+ prefs::kAutofillCreditCardSigninPromoImpressionCount));
+}
+
+// Test that ShouldShowCreditCardSigninPromo behaves as expected for a credit
+// card form targeting a non-secure page.
+TEST_F(AutofillManagerTest,
+ ShouldShowCreditCardSigninPromo_CreditCardField_NonSecureAction) {
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, false, false);
+ form.origin = GURL("https://myform.com/form.html");
+ form.action = GURL("http://myform.com/submit.html");
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ FormFieldData field;
+ test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field);
+
+ // Both calls will now return false, regardless of the mock implementation of
+ // ShouldShowSigninPromo().
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillOnce(testing::Return(true));
+ EXPECT_FALSE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+
+ EXPECT_CALL(autofill_client_, ShouldShowSigninPromo())
+ .WillOnce(testing::Return(false));
+ EXPECT_FALSE(autofill_manager_->ShouldShowCreditCardSigninPromo(form, field));
+
+ // Number of impressions should remain at zero.
+ EXPECT_EQ(0, autofill_client_.GetPrefs()->GetInteger(
+ prefs::kAutofillCreditCardSigninPromoImpressionCount));
+}
+
// Test that ShouldShowCreditCardSigninPromo behaves as expected for an address
// form.
TEST_F(AutofillManagerTest, ShouldShowCreditCardSigninPromo_AddressField) {
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698