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

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

Issue 2478043002: HTTP Bad: Add warning message to autofill dropdown for http sites (Closed)
Patch Set: nit change Created 4 years, 1 month 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') | components/autofill_strings.grdp » ('j') | 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 cdeb093cd92176793a026ad78593c9a2074904dc..034bd5bd7afc88693be923bc3f0bb6a168669471 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -49,6 +49,7 @@
#include "components/autofill/core/common/form_field_data.h"
#include "components/prefs/pref_service.h"
#include "components/rappor/test_rappor_service.h"
+#include "components/security_state/switches.h"
#include "components/variations/variations_associated_data.h"
#include "grit/components_strings.h"
#include "net/url_request/url_request_test_util.h"
@@ -1010,6 +1011,13 @@ class AutofillManagerTest : public testing::Test {
autofill_manager_->full_card_request_.get());
}
+ void SetHttpWarningEnabled() {
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ security_state::switches::kMarkHttpAs,
+ security_state::switches::
+ kMarkHttpWithPasswordsOrCcWithChipAndFormWarning);
+ }
+
protected:
base::MessageLoop message_loop_;
MockAutofillClient autofill_client_;
@@ -1601,6 +1609,65 @@ TEST_F(AutofillManagerTest, GetCreditCardSuggestions_NonSecureContext) {
EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
}
+// Test that we return an extra "Payment not secure" warning when the page and
+// the form target URL are not secure.
+TEST_F(AutofillManagerTest,
+ GetCreditCardSuggestions_NonSecureContextWithHttpBadSwitchOn) {
+ SetHttpWarningEnabled();
+
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, /* is_https */ false, false);
+ std::vector<FormData> forms(1, form);
+ FormsSeen(forms);
+
+ const FormFieldData& field = form.fields[0];
+ GetAutofillSuggestions(form, field);
+
+ // Test that we sent the right values to the external delegate.
+ external_delegate_->CheckSuggestions(
+ kDefaultPageID,
+ Suggestion(l10n_util::GetStringUTF8(
+ IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE),
+ "", "", -1),
+ Suggestion(
+ l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
+ "", "", -1));
+
+ // Clear the test credit cards and try again -- we shouldn't return a warning.
+ personal_data_.ClearCreditCards();
+ GetAutofillSuggestions(form, field);
+ // Autocomplete suggestions are queried, but not Autofill.
+ EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
+}
+
+// Test that we don't show the extra "Payment not secure" warning when the page
+// and the form target URL are secure, even when the switch is on.
+TEST_F(AutofillManagerTest,
+ GetCreditCardSuggestions_SecureContextWithHttpBadSwitchOn) {
+ SetHttpWarningEnabled();
+
+ // Set up our form data.
+ FormData form;
+ CreateTestCreditCardFormData(&form, /* is_https */ true, false);
+ 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 will eventually return the credit card signin promo when there
// are no credit card suggestions and the promo is active. See the tests in
// AutofillExternalDelegateTest that test whether the promo is added.
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698