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

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

Issue 2432063003: [Autofill] Offer credit card suggestions for some form action. (Closed)
Patch Set: added a test Created 4 years, 2 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 9fee3725942722ba9e4c415227d7053c04279274..a188001a1338d9242262b9f49d1df2a6c83930a2 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -1576,10 +1576,10 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonCCNumber) {
// Test that we return a warning explaining that credit card profile suggestions
// are unavailable when the page and the form target URL are not secure.
-TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonHTTPS) {
+TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonSecureContext) {
// Set up our form data.
FormData form;
- CreateTestCreditCardFormData(&form, false, false);
+ CreateTestCreditCardFormData(&form, /* is_https */ false, false);
std::vector<FormData> forms(1, form);
FormsSeen(forms);
@@ -1601,9 +1601,10 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonHTTPS) {
}
// Test that we return a warning explaining that credit card profile suggestions
-// are unavailable when the page is secure, but the form target URL is not
-// secure.
-TEST_F(AutofillManagerTest, GetCreditCardSuggestions_TargetURLNonHTTPS) {
+// are unavailable when the page is secure, but the form action URL is valid but
+// not secure.
+TEST_F(AutofillManagerTest,
+ GetCreditCardSuggestions_SecureContext_FormActionNotHTTPS) {
// Set up our form data.
FormData form;
CreateTestCreditCardFormData(&form, /* is_https= */ true, false);
@@ -1628,6 +1629,60 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestions_TargetURLNonHTTPS) {
EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
}
+// Test that we return credit card suggestions for secure pages that have an
+// empty form action target URL.
+TEST_F(AutofillManagerTest,
+ GetCreditCardSuggestions_SecureContext_EmptyFormAction) {
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, true, false);
+ // Clear the form action.
+ form.action = GURL();
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ FormFieldData field = form.fields[1];
+ GetAutofillSuggestions(form, field);
+
+ // Test that we sent the right values to the external delegate.
+ external_delegate_->CheckSuggestions(
+ kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF"
+ "3456",
+ "04/99", kVisaCard,
+ autofill_manager_->GetPackedCreditCardID(4)),
+ Suggestion("MasterCard\xC2\xA0\xE2\x8B\xAF"
+ "8765",
+ "10/98", kMasterCard,
+ autofill_manager_->GetPackedCreditCardID(5)));
+}
+
+// Test that we return credit card suggestions for secure pages that have a
+// form action set to "javascript:something".
+TEST_F(AutofillManagerTest,
+ GetCreditCardSuggestions_SecureContext_JavascriptFormAction) {
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, true, false);
+ // Have the form action be a javascript function (which is a valid URL).
+ form.action = GURL("javascript:alert('Hello');");
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ FormFieldData field = form.fields[1];
+ GetAutofillSuggestions(form, field);
+
+ // Test that we sent the right values to the external delegate.
+ external_delegate_->CheckSuggestions(
+ kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF"
+ "3456",
+ "04/99", kVisaCard,
+ autofill_manager_->GetPackedCreditCardID(4)),
+ Suggestion("MasterCard\xC2\xA0\xE2\x8B\xAF"
+ "8765",
+ "10/98", kMasterCard,
+ autofill_manager_->GetPackedCreditCardID(5)));
+}
+
// Test that we return all credit card suggestions in the case that two cards
// have the same obfuscated number.
TEST_F(AutofillManagerTest, GetCreditCardSuggestions_RepeatedObfuscatedNumber) {
« 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