OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 FormData form; | 1986 FormData form; |
1987 form.name = ASCIIToUTF16("MyForm"); | 1987 form.name = ASCIIToUTF16("MyForm"); |
1988 form.method = ASCIIToUTF16("POST"); | 1988 form.method = ASCIIToUTF16("POST"); |
1989 form.origin = GURL("https://myform.com/form.html"); | 1989 form.origin = GURL("https://myform.com/form.html"); |
1990 form.action = GURL("https://myform.com/submit.html"); | 1990 form.action = GURL("https://myform.com/submit.html"); |
1991 form.user_submitted = true; | 1991 form.user_submitted = true; |
1992 | 1992 |
1993 FormFieldData field; | 1993 FormFieldData field; |
1994 | 1994 |
1995 autofill_test::CreateTestFormField("", "country", "", "text", &field); | 1995 autofill_test::CreateTestFormField("", "country", "", "text", &field); |
1996 field.autocomplete_type = ASCIIToUTF16("section-billing country"); | 1996 field.autocomplete_attribute = ASCIIToUTF16("section-billing country"); |
1997 form.fields.push_back(field); | 1997 form.fields.push_back(field); |
1998 | 1998 |
1999 autofill_test::CreateTestFormField("", "firstname", "", "text", &field); | 1999 autofill_test::CreateTestFormField("", "firstname", "", "text", &field); |
2000 field.autocomplete_type = ASCIIToUTF16("given-name"); | 2000 field.autocomplete_attribute = ASCIIToUTF16("given-name"); |
2001 form.fields.push_back(field); | 2001 form.fields.push_back(field); |
2002 | 2002 |
2003 autofill_test::CreateTestFormField("", "lastname", "", "text", &field); | 2003 autofill_test::CreateTestFormField("", "lastname", "", "text", &field); |
2004 field.autocomplete_type = ASCIIToUTF16("surname"); | 2004 field.autocomplete_attribute = ASCIIToUTF16("family-name"); |
2005 form.fields.push_back(field); | 2005 form.fields.push_back(field); |
2006 | 2006 |
2007 autofill_test::CreateTestFormField("", "address", "", "text", &field); | 2007 autofill_test::CreateTestFormField("", "address", "", "text", &field); |
2008 field.autocomplete_type = ASCIIToUTF16("section-billing street-address"); | 2008 field.autocomplete_attribute = ASCIIToUTF16("section-billing street-address"); |
2009 form.fields.push_back(field); | 2009 form.fields.push_back(field); |
2010 | 2010 |
2011 autofill_test::CreateTestFormField("", "city", "", "text", &field); | 2011 autofill_test::CreateTestFormField("", "city", "", "text", &field); |
2012 field.autocomplete_type = ASCIIToUTF16("section-billing locality"); | 2012 field.autocomplete_attribute = ASCIIToUTF16("section-billing locality"); |
2013 form.fields.push_back(field); | 2013 form.fields.push_back(field); |
2014 | 2014 |
2015 autofill_test::CreateTestFormField("", "state", "", "text", &field); | 2015 autofill_test::CreateTestFormField("", "state", "", "text", &field); |
2016 field.autocomplete_type = ASCIIToUTF16("section-billing administrative-area"); | 2016 field.autocomplete_attribute = ASCIIToUTF16("section-billing region"); |
2017 form.fields.push_back(field); | 2017 form.fields.push_back(field); |
2018 | 2018 |
2019 autofill_test::CreateTestFormField("", "zip", "", "text", &field); | 2019 autofill_test::CreateTestFormField("", "zip", "", "text", &field); |
2020 field.autocomplete_type = ASCIIToUTF16("section-billing postal-code"); | 2020 field.autocomplete_attribute = ASCIIToUTF16("section-billing postal-code"); |
2021 form.fields.push_back(field); | 2021 form.fields.push_back(field); |
2022 | 2022 |
2023 autofill_test::CreateTestFormField("", "ccname", "", "text", &field); | 2023 autofill_test::CreateTestFormField("", "ccname", "", "text", &field); |
2024 field.autocomplete_type = ASCIIToUTF16("section-billing cc-full-name"); | 2024 field.autocomplete_attribute = ASCIIToUTF16("section-billing cc-name"); |
2025 form.fields.push_back(field); | 2025 form.fields.push_back(field); |
2026 | 2026 |
2027 autofill_test::CreateTestFormField("", "ccnumber", "", "text", &field); | 2027 autofill_test::CreateTestFormField("", "ccnumber", "", "text", &field); |
2028 field.autocomplete_type = ASCIIToUTF16("section-billing cc-number"); | 2028 field.autocomplete_attribute = ASCIIToUTF16("section-billing cc-number"); |
2029 form.fields.push_back(field); | 2029 form.fields.push_back(field); |
2030 | 2030 |
2031 autofill_test::CreateTestFormField("", "ccexp", "", "text", &field); | 2031 autofill_test::CreateTestFormField("", "ccexp", "", "text", &field); |
2032 field.autocomplete_type = ASCIIToUTF16("section-billing cc-exp"); | 2032 field.autocomplete_attribute = ASCIIToUTF16("section-billing cc-exp"); |
2033 form.fields.push_back(field); | 2033 form.fields.push_back(field); |
2034 | 2034 |
2035 autofill_test::CreateTestFormField("", "email", "", "text", &field); | 2035 autofill_test::CreateTestFormField("", "email", "", "text", &field); |
2036 field.autocomplete_type = ASCIIToUTF16("email"); | 2036 field.autocomplete_attribute = ASCIIToUTF16("email"); |
2037 form.fields.push_back(field); | 2037 form.fields.push_back(field); |
2038 | 2038 |
2039 std::vector<FormData> forms(1, form); | 2039 std::vector<FormData> forms(1, form); |
2040 FormsSeen(forms); | 2040 FormsSeen(forms); |
2041 | 2041 |
2042 // Fill the unnamed section. | 2042 // Fill the unnamed section. |
2043 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); | 2043 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); |
2044 GUIDPair empty(std::string(), 0); | 2044 GUIDPair empty(std::string(), 0); |
2045 FillAutofillFormData(kDefaultPageID, form, form.fields[1], | 2045 FillAutofillFormData(kDefaultPageID, form, form.fields[1], |
2046 PackGUIDs(empty, guid)); | 2046 PackGUIDs(empty, guid)); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 form_with_maxlength.origin = GURL("http://myform.com/phone_form.html"); | 2293 form_with_maxlength.origin = GURL("http://myform.com/phone_form.html"); |
2294 form_with_maxlength.action = GURL("http://myform.com/phone_submit.html"); | 2294 form_with_maxlength.action = GURL("http://myform.com/phone_submit.html"); |
2295 form_with_maxlength.user_submitted = true; | 2295 form_with_maxlength.user_submitted = true; |
2296 FormData form_with_autocompletetype = form_with_maxlength; | 2296 FormData form_with_autocompletetype = form_with_maxlength; |
2297 form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm"); | 2297 form_with_autocompletetype.name = ASCIIToUTF16("MyAutocompletetypePhoneForm"); |
2298 | 2298 |
2299 struct { | 2299 struct { |
2300 const char* label; | 2300 const char* label; |
2301 const char* name; | 2301 const char* name; |
2302 size_t max_length; | 2302 size_t max_length; |
2303 const char* autocomplete_type; | 2303 const char* autocomplete_attribute; |
2304 } test_fields[] = { | 2304 } test_fields[] = { |
2305 { "country code", "country_code", 1, "phone-country-code" }, | 2305 { "country code", "country_code", 1, "tel-country-code" }, |
2306 { "area code", "area_code", 3, "phone-area-code" }, | 2306 { "area code", "area_code", 3, "tel-area-code" }, |
2307 { "phone", "phone_prefix", 3, "phone-local-prefix" }, | 2307 { "phone", "phone_prefix", 3, "tel-local-prefix" }, |
2308 { "-", "phone_suffix", 4, "phone-local-suffix" }, | 2308 { "-", "phone_suffix", 4, "tel-local-suffix" }, |
2309 { "Phone Extension", "ext", 3, "phone-extension" } | 2309 { "Phone Extension", "ext", 3, "tel-extension" } |
2310 }; | 2310 }; |
2311 | 2311 |
2312 FormFieldData field; | 2312 FormFieldData field; |
2313 const size_t default_max_length = field.max_length; | 2313 const size_t default_max_length = field.max_length; |
2314 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_fields); ++i) { | 2314 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_fields); ++i) { |
2315 autofill_test::CreateTestFormField( | 2315 autofill_test::CreateTestFormField( |
2316 test_fields[i].label, test_fields[i].name, "", "text", &field); | 2316 test_fields[i].label, test_fields[i].name, "", "text", &field); |
2317 field.max_length = test_fields[i].max_length; | 2317 field.max_length = test_fields[i].max_length; |
2318 field.autocomplete_type = string16(); | 2318 field.autocomplete_attribute = string16(); |
2319 form_with_maxlength.fields.push_back(field); | 2319 form_with_maxlength.fields.push_back(field); |
2320 | 2320 |
2321 field.max_length = default_max_length; | 2321 field.max_length = default_max_length; |
2322 field.autocomplete_type = ASCIIToUTF16(test_fields[i].autocomplete_type); | 2322 field.autocomplete_attribute = |
| 2323 ASCIIToUTF16(test_fields[i].autocomplete_attribute); |
2323 form_with_autocompletetype.fields.push_back(field); | 2324 form_with_autocompletetype.fields.push_back(field); |
2324 } | 2325 } |
2325 | 2326 |
2326 std::vector<FormData> forms; | 2327 std::vector<FormData> forms; |
2327 forms.push_back(form_with_maxlength); | 2328 forms.push_back(form_with_maxlength); |
2328 forms.push_back(form_with_autocompletetype); | 2329 forms.push_back(form_with_autocompletetype); |
2329 FormsSeen(forms); | 2330 FormsSeen(forms); |
2330 | 2331 |
2331 // We should be able to fill prefix and suffix fields for US numbers. | 2332 // We should be able to fill prefix and suffix fields for US numbers. |
2332 AutofillProfile* work_profile = autofill_manager_->GetProfileWithGUID( | 2333 AutofillProfile* work_profile = autofill_manager_->GetProfileWithGUID( |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3132 AutofillManager* autofill_manager = | 3133 AutofillManager* autofill_manager = |
3133 AutofillManager::FromWebContents(contents); | 3134 AutofillManager::FromWebContents(contents); |
3134 EXPECT_TRUE(autofill_manager->external_delegate()); | 3135 EXPECT_TRUE(autofill_manager->external_delegate()); |
3135 | 3136 |
3136 AutocompleteHistoryManager* autocomplete_history_manager = | 3137 AutocompleteHistoryManager* autocomplete_history_manager = |
3137 AutocompleteHistoryManager::FromWebContents(contents); | 3138 AutocompleteHistoryManager::FromWebContents(contents); |
3138 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); | 3139 EXPECT_TRUE(autocomplete_history_manager->external_delegate()); |
3139 } | 3140 } |
3140 | 3141 |
3141 #endif // OS_ANDROID | 3142 #endif // OS_ANDROID |
OLD | NEW |