| OLD | NEW |
| 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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 FormsSeen(forms); | 1612 FormsSeen(forms); |
| 1613 | 1613 |
| 1614 FormFieldData field = form.fields[1]; | 1614 FormFieldData field = form.fields[1]; |
| 1615 GetAutofillSuggestions(form, field); | 1615 GetAutofillSuggestions(form, field); |
| 1616 | 1616 |
| 1617 // Test that we sent the right values to the external delegate. | 1617 // Test that we sent the right values to the external delegate. |
| 1618 external_delegate_->CheckSuggestions( | 1618 external_delegate_->CheckSuggestions( |
| 1619 kDefaultPageID, | 1619 kDefaultPageID, |
| 1620 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1620 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1621 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1621 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1622 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1622 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1623 "10/98", kMasterCard, | 1623 "10/98", kMasterCard, |
| 1624 autofill_manager_->GetPackedCreditCardID(5))); | 1624 autofill_manager_->GetPackedCreditCardID(5))); |
| 1625 } | 1625 } |
| 1626 | 1626 |
| 1627 // Test that we return all credit card profile suggestions when the triggering | 1627 // Test that we return all credit card profile suggestions when the triggering |
| 1628 // field has whitespace in it. | 1628 // field has whitespace in it. |
| 1629 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_Whitespace) { | 1629 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_Whitespace) { |
| 1630 // Set up our form data. | 1630 // Set up our form data. |
| 1631 FormData form; | 1631 FormData form; |
| 1632 CreateTestCreditCardFormData(&form, true, false); | 1632 CreateTestCreditCardFormData(&form, true, false); |
| 1633 std::vector<FormData> forms(1, form); | 1633 std::vector<FormData> forms(1, form); |
| 1634 FormsSeen(forms); | 1634 FormsSeen(forms); |
| 1635 | 1635 |
| 1636 FormFieldData field = form.fields[1]; | 1636 FormFieldData field = form.fields[1]; |
| 1637 field.value = ASCIIToUTF16(" "); | 1637 field.value = ASCIIToUTF16(" "); |
| 1638 GetAutofillSuggestions(form, field); | 1638 GetAutofillSuggestions(form, field); |
| 1639 | 1639 |
| 1640 // Test that we sent the right values to the external delegate. | 1640 // Test that we sent the right values to the external delegate. |
| 1641 external_delegate_->CheckSuggestions( | 1641 external_delegate_->CheckSuggestions( |
| 1642 kDefaultPageID, | 1642 kDefaultPageID, |
| 1643 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1643 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1644 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1644 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1645 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1645 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1646 "10/98", kMasterCard, | 1646 "10/98", kMasterCard, |
| 1647 autofill_manager_->GetPackedCreditCardID(5))); | 1647 autofill_manager_->GetPackedCreditCardID(5))); |
| 1648 } | 1648 } |
| 1649 | 1649 |
| 1650 // Test that we return all credit card profile suggestions when the triggering | 1650 // Test that we return all credit card profile suggestions when the triggering |
| 1651 // field has stop characters in it, which should be removed. | 1651 // field has stop characters in it, which should be removed. |
| 1652 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_StopCharsOnly) { | 1652 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_StopCharsOnly) { |
| 1653 // Set up our form data. | 1653 // Set up our form data. |
| 1654 FormData form; | 1654 FormData form; |
| 1655 CreateTestCreditCardFormData(&form, true, false); | 1655 CreateTestCreditCardFormData(&form, true, false); |
| 1656 std::vector<FormData> forms(1, form); | 1656 std::vector<FormData> forms(1, form); |
| 1657 FormsSeen(forms); | 1657 FormsSeen(forms); |
| 1658 | 1658 |
| 1659 FormFieldData field = form.fields[1]; | 1659 FormFieldData field = form.fields[1]; |
| 1660 field.value = ASCIIToUTF16("____-____-____-____"); | 1660 field.value = ASCIIToUTF16("____-____-____-____"); |
| 1661 GetAutofillSuggestions(form, field); | 1661 GetAutofillSuggestions(form, field); |
| 1662 | 1662 |
| 1663 // Test that we sent the right values to the external delegate. | 1663 // Test that we sent the right values to the external delegate. |
| 1664 external_delegate_->CheckSuggestions( | 1664 external_delegate_->CheckSuggestions( |
| 1665 kDefaultPageID, | 1665 kDefaultPageID, |
| 1666 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1666 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1667 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1667 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1668 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1668 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1669 "10/98", kMasterCard, | 1669 "10/98", kMasterCard, |
| 1670 autofill_manager_->GetPackedCreditCardID(5))); | 1670 autofill_manager_->GetPackedCreditCardID(5))); |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 // Test that we return all credit card profile suggestions when the triggering | 1673 // Test that we return all credit card profile suggestions when the triggering |
| 1674 // field has stop characters in it and some input. | 1674 // field has stop characters in it and some input. |
| 1675 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_StopCharsWithInput) { | 1675 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_StopCharsWithInput) { |
| 1676 // Add a credit card with particular numbers that we will attempt to recall. | 1676 // Add a credit card with particular numbers that we will attempt to recall. |
| 1677 CreditCard credit_card; | 1677 CreditCard credit_card; |
| 1678 test::SetCreditCardInfo(&credit_card, "John Smith", | 1678 test::SetCreditCardInfo(&credit_card, "John Smith", |
| 1679 "5255667890123123", // Mastercard | 1679 "5255667890123123", // Mastercard |
| 1680 "08", "2017", "1"); | 1680 "08", "2017", "1"); |
| 1681 credit_card.set_guid("00000000-0000-0000-0000-000000000007"); | 1681 credit_card.set_guid("00000000-0000-0000-0000-000000000007"); |
| 1682 autofill_manager_->AddCreditCard(credit_card); | 1682 autofill_manager_->AddCreditCard(credit_card); |
| 1683 | 1683 |
| 1684 // Set up our form data. | 1684 // Set up our form data. |
| 1685 FormData form; | 1685 FormData form; |
| 1686 CreateTestCreditCardFormData(&form, true, false); | 1686 CreateTestCreditCardFormData(&form, true, false); |
| 1687 std::vector<FormData> forms(1, form); | 1687 std::vector<FormData> forms(1, form); |
| 1688 FormsSeen(forms); | 1688 FormsSeen(forms); |
| 1689 | 1689 |
| 1690 FormFieldData field = form.fields[1]; | 1690 FormFieldData field = form.fields[1]; |
| 1691 | 1691 |
| 1692 field.value = ASCIIToUTF16("5255-66__-____-____"); | 1692 field.value = ASCIIToUTF16("5255-66__-____-____"); |
| 1693 GetAutofillSuggestions(form, field); | 1693 GetAutofillSuggestions(form, field); |
| 1694 | 1694 |
| 1695 // Test that we sent the right value to the external delegate. | 1695 // Test that we sent the right value to the external delegate. |
| 1696 external_delegate_->CheckSuggestions( | 1696 external_delegate_->CheckSuggestions( |
| 1697 kDefaultPageID, | 1697 kDefaultPageID, |
| 1698 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "3123", | 1698 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "3123", |
| 1699 "08/17", kMasterCard, | 1699 "08/17", kMasterCard, |
| 1700 autofill_manager_->GetPackedCreditCardID(7))); | 1700 autofill_manager_->GetPackedCreditCardID(7))); |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 // Test that we return only matching credit card profile suggestions when the | 1703 // Test that we return only matching credit card profile suggestions when the |
| 1704 // selected form field has been partially filled out. | 1704 // selected form field has been partially filled out. |
| 1705 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_MatchCharacter) { | 1705 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_MatchCharacter) { |
| 1706 // Set up our form data. | 1706 // Set up our form data. |
| 1707 FormData form; | 1707 FormData form; |
| 1708 CreateTestCreditCardFormData(&form, true, false); | 1708 CreateTestCreditCardFormData(&form, true, false); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1729 std::vector<FormData> forms(1, form); | 1729 std::vector<FormData> forms(1, form); |
| 1730 FormsSeen(forms); | 1730 FormsSeen(forms); |
| 1731 | 1731 |
| 1732 const FormFieldData& field = form.fields[0]; | 1732 const FormFieldData& field = form.fields[0]; |
| 1733 GetAutofillSuggestions(form, field); | 1733 GetAutofillSuggestions(form, field); |
| 1734 | 1734 |
| 1735 #if defined(OS_ANDROID) | 1735 #if defined(OS_ANDROID) |
| 1736 static const std::string kVisaSuggestion = | 1736 static const std::string kVisaSuggestion = |
| 1737 std::string("Visa") + kUTF8MidlineEllipsis + "3456"; | 1737 std::string("Visa") + kUTF8MidlineEllipsis + "3456"; |
| 1738 static const std::string kMcSuggestion = | 1738 static const std::string kMcSuggestion = |
| 1739 std::string("MasterCard") + kUTF8MidlineEllipsis + "8765"; | 1739 std::string("Mastercard") + kUTF8MidlineEllipsis + "8765"; |
| 1740 #else | 1740 #else |
| 1741 static const std::string kVisaSuggestion = "*3456"; | 1741 static const std::string kVisaSuggestion = "*3456"; |
| 1742 static const std::string kMcSuggestion = "*8765"; | 1742 static const std::string kMcSuggestion = "*8765"; |
| 1743 #endif | 1743 #endif |
| 1744 | 1744 |
| 1745 // Test that we sent the right values to the external delegate. | 1745 // Test that we sent the right values to the external delegate. |
| 1746 external_delegate_->CheckSuggestions( | 1746 external_delegate_->CheckSuggestions( |
| 1747 kDefaultPageID, | 1747 kDefaultPageID, |
| 1748 Suggestion("Elvis Presley", kVisaSuggestion, kVisaCard, | 1748 Suggestion("Elvis Presley", kVisaSuggestion, kVisaCard, |
| 1749 autofill_manager_->GetPackedCreditCardID(4)), | 1749 autofill_manager_->GetPackedCreditCardID(4)), |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 FormsSeen(forms); | 1831 FormsSeen(forms); |
| 1832 | 1832 |
| 1833 FormFieldData field = form.fields[1]; | 1833 FormFieldData field = form.fields[1]; |
| 1834 GetAutofillSuggestions(form, field); | 1834 GetAutofillSuggestions(form, field); |
| 1835 | 1835 |
| 1836 // Test that we sent the right values to the external delegate. | 1836 // Test that we sent the right values to the external delegate. |
| 1837 external_delegate_->CheckSuggestions( | 1837 external_delegate_->CheckSuggestions( |
| 1838 kDefaultPageID, | 1838 kDefaultPageID, |
| 1839 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1839 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1840 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1840 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1841 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1841 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1842 "10/98", kMasterCard, | 1842 "10/98", kMasterCard, |
| 1843 autofill_manager_->GetPackedCreditCardID(5))); | 1843 autofill_manager_->GetPackedCreditCardID(5))); |
| 1844 } | 1844 } |
| 1845 | 1845 |
| 1846 // Test that we will eventually return the credit card signin promo when there | 1846 // Test that we will eventually return the credit card signin promo when there |
| 1847 // are no credit card suggestions and the promo is active. See the tests in | 1847 // are no credit card suggestions and the promo is active. See the tests in |
| 1848 // AutofillExternalDelegateTest that test whether the promo is added. | 1848 // AutofillExternalDelegateTest that test whether the promo is added. |
| 1849 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_OnlySigninPromo) { | 1849 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_OnlySigninPromo) { |
| 1850 personal_data_.ClearCreditCards(); | 1850 personal_data_.ClearCreditCards(); |
| 1851 | 1851 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 FormsSeen(forms); | 1916 FormsSeen(forms); |
| 1917 | 1917 |
| 1918 FormFieldData field = form.fields[1]; | 1918 FormFieldData field = form.fields[1]; |
| 1919 GetAutofillSuggestions(form, field); | 1919 GetAutofillSuggestions(form, field); |
| 1920 | 1920 |
| 1921 // Test that we sent the right values to the external delegate. | 1921 // Test that we sent the right values to the external delegate. |
| 1922 external_delegate_->CheckSuggestions( | 1922 external_delegate_->CheckSuggestions( |
| 1923 kDefaultPageID, | 1923 kDefaultPageID, |
| 1924 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1924 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1925 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1925 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1926 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1926 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1927 "10/98", kMasterCard, | 1927 "10/98", kMasterCard, |
| 1928 autofill_manager_->GetPackedCreditCardID(5))); | 1928 autofill_manager_->GetPackedCreditCardID(5))); |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 // Test that we return credit card suggestions for secure pages that have a | 1931 // Test that we return credit card suggestions for secure pages that have a |
| 1932 // form action set to "javascript:something". | 1932 // form action set to "javascript:something". |
| 1933 TEST_F(AutofillManagerTest, | 1933 TEST_F(AutofillManagerTest, |
| 1934 GetCreditCardSuggestions_SecureContext_JavascriptFormAction) { | 1934 GetCreditCardSuggestions_SecureContext_JavascriptFormAction) { |
| 1935 // Set up our form data. | 1935 // Set up our form data. |
| 1936 FormData form; | 1936 FormData form; |
| 1937 CreateTestCreditCardFormData(&form, true, false); | 1937 CreateTestCreditCardFormData(&form, true, false); |
| 1938 // Have the form action be a javascript function (which is a valid URL). | 1938 // Have the form action be a javascript function (which is a valid URL). |
| 1939 form.action = GURL("javascript:alert('Hello');"); | 1939 form.action = GURL("javascript:alert('Hello');"); |
| 1940 std::vector<FormData> forms(1, form); | 1940 std::vector<FormData> forms(1, form); |
| 1941 FormsSeen(forms); | 1941 FormsSeen(forms); |
| 1942 | 1942 |
| 1943 FormFieldData field = form.fields[1]; | 1943 FormFieldData field = form.fields[1]; |
| 1944 GetAutofillSuggestions(form, field); | 1944 GetAutofillSuggestions(form, field); |
| 1945 | 1945 |
| 1946 // Test that we sent the right values to the external delegate. | 1946 // Test that we sent the right values to the external delegate. |
| 1947 external_delegate_->CheckSuggestions( | 1947 external_delegate_->CheckSuggestions( |
| 1948 kDefaultPageID, | 1948 kDefaultPageID, |
| 1949 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1949 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1950 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1950 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1951 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1951 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1952 "10/98", kMasterCard, | 1952 "10/98", kMasterCard, |
| 1953 autofill_manager_->GetPackedCreditCardID(5))); | 1953 autofill_manager_->GetPackedCreditCardID(5))); |
| 1954 } | 1954 } |
| 1955 | 1955 |
| 1956 // Test that we return all credit card suggestions in the case that two cards | 1956 // Test that we return all credit card suggestions in the case that two cards |
| 1957 // have the same obfuscated number. | 1957 // have the same obfuscated number. |
| 1958 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_RepeatedObfuscatedNumber) { | 1958 TEST_F(AutofillManagerTest, GetCreditCardSuggestions_RepeatedObfuscatedNumber) { |
| 1959 // Add a credit card with the same obfuscated number as Elvis's. | 1959 // Add a credit card with the same obfuscated number as Elvis's. |
| 1960 // |credit_card| will be owned by the mock PersonalDataManager. | 1960 // |credit_card| will be owned by the mock PersonalDataManager. |
| 1961 CreditCard credit_card; | 1961 CreditCard credit_card; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1974 FormsSeen(forms); | 1974 FormsSeen(forms); |
| 1975 | 1975 |
| 1976 FormFieldData field = form.fields[1]; | 1976 FormFieldData field = form.fields[1]; |
| 1977 GetAutofillSuggestions(form, field); | 1977 GetAutofillSuggestions(form, field); |
| 1978 | 1978 |
| 1979 // Test that we sent the right values to the external delegate. | 1979 // Test that we sent the right values to the external delegate. |
| 1980 external_delegate_->CheckSuggestions( | 1980 external_delegate_->CheckSuggestions( |
| 1981 kDefaultPageID, | 1981 kDefaultPageID, |
| 1982 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 1982 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 1983 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 1983 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 1984 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 1984 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 1985 "10/98", kMasterCard, | 1985 "10/98", kMasterCard, |
| 1986 autofill_manager_->GetPackedCreditCardID(5)), | 1986 autofill_manager_->GetPackedCreditCardID(5)), |
| 1987 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "3456", | 1987 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "3456", |
| 1988 "05/99", kMasterCard, | 1988 "05/99", kMasterCard, |
| 1989 autofill_manager_->GetPackedCreditCardID(7))); | 1989 autofill_manager_->GetPackedCreditCardID(7))); |
| 1990 } | 1990 } |
| 1991 | 1991 |
| 1992 // Test that we return profile and credit card suggestions for combined forms. | 1992 // Test that we return profile and credit card suggestions for combined forms. |
| 1993 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { | 1993 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { |
| 1994 // Set up our form data. | 1994 // Set up our form data. |
| 1995 FormData form; | 1995 FormData form; |
| 1996 test::CreateTestAddressFormData(&form); | 1996 test::CreateTestAddressFormData(&form); |
| 1997 CreateTestCreditCardFormData(&form, true, false); | 1997 CreateTestCreditCardFormData(&form, true, false); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2008 | 2008 |
| 2009 const int kPageID2 = 2; | 2009 const int kPageID2 = 2; |
| 2010 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); | 2010 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); |
| 2011 GetAutofillSuggestions(kPageID2, form, field); | 2011 GetAutofillSuggestions(kPageID2, form, field); |
| 2012 | 2012 |
| 2013 // Test that we sent the credit card suggestions to the external delegate. | 2013 // Test that we sent the credit card suggestions to the external delegate. |
| 2014 external_delegate_->CheckSuggestions( | 2014 external_delegate_->CheckSuggestions( |
| 2015 kPageID2, | 2015 kPageID2, |
| 2016 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", | 2016 Suggestion(std::string("Visa") + kUTF8MidlineEllipsis + "3456", "04/99", |
| 2017 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), | 2017 kVisaCard, autofill_manager_->GetPackedCreditCardID(4)), |
| 2018 Suggestion(std::string("MasterCard") + kUTF8MidlineEllipsis + "8765", | 2018 Suggestion(std::string("Mastercard") + kUTF8MidlineEllipsis + "8765", |
| 2019 "10/98", kMasterCard, | 2019 "10/98", kMasterCard, |
| 2020 autofill_manager_->GetPackedCreditCardID(5))); | 2020 autofill_manager_->GetPackedCreditCardID(5))); |
| 2021 } | 2021 } |
| 2022 | 2022 |
| 2023 // Test that for non-https forms with both address and credit card fields, we | 2023 // Test that for non-https forms with both address and credit card fields, we |
| 2024 // only return address suggestions. Instead of credit card suggestions, we | 2024 // only return address suggestions. Instead of credit card suggestions, we |
| 2025 // should return a warning explaining that credit card profile suggestions are | 2025 // should return a warning explaining that credit card profile suggestions are |
| 2026 // unavailable when the form is not https. | 2026 // unavailable when the form is not https. |
| 2027 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 2027 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { |
| 2028 // Set up our form data. | 2028 // Set up our form data. |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2709 FormData form; | 2709 FormData form; |
| 2710 form.name = ASCIIToUTF16("MyForm"); | 2710 form.name = ASCIIToUTF16("MyForm"); |
| 2711 form.origin = GURL("https://myform.com/form.html"); | 2711 form.origin = GURL("https://myform.com/form.html"); |
| 2712 form.action = GURL("https://myform.com/submit.html"); | 2712 form.action = GURL("https://myform.com/submit.html"); |
| 2713 | 2713 |
| 2714 // Create a credit card form. | 2714 // Create a credit card form. |
| 2715 FormFieldData field; | 2715 FormFieldData field; |
| 2716 test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field); | 2716 test::CreateTestFormField("Name on Card", "nameoncard", "", "text", &field); |
| 2717 field.autocomplete_attribute = "cc-name"; | 2717 field.autocomplete_attribute = "cc-name"; |
| 2718 form.fields.push_back(field); | 2718 form.fields.push_back(field); |
| 2719 std::vector<const char*> kCreditCardTypes = {"Visa", "Master Card", "AmEx", | 2719 std::vector<const char*> kCreditCardTypes = {"Visa", "Mastercard", "AmEx", |
| 2720 "discover"}; | 2720 "discover"}; |
| 2721 test::CreateTestSelectField("Card Type", "cardtype", "", kCreditCardTypes, | 2721 test::CreateTestSelectField("Card Type", "cardtype", "", kCreditCardTypes, |
| 2722 kCreditCardTypes, 4, &field); | 2722 kCreditCardTypes, 4, &field); |
| 2723 field.autocomplete_attribute = "cc-type"; | 2723 field.autocomplete_attribute = "cc-type"; |
| 2724 form.fields.push_back(field); | 2724 form.fields.push_back(field); |
| 2725 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); | 2725 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); |
| 2726 field.autocomplete_attribute = "cc-number"; | 2726 field.autocomplete_attribute = "cc-number"; |
| 2727 form.fields.push_back(field); | 2727 form.fields.push_back(field); |
| 2728 test::CreateTestFormField("Expiration Month", "ccmonth", "", "text", &field); | 2728 test::CreateTestFormField("Expiration Month", "ccmonth", "", "text", &field); |
| 2729 field.autocomplete_attribute = "cc-exp-month"; | 2729 field.autocomplete_attribute = "cc-exp-month"; |
| (...skipping 4207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6937 | 6937 |
| 6938 // Wait for upload to complete (will check expected types as well). | 6938 // Wait for upload to complete (will check expected types as well). |
| 6939 autofill_manager_->WaitForAsyncUploadProcess(); | 6939 autofill_manager_->WaitForAsyncUploadProcess(); |
| 6940 | 6940 |
| 6941 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6941 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
| 6942 EXPECT_NE(uploaded_available_types.end(), | 6942 EXPECT_NE(uploaded_available_types.end(), |
| 6943 uploaded_available_types.find(autofill::PASSWORD)); | 6943 uploaded_available_types.find(autofill::PASSWORD)); |
| 6944 } | 6944 } |
| 6945 | 6945 |
| 6946 } // namespace autofill | 6946 } // namespace autofill |
| OLD | NEW |