| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 " <SELECT id='select-unchanged'>" | 83 " <SELECT id='select-unchanged'>" |
| 84 " <OPTION value='CA' selected>California</OPTION>" | 84 " <OPTION value='CA' selected>California</OPTION>" |
| 85 " <OPTION value='TX'>Texas</OPTION>" | 85 " <OPTION value='TX'>Texas</OPTION>" |
| 86 " </SELECT>" | 86 " </SELECT>" |
| 87 " <TEXTAREA id='textarea'></TEXTAREA>" | 87 " <TEXTAREA id='textarea'></TEXTAREA>" |
| 88 " <TEXTAREA id='textarea-nonempty'>Go away!</TEXTAREA>" | 88 " <TEXTAREA id='textarea-nonempty'>Go away!</TEXTAREA>" |
| 89 " <INPUT type='submit' name='reply-send' value='Send'/>" | 89 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 90 "</FORM>"; | 90 "</FORM>"; |
| 91 | 91 |
| 92 const char kUnownedFormHtml[] = | 92 const char kUnownedFormHtml[] = |
| 93 "<HEAD><TITLE>enter shipping info</TITLE></HEAD>" |
| 93 "<INPUT type='text' id='firstname'/>" | 94 "<INPUT type='text' id='firstname'/>" |
| 94 "<INPUT type='text' id='lastname'/>" | 95 "<INPUT type='text' id='lastname'/>" |
| 95 "<INPUT type='hidden' id='imhidden'/>" | 96 "<INPUT type='hidden' id='imhidden'/>" |
| 96 "<INPUT type='text' id='notempty' value='Hi'/>" | 97 "<INPUT type='text' id='notempty' value='Hi'/>" |
| 97 "<INPUT type='text' autocomplete='off' id='noautocomplete'/>" | 98 "<INPUT type='text' autocomplete='off' id='noautocomplete'/>" |
| 98 "<INPUT type='text' disabled='disabled' id='notenabled'/>" | 99 "<INPUT type='text' disabled='disabled' id='notenabled'/>" |
| 99 "<INPUT type='text' readonly id='readonly'/>" | 100 "<INPUT type='text' readonly id='readonly'/>" |
| 100 "<INPUT type='text' style='visibility: hidden'" | 101 "<INPUT type='text' style='visibility: hidden'" |
| 101 " id='invisible'/>" | 102 " id='invisible'/>" |
| 102 "<INPUT type='text' style='display: none' id='displaynone'/>" | 103 "<INPUT type='text' style='display: none' id='displaynone'/>" |
| (...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 | 1031 |
| 1031 // Verify that the auto-filled attribute has been turned off. | 1032 // Verify that the auto-filled attribute has been turned off. |
| 1032 EXPECT_FALSE(firstname.isAutofilled()); | 1033 EXPECT_FALSE(firstname.isAutofilled()); |
| 1033 | 1034 |
| 1034 // Verify the form is cleared. | 1035 // Verify the form is cleared. |
| 1035 FormData form; | 1036 FormData form; |
| 1036 FormFieldData field; | 1037 FormFieldData field; |
| 1037 EXPECT_TRUE( | 1038 EXPECT_TRUE( |
| 1038 FindFormAndFieldForFormControlElement(firstname, &form, &field)); | 1039 FindFormAndFieldForFormControlElement(firstname, &form, &field)); |
| 1039 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 1040 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 1041 EXPECT_FALSE(form.origin.is_empty()); |
| 1040 if (!unowned) { | 1042 if (!unowned) { |
| 1041 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 1043 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 1042 EXPECT_EQ(GURL("http://buh.com"), form.action); | 1044 EXPECT_EQ(GURL("http://buh.com"), form.action); |
| 1043 } | 1045 } |
| 1044 | 1046 |
| 1045 const std::vector<FormFieldData>& fields = form.fields; | 1047 const std::vector<FormFieldData>& fields = form.fields; |
| 1046 ASSERT_EQ(9U, fields.size()); | 1048 ASSERT_EQ(9U, fields.size()); |
| 1047 | 1049 |
| 1048 FormFieldData expected; | 1050 FormFieldData expected; |
| 1049 expected.form_control_type = "text"; | 1051 expected.form_control_type = "text"; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 | 1126 |
| 1125 // Verify that the auto-filled attribute has been turned off. | 1127 // Verify that the auto-filled attribute has been turned off. |
| 1126 EXPECT_FALSE(firstname.isAutofilled()); | 1128 EXPECT_FALSE(firstname.isAutofilled()); |
| 1127 | 1129 |
| 1128 // Verify the form is cleared. | 1130 // Verify the form is cleared. |
| 1129 FormData form; | 1131 FormData form; |
| 1130 FormFieldData field; | 1132 FormFieldData field; |
| 1131 EXPECT_TRUE( | 1133 EXPECT_TRUE( |
| 1132 FindFormAndFieldForFormControlElement(firstname, &form, &field)); | 1134 FindFormAndFieldForFormControlElement(firstname, &form, &field)); |
| 1133 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 1135 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 1136 EXPECT_FALSE(form.origin.is_empty()); |
| 1134 if (!unowned) { | 1137 if (!unowned) { |
| 1135 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 1138 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 1136 EXPECT_EQ(GURL("http://buh.com"), form.action); | 1139 EXPECT_EQ(GURL("http://buh.com"), form.action); |
| 1137 } | 1140 } |
| 1138 | 1141 |
| 1139 const std::vector<FormFieldData>& fields = form.fields; | 1142 const std::vector<FormFieldData>& fields = form.fields; |
| 1140 ASSERT_EQ(3U, fields.size()); | 1143 ASSERT_EQ(3U, fields.size()); |
| 1141 | 1144 |
| 1142 FormFieldData expected; | 1145 FormFieldData expected; |
| 1143 | 1146 |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 | 1914 |
| 1912 FormData form; | 1915 FormData form; |
| 1913 FormFieldData field; | 1916 FormFieldData field; |
| 1914 EXPECT_TRUE(WebFormElementToFormData(forms[0], | 1917 EXPECT_TRUE(WebFormElementToFormData(forms[0], |
| 1915 input_element, | 1918 input_element, |
| 1916 EXTRACT_VALUE, | 1919 EXTRACT_VALUE, |
| 1917 &form, | 1920 &form, |
| 1918 &field)); | 1921 &field)); |
| 1919 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 1922 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 1920 EXPECT_EQ(GURL(frame->document().url()), form.origin); | 1923 EXPECT_EQ(GURL(frame->document().url()), form.origin); |
| 1924 EXPECT_FALSE(form.origin.is_empty()); |
| 1921 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 1925 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 1922 | 1926 |
| 1923 const std::vector<FormFieldData>& fields = form.fields; | 1927 const std::vector<FormFieldData>& fields = form.fields; |
| 1924 ASSERT_EQ(6U, fields.size()); | 1928 ASSERT_EQ(6U, fields.size()); |
| 1925 | 1929 |
| 1926 FormFieldData expected; | 1930 FormFieldData expected; |
| 1927 expected.name = ASCIIToUTF16("firstname"); | 1931 expected.name = ASCIIToUTF16("firstname"); |
| 1928 expected.value = ASCIIToUTF16("John"); | 1932 expected.value = ASCIIToUTF16("John"); |
| 1929 expected.label = ASCIIToUTF16("First name:"); | 1933 expected.label = ASCIIToUTF16("First name:"); |
| 1930 expected.form_control_type = "text"; | 1934 expected.form_control_type = "text"; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 ASSERT_NE(nullptr, web_frame); | 2027 ASSERT_NE(nullptr, web_frame); |
| 2024 | 2028 |
| 2025 FormCache form_cache(*web_frame); | 2029 FormCache form_cache(*web_frame); |
| 2026 std::vector<FormData> forms = form_cache.ExtractNewForms(); | 2030 std::vector<FormData> forms = form_cache.ExtractNewForms(); |
| 2027 ASSERT_EQ(2U, forms.size()); | 2031 ASSERT_EQ(2U, forms.size()); |
| 2028 | 2032 |
| 2029 // First form. | 2033 // First form. |
| 2030 const FormData& form = forms[0]; | 2034 const FormData& form = forms[0]; |
| 2031 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 2035 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 2032 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2036 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 2037 EXPECT_FALSE(form.origin.is_empty()); |
| 2033 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 2038 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 2034 | 2039 |
| 2035 const std::vector<FormFieldData>& fields = form.fields; | 2040 const std::vector<FormFieldData>& fields = form.fields; |
| 2036 ASSERT_EQ(3U, fields.size()); | 2041 ASSERT_EQ(3U, fields.size()); |
| 2037 | 2042 |
| 2038 FormFieldData expected; | 2043 FormFieldData expected; |
| 2039 expected.form_control_type = "text"; | 2044 expected.form_control_type = "text"; |
| 2040 expected.max_length = WebInputElement::defaultMaxLength(); | 2045 expected.max_length = WebInputElement::defaultMaxLength(); |
| 2041 | 2046 |
| 2042 expected.name = ASCIIToUTF16("firstname"); | 2047 expected.name = ASCIIToUTF16("firstname"); |
| 2043 expected.value = ASCIIToUTF16("John"); | 2048 expected.value = ASCIIToUTF16("John"); |
| 2044 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); | 2049 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); |
| 2045 | 2050 |
| 2046 expected.name = ASCIIToUTF16("lastname"); | 2051 expected.name = ASCIIToUTF16("lastname"); |
| 2047 expected.value = ASCIIToUTF16("Smith"); | 2052 expected.value = ASCIIToUTF16("Smith"); |
| 2048 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 2053 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 2049 | 2054 |
| 2050 expected.name = ASCIIToUTF16("email"); | 2055 expected.name = ASCIIToUTF16("email"); |
| 2051 expected.value = ASCIIToUTF16("john@example.com"); | 2056 expected.value = ASCIIToUTF16("john@example.com"); |
| 2052 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2057 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 2053 | 2058 |
| 2054 // Second form. | 2059 // Second form. |
| 2055 const FormData& form2 = forms[1]; | 2060 const FormData& form2 = forms[1]; |
| 2056 EXPECT_EQ(ASCIIToUTF16("TestForm2"), form2.name); | 2061 EXPECT_EQ(ASCIIToUTF16("TestForm2"), form2.name); |
| 2057 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2062 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
| 2063 EXPECT_FALSE(form.origin.is_empty()); |
| 2058 EXPECT_EQ(GURL("http://zoo.com"), form2.action); | 2064 EXPECT_EQ(GURL("http://zoo.com"), form2.action); |
| 2059 | 2065 |
| 2060 const std::vector<FormFieldData>& fields2 = form2.fields; | 2066 const std::vector<FormFieldData>& fields2 = form2.fields; |
| 2061 ASSERT_EQ(3U, fields2.size()); | 2067 ASSERT_EQ(3U, fields2.size()); |
| 2062 | 2068 |
| 2063 expected.name = ASCIIToUTF16("firstname"); | 2069 expected.name = ASCIIToUTF16("firstname"); |
| 2064 expected.value = ASCIIToUTF16("Jack"); | 2070 expected.value = ASCIIToUTF16("Jack"); |
| 2065 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 2071 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| 2066 | 2072 |
| 2067 expected.name = ASCIIToUTF16("lastname"); | 2073 expected.name = ASCIIToUTF16("lastname"); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 " <INPUT type='text' id='email' value='john@example.com'" | 2276 " <INPUT type='text' id='email' value='john@example.com'" |
| 2271 "autocomplete='off' />" | 2277 "autocomplete='off' />" |
| 2272 " <INPUT type='text' id='phone' value='1.800.555.1234'/>" | 2278 " <INPUT type='text' id='phone' value='1.800.555.1234'/>" |
| 2273 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2279 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2274 "</FORM>", | 2280 "</FORM>", |
| 2275 false); | 2281 false); |
| 2276 } | 2282 } |
| 2277 | 2283 |
| 2278 TEST_F(FormAutofillTest, FindFormForInputElementForUnownedForm) { | 2284 TEST_F(FormAutofillTest, FindFormForInputElementForUnownedForm) { |
| 2279 TestFindFormForInputElement( | 2285 TestFindFormForInputElement( |
| 2286 "<HEAD><TITLE>delivery recipient</TITLE></HEAD>" |
| 2280 "<INPUT type='text' id='firstname' value='John'/>" | 2287 "<INPUT type='text' id='firstname' value='John'/>" |
| 2281 "<INPUT type='text' id='lastname' value='Smith'/>" | 2288 "<INPUT type='text' id='lastname' value='Smith'/>" |
| 2282 "<INPUT type='text' id='email' value='john@example.com'" | 2289 "<INPUT type='text' id='email' value='john@example.com'" |
| 2283 "autocomplete='off' />" | 2290 "autocomplete='off' />" |
| 2284 "<INPUT type='text' id='phone' value='1.800.555.1234'/>" | 2291 "<INPUT type='text' id='phone' value='1.800.555.1234'/>" |
| 2285 "<INPUT type='submit' name='reply-send' value='Send'/>", | 2292 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 2286 true); | 2293 true); |
| 2287 } | 2294 } |
| 2288 | 2295 |
| 2289 TEST_F(FormAutofillTest, FindFormForTextAreaElement) { | 2296 TEST_F(FormAutofillTest, FindFormForTextAreaElement) { |
| 2290 TestFindFormForTextAreaElement( | 2297 TestFindFormForTextAreaElement( |
| 2291 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 2298 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 2292 " <INPUT type='text' id='firstname' value='John'/>" | 2299 " <INPUT type='text' id='firstname' value='John'/>" |
| 2293 " <INPUT type='text' id='lastname' value='Smith'/>" | 2300 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 2294 " <INPUT type='text' id='email' value='john@example.com'" | 2301 " <INPUT type='text' id='email' value='john@example.com'" |
| 2295 "autocomplete='off' />" | 2302 "autocomplete='off' />" |
| 2296 " <TEXTAREA id='street-address'>" | 2303 " <TEXTAREA id='street-address'>" |
| 2297 "123 Fantasy Ln. " | 2304 "123 Fantasy Ln. " |
| 2298 "Apt. 42" | 2305 "Apt. 42" |
| 2299 "</TEXTAREA>" | 2306 "</TEXTAREA>" |
| 2300 " <INPUT type='submit' name='reply-send' value='Send'/>" | 2307 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 2301 "</FORM>", | 2308 "</FORM>", |
| 2302 false); | 2309 false); |
| 2303 } | 2310 } |
| 2304 | 2311 |
| 2305 TEST_F(FormAutofillTest, FindFormForTextAreaElementForUnownedForm) { | 2312 TEST_F(FormAutofillTest, FindFormForTextAreaElementForUnownedForm) { |
| 2306 TestFindFormForTextAreaElement( | 2313 TestFindFormForTextAreaElement( |
| 2314 "<HEAD><TITLE>delivery address</TITLE></HEAD>" |
| 2307 "<INPUT type='text' id='firstname' value='John'/>" | 2315 "<INPUT type='text' id='firstname' value='John'/>" |
| 2308 "<INPUT type='text' id='lastname' value='Smith'/>" | 2316 "<INPUT type='text' id='lastname' value='Smith'/>" |
| 2309 "<INPUT type='text' id='email' value='john@example.com'" | 2317 "<INPUT type='text' id='email' value='john@example.com'" |
| 2310 "autocomplete='off' />" | 2318 "autocomplete='off' />" |
| 2311 "<TEXTAREA id='street-address'>" | 2319 "<TEXTAREA id='street-address'>" |
| 2312 "123 Fantasy Ln. " | 2320 "123 Fantasy Ln. " |
| 2313 "Apt. 42" | 2321 "Apt. 42" |
| 2314 "</TEXTAREA>" | 2322 "</TEXTAREA>" |
| 2315 "<INPUT type='submit' name='reply-send' value='Send'/>", | 2323 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 2316 true); | 2324 true); |
| (...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 " <INPUT type='text' id='firstname' maxlength='5'/>" | 3372 " <INPUT type='text' id='firstname' maxlength='5'/>" |
| 3365 " <INPUT type='text' id='lastname' maxlength='7'/>" | 3373 " <INPUT type='text' id='lastname' maxlength='7'/>" |
| 3366 " <INPUT type='text' id='email' maxlength='9'/>" | 3374 " <INPUT type='text' id='email' maxlength='9'/>" |
| 3367 " <INPUT type='submit' name='reply-send' value='Send'/>" | 3375 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 3368 "</FORM>", | 3376 "</FORM>", |
| 3369 false); | 3377 false); |
| 3370 } | 3378 } |
| 3371 | 3379 |
| 3372 TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) { | 3380 TEST_F(FormAutofillTest, FillFormMaxLengthForUnownedForm) { |
| 3373 TestFillFormMaxLength( | 3381 TestFillFormMaxLength( |
| 3382 "<HEAD><TITLE>delivery recipient info</TITLE></HEAD>" |
| 3374 "<INPUT type='text' id='firstname' maxlength='5'/>" | 3383 "<INPUT type='text' id='firstname' maxlength='5'/>" |
| 3375 "<INPUT type='text' id='lastname' maxlength='7'/>" | 3384 "<INPUT type='text' id='lastname' maxlength='7'/>" |
| 3376 "<INPUT type='text' id='email' maxlength='9'/>" | 3385 "<INPUT type='text' id='email' maxlength='9'/>" |
| 3377 "<INPUT type='submit' name='reply-send' value='Send'/>", | 3386 "<INPUT type='submit' name='reply-send' value='Send'/>", |
| 3378 true); | 3387 true); |
| 3379 } | 3388 } |
| 3380 | 3389 |
| 3381 // This test uses negative values of the maxlength attribute for input elements. | 3390 // This test uses negative values of the maxlength attribute for input elements. |
| 3382 // In this case, the maxlength of the input elements is set to the default | 3391 // In this case, the maxlength of the input elements is set to the default |
| 3383 // maxlength (defined in WebKit.) | 3392 // maxlength (defined in WebKit.) |
| 3384 TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { | 3393 TEST_F(FormAutofillTest, FillFormNegativeMaxLength) { |
| 3385 TestFillFormNegativeMaxLength( | 3394 TestFillFormNegativeMaxLength( |
| 3395 "<HEAD><TITLE>delivery recipient info</TITLE></HEAD>" |
| 3386 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3396 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3387 " <INPUT type='text' id='firstname' maxlength='-1'/>" | 3397 " <INPUT type='text' id='firstname' maxlength='-1'/>" |
| 3388 " <INPUT type='text' id='lastname' maxlength='-10'/>" | 3398 " <INPUT type='text' id='lastname' maxlength='-10'/>" |
| 3389 " <INPUT type='text' id='email' maxlength='-13'/>" | 3399 " <INPUT type='text' id='email' maxlength='-13'/>" |
| 3390 " <INPUT type='submit' name='reply-send' value='Send'/>" | 3400 " <INPUT type='submit' name='reply-send' value='Send'/>" |
| 3391 "</FORM>", | 3401 "</FORM>", |
| 3392 false); | 3402 false); |
| 3393 } | 3403 } |
| 3394 | 3404 |
| 3395 TEST_F(FormAutofillTest, FillFormNegativeMaxLengthForUnownedForm) { | 3405 TEST_F(FormAutofillTest, FillFormNegativeMaxLengthForUnownedForm) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3407 " <INPUT type='text' id='firstname'/>" | 3417 " <INPUT type='text' id='firstname'/>" |
| 3408 " <INPUT type='text' id='lastname'/>" | 3418 " <INPUT type='text' id='lastname'/>" |
| 3409 " <INPUT type='text' id='email'/>" | 3419 " <INPUT type='text' id='email'/>" |
| 3410 " <INPUT type='submit' value='Send'/>" | 3420 " <INPUT type='submit' value='Send'/>" |
| 3411 "</FORM>", | 3421 "</FORM>", |
| 3412 false); | 3422 false); |
| 3413 } | 3423 } |
| 3414 | 3424 |
| 3415 TEST_F(FormAutofillTest, FillFormEmptyNameForUnownedForm) { | 3425 TEST_F(FormAutofillTest, FillFormEmptyNameForUnownedForm) { |
| 3416 TestFillFormEmptyName( | 3426 TestFillFormEmptyName( |
| 3427 "<HEAD><TITLE>delivery recipient info</TITLE></HEAD>" |
| 3417 "<INPUT type='text' id='firstname'/>" | 3428 "<INPUT type='text' id='firstname'/>" |
| 3418 "<INPUT type='text' id='lastname'/>" | 3429 "<INPUT type='text' id='lastname'/>" |
| 3419 "<INPUT type='text' id='email'/>" | 3430 "<INPUT type='text' id='email'/>" |
| 3420 "<INPUT type='submit' value='Send'/>", | 3431 "<INPUT type='submit' value='Send'/>", |
| 3421 true); | 3432 true); |
| 3422 } | 3433 } |
| 3423 | 3434 |
| 3424 TEST_F(FormAutofillTest, FillFormEmptyFormNames) { | 3435 TEST_F(FormAutofillTest, FillFormEmptyFormNames) { |
| 3425 TestFillFormEmptyFormNames( | 3436 TestFillFormEmptyFormNames( |
| 3426 "<FORM action='http://buh.com' method='post'>" | 3437 "<FORM action='http://buh.com' method='post'>" |
| 3427 " <INPUT type='text' id='firstname'/>" | 3438 " <INPUT type='text' id='firstname'/>" |
| 3428 " <INPUT type='text' id='middlename'/>" | 3439 " <INPUT type='text' id='middlename'/>" |
| 3429 " <INPUT type='text' id='lastname'/>" | 3440 " <INPUT type='text' id='lastname'/>" |
| 3430 " <INPUT type='submit' value='Send'/>" | 3441 " <INPUT type='submit' value='Send'/>" |
| 3431 "</FORM>" | 3442 "</FORM>" |
| 3432 "<FORM action='http://abc.com' method='post'>" | 3443 "<FORM action='http://abc.com' method='post'>" |
| 3433 " <INPUT type='text' id='apple'/>" | 3444 " <INPUT type='text' id='apple'/>" |
| 3434 " <INPUT type='text' id='banana'/>" | 3445 " <INPUT type='text' id='banana'/>" |
| 3435 " <INPUT type='text' id='cantelope'/>" | 3446 " <INPUT type='text' id='cantelope'/>" |
| 3436 " <INPUT type='submit' value='Send'/>" | 3447 " <INPUT type='submit' value='Send'/>" |
| 3437 "</FORM>", | 3448 "</FORM>", |
| 3438 false); | 3449 false); |
| 3439 } | 3450 } |
| 3440 | 3451 |
| 3441 TEST_F(FormAutofillTest, FillFormEmptyFormNamesForUnownedForm) { | 3452 TEST_F(FormAutofillTest, FillFormEmptyFormNamesForUnownedForm) { |
| 3442 TestFillFormEmptyFormNames( | 3453 TestFillFormEmptyFormNames( |
| 3454 "<HEAD><TITLE>enter delivery preferences</TITLE></HEAD>" |
| 3443 "<INPUT type='text' id='firstname'/>" | 3455 "<INPUT type='text' id='firstname'/>" |
| 3444 "<INPUT type='text' id='middlename'/>" | 3456 "<INPUT type='text' id='middlename'/>" |
| 3445 "<INPUT type='text' id='lastname'/>" | 3457 "<INPUT type='text' id='lastname'/>" |
| 3446 "<INPUT type='text' id='apple'/>" | 3458 "<INPUT type='text' id='apple'/>" |
| 3447 "<INPUT type='text' id='banana'/>" | 3459 "<INPUT type='text' id='banana'/>" |
| 3448 "<INPUT type='text' id='cantelope'/>" | 3460 "<INPUT type='text' id='cantelope'/>" |
| 3449 "<INPUT type='submit' value='Send'/>", | 3461 "<INPUT type='submit' value='Send'/>", |
| 3450 true); | 3462 true); |
| 3451 } | 3463 } |
| 3452 | 3464 |
| 3453 TEST_F(FormAutofillTest, ThreePartPhone) { | 3465 TEST_F(FormAutofillTest, ThreePartPhone) { |
| 3454 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" | 3466 LoadHTML("<FORM name='TestForm' action='http://cnn.com' method='post'>" |
| 3455 " Phone:" | 3467 " Phone:" |
| 3456 " <input type='text' name='dayphone1'>" | 3468 " <input type='text' name='dayphone1'>" |
| 3457 " -" | 3469 " -" |
| 3458 " <input type='text' name='dayphone2'>" | 3470 " <input type='text' name='dayphone2'>" |
| 3459 " -" | 3471 " -" |
| 3460 " <input type='text' name='dayphone3'>" | 3472 " <input type='text' name='dayphone3'>" |
| 3461 " ext.:" | 3473 " ext.:" |
| 3462 " <input type='text' name='dayphone4'>" | 3474 " <input type='text' name='dayphone4'>" |
| 3463 " <input type='submit' name='reply-send' value='Send'>" | 3475 " <input type='submit' name='reply-send' value='Send'>" |
| 3464 "</FORM>"); | 3476 "</FORM>"); |
| 3465 | 3477 |
| 3466 | |
| 3467 WebFrame* frame = GetMainFrame(); | 3478 WebFrame* frame = GetMainFrame(); |
| 3468 ASSERT_NE(nullptr, frame); | 3479 ASSERT_NE(nullptr, frame); |
| 3469 | 3480 |
| 3470 WebVector<WebFormElement> forms; | 3481 WebVector<WebFormElement> forms; |
| 3471 frame->document().forms(forms); | 3482 frame->document().forms(forms); |
| 3472 ASSERT_EQ(1U, forms.size()); | 3483 ASSERT_EQ(1U, forms.size()); |
| 3473 | 3484 |
| 3474 FormData form; | 3485 FormData form; |
| 3475 EXPECT_TRUE(WebFormElementToFormData(forms[0], | 3486 EXPECT_TRUE(WebFormElementToFormData(forms[0], |
| 3476 WebFormControlElement(), | 3487 WebFormControlElement(), |
| 3477 EXTRACT_VALUE, | 3488 EXTRACT_VALUE, |
| 3478 &form, | 3489 &form, |
| 3479 nullptr)); | 3490 nullptr)); |
| 3480 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 3491 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 3481 EXPECT_EQ(GURL(frame->document().url()), form.origin); | 3492 EXPECT_EQ(GURL(frame->document().url()), form.origin); |
| 3493 EXPECT_FALSE(form.origin.is_empty()); |
| 3482 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 3494 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 3483 | 3495 |
| 3484 const std::vector<FormFieldData>& fields = form.fields; | 3496 const std::vector<FormFieldData>& fields = form.fields; |
| 3485 ASSERT_EQ(4U, fields.size()); | 3497 ASSERT_EQ(4U, fields.size()); |
| 3486 | 3498 |
| 3487 FormFieldData expected; | 3499 FormFieldData expected; |
| 3488 expected.form_control_type = "text"; | 3500 expected.form_control_type = "text"; |
| 3489 expected.max_length = WebInputElement::defaultMaxLength(); | 3501 expected.max_length = WebInputElement::defaultMaxLength(); |
| 3490 | 3502 |
| 3491 expected.label = ASCIIToUTF16("Phone:"); | 3503 expected.label = ASCIIToUTF16("Phone:"); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3586 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3598 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3587 " <INPUT type='text' id='firstname'/>" | 3599 " <INPUT type='text' id='firstname'/>" |
| 3588 " <INPUT type='text' id='lastname'/>" | 3600 " <INPUT type='text' id='lastname'/>" |
| 3589 " <INPUT type='text' id='email'/>" | 3601 " <INPUT type='text' id='email'/>" |
| 3590 " <INPUT type='submit' value='Send'/>" | 3602 " <INPUT type='submit' value='Send'/>" |
| 3591 "</FORM>", | 3603 "</FORM>", |
| 3592 false); | 3604 false); |
| 3593 } | 3605 } |
| 3594 | 3606 |
| 3595 TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) { | 3607 TEST_F(FormAutofillTest, FillFormNonEmptyFieldForUnownedForm) { |
| 3596 TestFillFormNonEmptyField("<INPUT type='text' id='firstname'/>" | 3608 TestFillFormNonEmptyField( |
| 3597 "<INPUT type='text' id='lastname'/>" | 3609 "<HEAD><TITLE>delivery recipient info</TITLE></HEAD>" |
| 3598 "<INPUT type='text' id='email'/>" | 3610 "<INPUT type='text' id='firstname'/>" |
| 3599 "<INPUT type='submit' value='Send'/>", | 3611 "<INPUT type='text' id='lastname'/>" |
| 3600 true); | 3612 "<INPUT type='text' id='email'/>" |
| 3613 "<INPUT type='submit' value='Send'/>", |
| 3614 true); |
| 3601 } | 3615 } |
| 3602 | 3616 |
| 3603 TEST_F(FormAutofillTest, ClearFormWithNode) { | 3617 TEST_F(FormAutofillTest, ClearFormWithNode) { |
| 3604 TestClearFormWithNode( | 3618 TestClearFormWithNode( |
| 3605 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3619 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3606 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3620 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3607 " <INPUT type='text' id='lastname' value='Earp'/>" | 3621 " <INPUT type='text' id='lastname' value='Earp'/>" |
| 3608 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" | 3622 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" |
| 3609 " <INPUT type='text' id='notenabled' disabled='disabled'>" | 3623 " <INPUT type='text' id='notenabled' disabled='disabled'>" |
| 3610 " <INPUT type='month' id='month' value='2012-11'>" | 3624 " <INPUT type='month' id='month' value='2012-11'>" |
| 3611 " <INPUT type='month' id='month-disabled' value='2012-11'" | 3625 " <INPUT type='month' id='month-disabled' value='2012-11'" |
| 3612 " disabled='disabled'>" | 3626 " disabled='disabled'>" |
| 3613 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" | 3627 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" |
| 3614 " <TEXTAREA id='textarea-disabled' disabled='disabled'>" | 3628 " <TEXTAREA id='textarea-disabled' disabled='disabled'>" |
| 3615 " Banana!" | 3629 " Banana!" |
| 3616 " </TEXTAREA>" | 3630 " </TEXTAREA>" |
| 3617 " <TEXTAREA id='textarea-noAC' autocomplete='off'>Carrot?</TEXTAREA>" | 3631 " <TEXTAREA id='textarea-noAC' autocomplete='off'>Carrot?</TEXTAREA>" |
| 3618 " <INPUT type='submit' value='Send'/>" | 3632 " <INPUT type='submit' value='Send'/>" |
| 3619 "</FORM>", | 3633 "</FORM>", |
| 3620 false); | 3634 false); |
| 3621 } | 3635 } |
| 3622 | 3636 |
| 3623 TEST_F(FormAutofillTest, ClearFormWithNodeForUnownedForm) { | 3637 TEST_F(FormAutofillTest, ClearFormWithNodeForUnownedForm) { |
| 3624 TestClearFormWithNode( | 3638 TestClearFormWithNode( |
| 3639 "<HEAD><TITLE>store checkout</TITLE></HEAD>" |
| 3625 " <!-- Indented on purpose //-->" | 3640 " <!-- Indented on purpose //-->" |
| 3626 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3641 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3627 " <INPUT type='text' id='lastname' value='Earp'/>" | 3642 " <INPUT type='text' id='lastname' value='Earp'/>" |
| 3628 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" | 3643 " <INPUT type='text' autocomplete='off' id='noAC' value='one'/>" |
| 3629 " <INPUT type='text' id='notenabled' disabled='disabled'>" | 3644 " <INPUT type='text' id='notenabled' disabled='disabled'>" |
| 3630 " <INPUT type='month' id='month' value='2012-11'>" | 3645 " <INPUT type='month' id='month' value='2012-11'>" |
| 3631 " <INPUT type='month' id='month-disabled' value='2012-11'" | 3646 " <INPUT type='month' id='month-disabled' value='2012-11'" |
| 3632 " disabled='disabled'>" | 3647 " disabled='disabled'>" |
| 3633 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" | 3648 " <TEXTAREA id='textarea'>Apple.</TEXTAREA>" |
| 3634 " <TEXTAREA id='textarea-disabled' disabled='disabled'>" | 3649 " <TEXTAREA id='textarea-disabled' disabled='disabled'>" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3650 " <OPTION>AE</OPTION>" | 3665 " <OPTION>AE</OPTION>" |
| 3651 " <OPTION>AK</OPTION>" | 3666 " <OPTION>AK</OPTION>" |
| 3652 " </SELECT>" | 3667 " </SELECT>" |
| 3653 " <INPUT type='submit' value='Send'/>" | 3668 " <INPUT type='submit' value='Send'/>" |
| 3654 "</FORM>", | 3669 "</FORM>", |
| 3655 false); | 3670 false); |
| 3656 } | 3671 } |
| 3657 | 3672 |
| 3658 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOneForUnownedForm) { | 3673 TEST_F(FormAutofillTest, ClearFormWithNodeContainingSelectOneForUnownedForm) { |
| 3659 TestClearFormWithNodeContainingSelectOne( | 3674 TestClearFormWithNodeContainingSelectOne( |
| 3675 "<HEAD><TITLE>store checkout</TITLE></HEAD>" |
| 3660 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3676 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3661 "<INPUT type='text' id='lastname' value='Earp'/>" | 3677 "<INPUT type='text' id='lastname' value='Earp'/>" |
| 3662 "<SELECT id='state' name='state'>" | 3678 "<SELECT id='state' name='state'>" |
| 3663 " <OPTION selected>?</OPTION>" | 3679 " <OPTION selected>?</OPTION>" |
| 3664 " <OPTION>AA</OPTION>" | 3680 " <OPTION>AA</OPTION>" |
| 3665 " <OPTION>AE</OPTION>" | 3681 " <OPTION>AE</OPTION>" |
| 3666 " <OPTION>AK</OPTION>" | 3682 " <OPTION>AK</OPTION>" |
| 3667 "</SELECT>" | 3683 "</SELECT>" |
| 3668 "<INPUT type='submit' value='Send'/>", | 3684 "<INPUT type='submit' value='Send'/>", |
| 3669 true); | 3685 true); |
| 3670 } | 3686 } |
| 3671 | 3687 |
| 3672 TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { | 3688 TEST_F(FormAutofillTest, ClearPreviewedFormWithElement) { |
| 3673 TestClearPreviewedFormWithElement( | 3689 TestClearPreviewedFormWithElement( |
| 3674 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3690 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3675 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3691 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3676 " <INPUT type='text' id='lastname'/>" | 3692 " <INPUT type='text' id='lastname'/>" |
| 3677 " <INPUT type='text' id='email'/>" | 3693 " <INPUT type='text' id='email'/>" |
| 3678 " <INPUT type='email' id='email2'/>" | 3694 " <INPUT type='email' id='email2'/>" |
| 3679 " <INPUT type='tel' id='phone'/>" | 3695 " <INPUT type='tel' id='phone'/>" |
| 3680 " <INPUT type='submit' value='Send'/>" | 3696 " <INPUT type='submit' value='Send'/>" |
| 3681 "</FORM>"); | 3697 "</FORM>"); |
| 3682 } | 3698 } |
| 3683 | 3699 |
| 3684 TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) { | 3700 TEST_F(FormAutofillTest, ClearPreviewedFormWithElementForUnownedForm) { |
| 3685 TestClearPreviewedFormWithElement( | 3701 TestClearPreviewedFormWithElement( |
| 3702 "<HEAD><TITLE>store checkout</TITLE></HEAD>" |
| 3686 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3703 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3687 "<INPUT type='text' id='lastname'/>" | 3704 "<INPUT type='text' id='lastname'/>" |
| 3688 "<INPUT type='text' id='email'/>" | 3705 "<INPUT type='text' id='email'/>" |
| 3689 "<INPUT type='email' id='email2'/>" | 3706 "<INPUT type='email' id='email2'/>" |
| 3690 "<INPUT type='tel' id='phone'/>" | 3707 "<INPUT type='tel' id='phone'/>" |
| 3691 "<INPUT type='submit' value='Send'/>"); | 3708 "<INPUT type='submit' value='Send'/>"); |
| 3692 } | 3709 } |
| 3693 | 3710 |
| 3694 TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { | 3711 TEST_F(FormAutofillTest, ClearPreviewedFormWithNonEmptyInitiatingNode) { |
| 3695 TestClearPreviewedFormWithNonEmptyInitiatingNode( | 3712 TestClearPreviewedFormWithNonEmptyInitiatingNode( |
| 3696 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3713 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3697 " <INPUT type='text' id='firstname' value='W'/>" | 3714 " <INPUT type='text' id='firstname' value='W'/>" |
| 3698 " <INPUT type='text' id='lastname'/>" | 3715 " <INPUT type='text' id='lastname'/>" |
| 3699 " <INPUT type='text' id='email'/>" | 3716 " <INPUT type='text' id='email'/>" |
| 3700 " <INPUT type='email' id='email2'/>" | 3717 " <INPUT type='email' id='email2'/>" |
| 3701 " <INPUT type='tel' id='phone'/>" | 3718 " <INPUT type='tel' id='phone'/>" |
| 3702 " <INPUT type='submit' value='Send'/>" | 3719 " <INPUT type='submit' value='Send'/>" |
| 3703 "</FORM>"); | 3720 "</FORM>"); |
| 3704 } | 3721 } |
| 3705 | 3722 |
| 3706 TEST_F(FormAutofillTest, | 3723 TEST_F(FormAutofillTest, |
| 3707 ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { | 3724 ClearPreviewedFormWithNonEmptyInitiatingNodeForUnownedForm) { |
| 3708 TestClearPreviewedFormWithNonEmptyInitiatingNode( | 3725 TestClearPreviewedFormWithNonEmptyInitiatingNode( |
| 3726 "<HEAD><TITLE>shipping details</TITLE></HEAD>" |
| 3709 "<INPUT type='text' id='firstname' value='W'/>" | 3727 "<INPUT type='text' id='firstname' value='W'/>" |
| 3710 "<INPUT type='text' id='lastname'/>" | 3728 "<INPUT type='text' id='lastname'/>" |
| 3711 "<INPUT type='text' id='email'/>" | 3729 "<INPUT type='text' id='email'/>" |
| 3712 "<INPUT type='email' id='email2'/>" | 3730 "<INPUT type='email' id='email2'/>" |
| 3713 "<INPUT type='tel' id='phone'/>" | 3731 "<INPUT type='tel' id='phone'/>" |
| 3714 "<INPUT type='submit' value='Send'/>"); | 3732 "<INPUT type='submit' value='Send'/>"); |
| 3715 } | 3733 } |
| 3716 | 3734 |
| 3717 TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { | 3735 TEST_F(FormAutofillTest, ClearPreviewedFormWithAutofilledInitiatingNode) { |
| 3718 TestClearPreviewedFormWithAutofilledInitiatingNode( | 3736 TestClearPreviewedFormWithAutofilledInitiatingNode( |
| 3719 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3737 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3720 " <INPUT type='text' id='firstname' value='W'/>" | 3738 " <INPUT type='text' id='firstname' value='W'/>" |
| 3721 " <INPUT type='text' id='lastname'/>" | 3739 " <INPUT type='text' id='lastname'/>" |
| 3722 " <INPUT type='text' id='email'/>" | 3740 " <INPUT type='text' id='email'/>" |
| 3723 " <INPUT type='email' id='email2'/>" | 3741 " <INPUT type='email' id='email2'/>" |
| 3724 " <INPUT type='tel' id='phone'/>" | 3742 " <INPUT type='tel' id='phone'/>" |
| 3725 " <INPUT type='submit' value='Send'/>" | 3743 " <INPUT type='submit' value='Send'/>" |
| 3726 "</FORM>"); | 3744 "</FORM>"); |
| 3727 } | 3745 } |
| 3728 | 3746 |
| 3729 TEST_F(FormAutofillTest, | 3747 TEST_F(FormAutofillTest, |
| 3730 ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { | 3748 ClearPreviewedFormWithAutofilledInitiatingNodeForUnownedForm) { |
| 3731 TestClearPreviewedFormWithAutofilledInitiatingNode( | 3749 TestClearPreviewedFormWithAutofilledInitiatingNode( |
| 3750 "<HEAD><TITLE>shipping details</TITLE></HEAD>" |
| 3732 "<INPUT type='text' id='firstname' value='W'/>" | 3751 "<INPUT type='text' id='firstname' value='W'/>" |
| 3733 "<INPUT type='text' id='lastname'/>" | 3752 "<INPUT type='text' id='lastname'/>" |
| 3734 "<INPUT type='text' id='email'/>" | 3753 "<INPUT type='text' id='email'/>" |
| 3735 "<INPUT type='email' id='email2'/>" | 3754 "<INPUT type='email' id='email2'/>" |
| 3736 "<INPUT type='tel' id='phone'/>" | 3755 "<INPUT type='tel' id='phone'/>" |
| 3737 "<INPUT type='submit' value='Send'/>"); | 3756 "<INPUT type='submit' value='Send'/>"); |
| 3738 } | 3757 } |
| 3739 | 3758 |
| 3740 // Autofill's "Clear Form" should clear only autofilled fields | 3759 // Autofill's "Clear Form" should clear only autofilled fields |
| 3741 TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { | 3760 TEST_F(FormAutofillTest, ClearOnlyAutofilledFields) { |
| 3742 TestClearOnlyAutofilledFields( | 3761 TestClearOnlyAutofilledFields( |
| 3743 "<FORM name='TestForm' action='http://buh.com' method='post'>" | 3762 "<FORM name='TestForm' action='http://buh.com' method='post'>" |
| 3744 " <INPUT type='text' id='firstname' value='Wyatt'/>" | 3763 " <INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3745 " <INPUT type='text' id='lastname' value='Earp'/>" | 3764 " <INPUT type='text' id='lastname' value='Earp'/>" |
| 3746 " <INPUT type='email' id='email' value='wyatt@earp.com'/>" | 3765 " <INPUT type='email' id='email' value='wyatt@earp.com'/>" |
| 3747 " <INPUT type='tel' id='phone' value='650-777-9999'/>" | 3766 " <INPUT type='tel' id='phone' value='650-777-9999'/>" |
| 3748 " <INPUT type='submit' value='Send'/>" | 3767 " <INPUT type='submit' value='Send'/>" |
| 3749 "</FORM>"); | 3768 "</FORM>"); |
| 3750 } | 3769 } |
| 3751 | 3770 |
| 3752 TEST_F(FormAutofillTest, ClearOnlyAutofilledFieldsForUnownedForm) { | 3771 TEST_F(FormAutofillTest, ClearOnlyAutofilledFieldsForUnownedForm) { |
| 3753 TestClearOnlyAutofilledFields( | 3772 TestClearOnlyAutofilledFields( |
| 3773 "<HEAD><TITLE>shipping details</TITLE></HEAD>" |
| 3754 "<INPUT type='text' id='firstname' value='Wyatt'/>" | 3774 "<INPUT type='text' id='firstname' value='Wyatt'/>" |
| 3755 "<INPUT type='text' id='lastname' value='Earp'/>" | 3775 "<INPUT type='text' id='lastname' value='Earp'/>" |
| 3756 "<INPUT type='email' id='email' value='wyatt@earp.com'/>" | 3776 "<INPUT type='email' id='email' value='wyatt@earp.com'/>" |
| 3757 "<INPUT type='tel' id='phone' value='650-777-9999'/>" | 3777 "<INPUT type='tel' id='phone' value='650-777-9999'/>" |
| 3758 "<INPUT type='submit' value='Send'/>"); | 3778 "<INPUT type='submit' value='Send'/>"); |
| 3759 } | 3779 } |
| 3760 | 3780 |
| 3761 // If we have multiple labels per id, the labels concatenated into label string. | 3781 // If we have multiple labels per id, the labels concatenated into label string. |
| 3762 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { | 3782 TEST_F(FormAutofillTest, MultipleLabelsPerElement) { |
| 3763 std::vector<base::string16> labels, names, values; | 3783 std::vector<base::string16> labels, names, values; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3906 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3926 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 3907 } | 3927 } |
| 3908 | 3928 |
| 3909 TEST_F(FormAutofillTest, | 3929 TEST_F(FormAutofillTest, |
| 3910 UnownedFormElementsAndFieldSetsToFormDataFieldsets) { | 3930 UnownedFormElementsAndFieldSetsToFormDataFieldsets) { |
| 3911 std::vector<WebElement> fieldsets; | 3931 std::vector<WebElement> fieldsets; |
| 3912 std::vector<WebFormControlElement> control_elements; | 3932 std::vector<WebFormControlElement> control_elements; |
| 3913 | 3933 |
| 3914 const ExtractMask extract_mask = | 3934 const ExtractMask extract_mask = |
| 3915 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 3935 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
| 3916 const GURL dummy_origin("http://www.example.com"); | |
| 3917 | 3936 |
| 3918 LoadHTML("<DIV>" | 3937 LoadHTML("<HEAD><TITLE>delivery info</TITLE></HEAD>" |
| 3938 "<DIV>" |
| 3919 " <FIELDSET>" | 3939 " <FIELDSET>" |
| 3920 " <LABEL for='firstname'>First name:</LABEL>" | 3940 " <LABEL for='firstname'>First name:</LABEL>" |
| 3921 " <LABEL for='lastname'>Last name:</LABEL>" | 3941 " <LABEL for='lastname'>Last name:</LABEL>" |
| 3922 " <INPUT type='text' id='firstname' value='John'/>" | 3942 " <INPUT type='text' id='firstname' value='John'/>" |
| 3923 " <INPUT type='text' id='lastname' value='Smith'/>" | 3943 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 3924 " </FIELDSET>" | 3944 " </FIELDSET>" |
| 3925 " <FIELDSET>" | 3945 " <FIELDSET>" |
| 3926 " <LABEL for='email'>Email:</LABEL>" | 3946 " <LABEL for='email'>Email:</LABEL>" |
| 3927 " <INPUT type='text' id='email' value='john@example.com'/>" | 3947 " <INPUT type='text' id='email' value='john@example.com'/>" |
| 3928 " </FIELDSET>" | 3948 " </FIELDSET>" |
| 3929 "</DIV>"); | 3949 "</DIV>"); |
| 3930 | 3950 |
| 3931 WebFrame* frame = GetMainFrame(); | 3951 WebFrame* frame = GetMainFrame(); |
| 3932 ASSERT_NE(nullptr, frame); | 3952 ASSERT_NE(nullptr, frame); |
| 3933 | 3953 |
| 3934 control_elements = GetUnownedAutofillableFormFieldElements( | 3954 control_elements = GetUnownedAutofillableFormFieldElements( |
| 3935 frame->document().all(), &fieldsets); | 3955 frame->document().all(), &fieldsets); |
| 3936 ASSERT_EQ(3U, control_elements.size()); | 3956 ASSERT_EQ(3U, control_elements.size()); |
| 3937 ASSERT_EQ(2U, fieldsets.size()); | 3957 ASSERT_EQ(2U, fieldsets.size()); |
| 3938 | 3958 |
| 3939 FormData form; | 3959 FormData form; |
| 3940 EXPECT_TRUE(UnownedFormElementsAndFieldSetsToFormData( | 3960 EXPECT_TRUE(UnownedFormElementsAndFieldSetsToFormData( |
| 3941 fieldsets, control_elements, nullptr, dummy_origin, extract_mask, &form, | 3961 fieldsets, control_elements, nullptr, frame->document(), extract_mask, |
| 3942 nullptr)); | 3962 &form, nullptr)); |
| 3943 | 3963 |
| 3944 EXPECT_TRUE(form.name.empty()); | 3964 EXPECT_TRUE(form.name.empty()); |
| 3945 EXPECT_EQ(dummy_origin, form.origin); | 3965 EXPECT_EQ(frame->document().url(), form.origin); |
| 3946 EXPECT_FALSE(form.action.is_valid()); | 3966 EXPECT_FALSE(form.action.is_valid()); |
| 3947 | 3967 |
| 3948 const std::vector<FormFieldData>& fields = form.fields; | 3968 const std::vector<FormFieldData>& fields = form.fields; |
| 3949 ASSERT_EQ(3U, fields.size()); | 3969 ASSERT_EQ(3U, fields.size()); |
| 3950 | 3970 |
| 3951 FormFieldData expected; | 3971 FormFieldData expected; |
| 3952 expected.form_control_type = "text"; | 3972 expected.form_control_type = "text"; |
| 3953 expected.max_length = WebInputElement::defaultMaxLength(); | 3973 expected.max_length = WebInputElement::defaultMaxLength(); |
| 3954 | 3974 |
| 3955 expected.name = ASCIIToUTF16("firstname"); | 3975 expected.name = ASCIIToUTF16("firstname"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3968 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3988 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 3969 } | 3989 } |
| 3970 | 3990 |
| 3971 TEST_F(FormAutofillTest, | 3991 TEST_F(FormAutofillTest, |
| 3972 UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldset) { | 3992 UnownedFormElementsAndFieldSetsToFormDataControlOutsideOfFieldset) { |
| 3973 std::vector<WebElement> fieldsets; | 3993 std::vector<WebElement> fieldsets; |
| 3974 std::vector<WebFormControlElement> control_elements; | 3994 std::vector<WebFormControlElement> control_elements; |
| 3975 | 3995 |
| 3976 const ExtractMask extract_mask = | 3996 const ExtractMask extract_mask = |
| 3977 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 3997 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
| 3978 const GURL dummy_origin("http://www.example.com"); | |
| 3979 | 3998 |
| 3980 LoadHTML("<DIV>" | 3999 LoadHTML("<HEAD><TITLE>shipping details</TITLE></HEAD>" |
| 4000 "<DIV>" |
| 3981 " <FIELDSET>" | 4001 " <FIELDSET>" |
| 3982 " <LABEL for='firstname'>First name:</LABEL>" | 4002 " <LABEL for='firstname'>First name:</LABEL>" |
| 3983 " <LABEL for='lastname'>Last name:</LABEL>" | 4003 " <LABEL for='lastname'>Last name:</LABEL>" |
| 3984 " <INPUT type='text' id='firstname' value='John'/>" | 4004 " <INPUT type='text' id='firstname' value='John'/>" |
| 3985 " <INPUT type='text' id='lastname' value='Smith'/>" | 4005 " <INPUT type='text' id='lastname' value='Smith'/>" |
| 3986 " <LABEL for='email'>Email:</LABEL>" | 4006 " <LABEL for='email'>Email:</LABEL>" |
| 3987 " </FIELDSET>" | 4007 " </FIELDSET>" |
| 3988 " <INPUT type='text' id='email' value='john@example.com'/>" | 4008 " <INPUT type='text' id='email' value='john@example.com'/>" |
| 3989 "</DIV>"); | 4009 "</DIV>"); |
| 3990 | 4010 |
| 3991 WebFrame* frame = GetMainFrame(); | 4011 WebFrame* frame = GetMainFrame(); |
| 3992 ASSERT_NE(nullptr, frame); | 4012 ASSERT_NE(nullptr, frame); |
| 3993 | 4013 |
| 3994 control_elements = GetUnownedAutofillableFormFieldElements( | 4014 control_elements = GetUnownedAutofillableFormFieldElements( |
| 3995 frame->document().all(), &fieldsets); | 4015 frame->document().all(), &fieldsets); |
| 3996 ASSERT_EQ(3U, control_elements.size()); | 4016 ASSERT_EQ(3U, control_elements.size()); |
| 3997 ASSERT_EQ(1U, fieldsets.size()); | 4017 ASSERT_EQ(1U, fieldsets.size()); |
| 3998 | 4018 |
| 3999 FormData form; | 4019 FormData form; |
| 4000 EXPECT_TRUE(UnownedFormElementsAndFieldSetsToFormData( | 4020 EXPECT_TRUE(UnownedFormElementsAndFieldSetsToFormData( |
| 4001 fieldsets, control_elements, nullptr, dummy_origin, extract_mask, &form, | 4021 fieldsets, control_elements, nullptr, frame->document(), extract_mask, |
| 4002 nullptr)); | 4022 &form, nullptr)); |
| 4003 | 4023 |
| 4004 EXPECT_TRUE(form.name.empty()); | 4024 EXPECT_TRUE(form.name.empty()); |
| 4005 EXPECT_EQ(dummy_origin, form.origin); | 4025 EXPECT_EQ(frame->document().url(), form.origin); |
| 4006 EXPECT_FALSE(form.action.is_valid()); | 4026 EXPECT_FALSE(form.action.is_valid()); |
| 4007 | 4027 |
| 4008 const std::vector<FormFieldData>& fields = form.fields; | 4028 const std::vector<FormFieldData>& fields = form.fields; |
| 4009 ASSERT_EQ(3U, fields.size()); | 4029 ASSERT_EQ(3U, fields.size()); |
| 4010 | 4030 |
| 4011 FormFieldData expected; | 4031 FormFieldData expected; |
| 4012 expected.form_control_type = "text"; | 4032 expected.form_control_type = "text"; |
| 4013 expected.max_length = WebInputElement::defaultMaxLength(); | 4033 expected.max_length = WebInputElement::defaultMaxLength(); |
| 4014 | 4034 |
| 4015 expected.name = ASCIIToUTF16("firstname"); | 4035 expected.name = ASCIIToUTF16("firstname"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4027 expected.label = ASCIIToUTF16("Email:"); | 4047 expected.label = ASCIIToUTF16("Email:"); |
| 4028 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 4048 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 4029 } | 4049 } |
| 4030 | 4050 |
| 4031 TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) { | 4051 TEST_F(FormAutofillTest, UnownedFormElementsAndFieldSetsToFormDataWithForm) { |
| 4032 std::vector<WebElement> fieldsets; | 4052 std::vector<WebElement> fieldsets; |
| 4033 std::vector<WebFormControlElement> control_elements; | 4053 std::vector<WebFormControlElement> control_elements; |
| 4034 | 4054 |
| 4035 const ExtractMask extract_mask = | 4055 const ExtractMask extract_mask = |
| 4036 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); | 4056 static_cast<ExtractMask>(EXTRACT_VALUE | EXTRACT_OPTIONS); |
| 4037 const GURL dummy_origin("http://www.example.com"); | |
| 4038 | 4057 |
| 4039 LoadHTML(kFormHtml); | 4058 LoadHTML(kFormHtml); |
| 4040 | 4059 |
| 4041 WebFrame* frame = GetMainFrame(); | 4060 WebFrame* frame = GetMainFrame(); |
| 4042 ASSERT_NE(nullptr, frame); | 4061 ASSERT_NE(nullptr, frame); |
| 4043 | 4062 |
| 4044 control_elements = GetUnownedAutofillableFormFieldElements( | 4063 control_elements = GetUnownedAutofillableFormFieldElements( |
| 4045 frame->document().all(), &fieldsets); | 4064 frame->document().all(), &fieldsets); |
| 4046 ASSERT_TRUE(control_elements.empty()); | 4065 ASSERT_TRUE(control_elements.empty()); |
| 4047 ASSERT_TRUE(fieldsets.empty()); | 4066 ASSERT_TRUE(fieldsets.empty()); |
| 4048 | 4067 |
| 4049 FormData form; | 4068 FormData form; |
| 4050 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( | 4069 EXPECT_FALSE(UnownedFormElementsAndFieldSetsToFormData( |
| 4051 fieldsets, control_elements, nullptr, dummy_origin, extract_mask, &form, | 4070 fieldsets, control_elements, nullptr, frame->document(), extract_mask, |
| 4052 nullptr)); | 4071 &form, nullptr)); |
| 4053 } | 4072 } |
| 4054 | 4073 |
| 4055 } // namespace autofill | 4074 } // namespace autofill |
| OLD | NEW |