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

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

Issue 2422363002: Trigger HTTP-bad warning when querying credit card autofill (Closed)
Patch Set: add missing blank line 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
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 76d8e853b03fa5c0d503e64c92e5c92c15e9802d..32a4d187d2f94963201b0d05653bb99d1b9d863c 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -471,7 +471,8 @@ class MockAutocompleteHistoryManager : public AutocompleteHistoryManager {
class MockAutofillDriver : public TestAutofillDriver {
public:
- MockAutofillDriver() : is_off_the_record_(false) {}
+ MockAutofillDriver()
+ : is_off_the_record_(false), did_interact_with_credit_card_form_(false) {}
// Mock methods to enable testability.
MOCK_METHOD3(SendFormDataToRenderer, void(int query_id,
@@ -484,8 +485,21 @@ class MockAutofillDriver : public TestAutofillDriver {
bool IsOffTheRecord() const override { return is_off_the_record_; }
+ void DidInteractWithCreditCardForm() override {
+ did_interact_with_credit_card_form_ = true;
+ };
+
+ void ClearDidInteractWithCreditCardForm() {
+ did_interact_with_credit_card_form_ = false;
+ };
+
+ bool did_interact_with_credit_card_form() const {
+ return did_interact_with_credit_card_form_;
+ }
+
private:
bool is_off_the_record_;
+ bool did_interact_with_credit_card_form_;
DISALLOW_COPY_AND_ASSIGN(MockAutofillDriver);
};
@@ -5247,4 +5261,36 @@ TEST_F(AutofillManagerTest,
}
}
+// Tests that querying for credit card field suggestions notifies the
+// driver of an interaction with a credit card field.
+TEST_F(AutofillManagerTest, NotifyDriverOfCreditCardInteraction) {
+ // Set up a credit card form.
+ FormData form;
+ form.name = ASCIIToUTF16("MyForm");
+ form.origin = GURL("https://myform.com/form.html");
+ form.action = GURL("https://myform.com/submit.html");
+ FormFieldData field;
+ test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field);
+ field.should_autocomplete = false;
+ form.fields.push_back(field);
+ test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field);
+ field.should_autocomplete = true;
+ form.fields.push_back(field);
+ test::CreateTestFormField("Expiration Month", "ccexpiresmonth", "", "text",
+ &field);
+ field.should_autocomplete = false;
+ form.fields.push_back(field);
+ form.fields.push_back(field);
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+ EXPECT_FALSE(autofill_driver_->did_interact_with_credit_card_form());
+
+ // The driver should always be notified.
+ for (const FormFieldData& field : form.fields) {
+ GetAutofillSuggestions(form, field);
+ EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form());
+ autofill_driver_->ClearDidInteractWithCreditCardForm();
+ }
+}
+
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/test_autofill_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698