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

Side by Side 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: remove an unused header file 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "components/autofill/core/browser/test_autofill_external_delegate.h" 42 #include "components/autofill/core/browser/test_autofill_external_delegate.h"
43 #include "components/autofill/core/browser/validation.h" 43 #include "components/autofill/core/browser/validation.h"
44 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 44 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
45 #include "components/autofill/core/common/autofill_pref_names.h" 45 #include "components/autofill/core/common/autofill_pref_names.h"
46 #include "components/autofill/core/common/autofill_switches.h" 46 #include "components/autofill/core/common/autofill_switches.h"
47 #include "components/autofill/core/common/autofill_util.h" 47 #include "components/autofill/core/common/autofill_util.h"
48 #include "components/autofill/core/common/form_data.h" 48 #include "components/autofill/core/common/form_data.h"
49 #include "components/autofill/core/common/form_field_data.h" 49 #include "components/autofill/core/common/form_field_data.h"
50 #include "components/prefs/pref_service.h" 50 #include "components/prefs/pref_service.h"
51 #include "components/rappor/test_rappor_service.h" 51 #include "components/rappor/test_rappor_service.h"
52 #include "components/security_state/switches.h"
52 #include "components/variations/variations_associated_data.h" 53 #include "components/variations/variations_associated_data.h"
53 #include "grit/components_strings.h" 54 #include "grit/components_strings.h"
54 #include "net/url_request/url_request_test_util.h" 55 #include "net/url_request/url_request_test_util.h"
55 #include "testing/gmock/include/gmock/gmock.h" 56 #include "testing/gmock/include/gmock/gmock.h"
56 #include "testing/gtest/include/gtest/gtest.h" 57 #include "testing/gtest/include/gtest/gtest.h"
57 #include "ui/base/l10n/l10n_util.h" 58 #include "ui/base/l10n/l10n_util.h"
58 #include "ui/gfx/geometry/rect.h" 59 #include "ui/gfx/geometry/rect.h"
59 #include "url/gurl.h" 60 #include "url/gurl.h"
60 61
61 using base::ASCIIToUTF16; 62 using base::ASCIIToUTF16;
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), 1595 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
1595 "", "", -1)); 1596 "", "", -1));
1596 1597
1597 // Clear the test credit cards and try again -- we shouldn't return a warning. 1598 // Clear the test credit cards and try again -- we shouldn't return a warning.
1598 personal_data_.ClearCreditCards(); 1599 personal_data_.ClearCreditCards();
1599 GetAutofillSuggestions(form, field); 1600 GetAutofillSuggestions(form, field);
1600 // Autocomplete suggestions are queried, but not Autofill. 1601 // Autocomplete suggestions are queried, but not Autofill.
1601 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen()); 1602 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
1602 } 1603 }
1603 1604
1605 // Test that we return an extra "Payment not secure" warning when the page and
1606 // the form target URL are not secure.
1607 TEST_F(AutofillManagerTest,
1608 GetCreditCardSuggestions_NonSecureContextWithHttpBadSwitchOn) {
1609 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
Mathieu 2016/11/07 14:32:27 Make this a function in the AutofillManagerTest cl
lshang 2016/11/08 06:00:58 Done.
1610 security_state::switches::kMarkHttpAs,
1611 security_state::switches::
1612 kMarkHttpWithPasswordsOrCcWithChipAndFormWarning);
1613
1614 // Set up our form data.
1615 FormData form;
1616 CreateTestCreditCardFormData(&form, /* is_https */ false, false);
1617 std::vector<FormData> forms(1, form);
1618 FormsSeen(forms);
1619
1620 const FormFieldData& field = form.fields[0];
1621 GetAutofillSuggestions(form, field);
1622
1623 // Test that we sent the right values to the external delegate.
1624 external_delegate_->CheckSuggestions(
1625 kDefaultPageID,
1626 Suggestion(l10n_util::GetStringUTF8(
1627 IDS_AUTOFILL_CREDIT_CARD_HTTP_WARNING_MESSAGE),
1628 "", "", -1),
1629 Suggestion(
1630 l10n_util::GetStringUTF8(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
1631 "", "", -1));
1632
1633 // Clear the test credit cards and try again -- we shouldn't return a warning.
1634 personal_data_.ClearCreditCards();
1635 GetAutofillSuggestions(form, field);
1636 // Autocomplete suggestions are queried, but not Autofill.
1637 EXPECT_FALSE(external_delegate_->on_suggestions_returned_seen());
1638 }
1639
1640 // Test that we don't show the extra "Payment not secure" warning when the page
1641 // and the form target URL are secure, even when the switch is on.
1642 TEST_F(AutofillManagerTest,
1643 GetCreditCardSuggestions_SecureContextWithHttpBadSwitchOn) {
1644 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
1645 security_state::switches::kMarkHttpAs,
1646 security_state::switches::
1647 kMarkHttpWithPasswordsOrCcWithChipAndFormWarning);
1648
1649 // Set up our form data.
1650 FormData form;
1651 CreateTestCreditCardFormData(&form, /* is_https */ true, false);
1652 std::vector<FormData> forms(1, form);
1653 FormsSeen(forms);
1654
1655 FormFieldData field = form.fields[1];
1656 GetAutofillSuggestions(form, field);
1657
1658 // Test that we sent the right values to the external delegate.
1659 external_delegate_->CheckSuggestions(
1660 kDefaultPageID, Suggestion("Visa\xC2\xA0\xE2\x8B\xAF"
1661 "3456",
1662 "04/99", kVisaCard,
1663 autofill_manager_->GetPackedCreditCardID(4)),
1664 Suggestion("MasterCard\xC2\xA0\xE2\x8B\xAF"
1665 "8765",
1666 "10/98", kMasterCard,
1667 autofill_manager_->GetPackedCreditCardID(5)));
1668 }
1669
1604 // Test that we will eventually return the credit card signin promo when there 1670 // Test that we will eventually return the credit card signin promo when there
1605 // are no credit card suggestions and the promo is active. See the tests in 1671 // are no credit card suggestions and the promo is active. See the tests in
1606 // AutofillExternalDelegateTest that test whether the promo is added. 1672 // AutofillExternalDelegateTest that test whether the promo is added.
1607 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_OnlySigninPromo) { 1673 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_OnlySigninPromo) {
1608 // Enable the signin promo feature with no impression limit. 1674 // Enable the signin promo feature with no impression limit.
1609 EnableCreditCardSigninPromoFeatureWithLimit(0); 1675 EnableCreditCardSigninPromoFeatureWithLimit(0);
1610 1676
1611 // Make sure there are no credit cards. 1677 // Make sure there are no credit cards.
1612 personal_data_.ClearCreditCards(); 1678 personal_data_.ClearCreditCards();
1613 1679
(...skipping 3779 matching lines...) Expand 10 before | Expand all | Expand 10 after
5393 5459
5394 // The driver should always be notified. 5460 // The driver should always be notified.
5395 for (const FormFieldData& field : form.fields) { 5461 for (const FormFieldData& field : form.fields) {
5396 GetAutofillSuggestions(form, field); 5462 GetAutofillSuggestions(form, field);
5397 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form()); 5463 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form());
5398 autofill_driver_->ClearDidInteractWithCreditCardForm(); 5464 autofill_driver_->ClearDidInteractWithCreditCardForm();
5399 } 5465 }
5400 } 5466 }
5401 5467
5402 } // namespace autofill 5468 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698