| 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/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ASSERT_EQ(labels.size(), values.size()); | 110 ASSERT_EQ(labels.size(), values.size()); |
| 111 ASSERT_EQ(labels.size(), control_types.size()); | 111 ASSERT_EQ(labels.size(), control_types.size()); |
| 112 | 112 |
| 113 LoadHTML(html); | 113 LoadHTML(html); |
| 114 | 114 |
| 115 WebFrame* web_frame = GetMainFrame(); | 115 WebFrame* web_frame = GetMainFrame(); |
| 116 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 116 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 117 | 117 |
| 118 FormCache form_cache; | 118 FormCache form_cache; |
| 119 std::vector<FormData> forms; | 119 std::vector<FormData> forms; |
| 120 form_cache.ExtractNewForms(*web_frame, &forms); | 120 form_cache.ExtractForms(*web_frame, &forms); |
| 121 ASSERT_EQ(1U, forms.size()); | 121 ASSERT_EQ(1U, forms.size()); |
| 122 | 122 |
| 123 const FormData& form = forms[0]; | 123 const FormData& form = forms[0]; |
| 124 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 124 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 125 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 125 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 126 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 126 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 127 | 127 |
| 128 const std::vector<FormFieldData>& fields = form.fields; | 128 const std::vector<FormFieldData>& fields = form.fields; |
| 129 ASSERT_EQ(labels.size(), fields.size()); | 129 ASSERT_EQ(labels.size(), fields.size()); |
| 130 for (size_t i = 0; i < labels.size(); ++i) { | 130 for (size_t i = 0; i < labels.size(); ++i) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 size_t number_of_field_cases, | 170 size_t number_of_field_cases, |
| 171 FillFormFunction fill_form_function, | 171 FillFormFunction fill_form_function, |
| 172 GetValueFunction get_value_function) { | 172 GetValueFunction get_value_function) { |
| 173 LoadHTML(html); | 173 LoadHTML(html); |
| 174 | 174 |
| 175 WebFrame* web_frame = GetMainFrame(); | 175 WebFrame* web_frame = GetMainFrame(); |
| 176 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 176 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 177 | 177 |
| 178 FormCache form_cache; | 178 FormCache form_cache; |
| 179 std::vector<FormData> forms; | 179 std::vector<FormData> forms; |
| 180 form_cache.ExtractNewForms(*web_frame, &forms); | 180 form_cache.ExtractForms(*web_frame, &forms); |
| 181 ASSERT_EQ(1U, forms.size()); | 181 ASSERT_EQ(1U, forms.size()); |
| 182 | 182 |
| 183 // Get the input element we want to find. | 183 // Get the input element we want to find. |
| 184 WebElement element = web_frame->document().getElementById("firstname"); | 184 WebElement element = web_frame->document().getElementById("firstname"); |
| 185 WebInputElement input_element = element.to<WebInputElement>(); | 185 WebInputElement input_element = element.to<WebInputElement>(); |
| 186 | 186 |
| 187 // Find the form that contains the input element. | 187 // Find the form that contains the input element. |
| 188 FormData form_data; | 188 FormData form_data; |
| 189 FormFieldData field; | 189 FormFieldData field; |
| 190 EXPECT_TRUE( | 190 EXPECT_TRUE( |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 " <INPUT type=\"text\" id=\"lastname\" value=\"Adams\"/>" | 798 " <INPUT type=\"text\" id=\"lastname\" value=\"Adams\"/>" |
| 799 " <INPUT type=\"text\" id=\"email\" value=\"jack@example.com\"/>" | 799 " <INPUT type=\"text\" id=\"email\" value=\"jack@example.com\"/>" |
| 800 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 800 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 801 "</FORM>"); | 801 "</FORM>"); |
| 802 | 802 |
| 803 WebFrame* web_frame = GetMainFrame(); | 803 WebFrame* web_frame = GetMainFrame(); |
| 804 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 804 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 805 | 805 |
| 806 FormCache form_cache; | 806 FormCache form_cache; |
| 807 std::vector<FormData> forms; | 807 std::vector<FormData> forms; |
| 808 form_cache.ExtractNewForms(*web_frame, &forms); | 808 form_cache.ExtractForms(*web_frame, &forms); |
| 809 ASSERT_EQ(2U, forms.size()); | 809 ASSERT_EQ(2U, forms.size()); |
| 810 | 810 |
| 811 // First form. | 811 // First form. |
| 812 const FormData& form = forms[0]; | 812 const FormData& form = forms[0]; |
| 813 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 813 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 814 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 814 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 815 EXPECT_EQ(GURL("http://cnn.com"), form.action); | 815 EXPECT_EQ(GURL("http://cnn.com"), form.action); |
| 816 | 816 |
| 817 const std::vector<FormFieldData>& fields = form.fields; | 817 const std::vector<FormFieldData>& fields = form.fields; |
| 818 ASSERT_EQ(3U, fields.size()); | 818 ASSERT_EQ(3U, fields.size()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 848 | 848 |
| 849 expected.name = ASCIIToUTF16("lastname"); | 849 expected.name = ASCIIToUTF16("lastname"); |
| 850 expected.value = ASCIIToUTF16("Adams"); | 850 expected.value = ASCIIToUTF16("Adams"); |
| 851 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | 851 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
| 852 | 852 |
| 853 expected.name = ASCIIToUTF16("email"); | 853 expected.name = ASCIIToUTF16("email"); |
| 854 expected.value = ASCIIToUTF16("jack@example.com"); | 854 expected.value = ASCIIToUTF16("jack@example.com"); |
| 855 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 855 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 856 } | 856 } |
| 857 | 857 |
| 858 TEST_F(FormAutofillTest, OnlyExtractNewForms) { | |
| 859 LoadHTML( | |
| 860 "<FORM id='testform' action='http://cnn.com' method='post'>" | |
| 861 " <INPUT type='text' id='firstname' value='John'/>" | |
| 862 " <INPUT type='text' id='lastname' value='Smith'/>" | |
| 863 " <INPUT type='text' id='email' value='john@example.com'/>" | |
| 864 " <INPUT type='submit' name='reply-send' value='Send'/>" | |
| 865 "</FORM>"); | |
| 866 | |
| 867 WebFrame* web_frame = GetMainFrame(); | |
| 868 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | |
| 869 | |
| 870 FormCache form_cache; | |
| 871 std::vector<FormData> forms; | |
| 872 form_cache.ExtractNewForms(*web_frame, &forms); | |
| 873 ASSERT_EQ(1U, forms.size()); | |
| 874 forms.clear(); | |
| 875 | |
| 876 // Second call should give nothing as there are no new forms. | |
| 877 form_cache.ExtractNewForms(*web_frame, &forms); | |
| 878 ASSERT_EQ(0U, forms.size()); | |
| 879 | |
| 880 // Append to the current form will re-extract. | |
| 881 ExecuteJavaScript( | |
| 882 "var newInput = document.createElement('input');" | |
| 883 "newInput.setAttribute('type', 'text');" | |
| 884 "newInput.setAttribute('id', 'telephone');" | |
| 885 "newInput.value = '12345';" | |
| 886 "document.getElementById('testform').appendChild(newInput);"); | |
| 887 msg_loop_.RunUntilIdle(); | |
| 888 | |
| 889 form_cache.ExtractNewForms(*web_frame, &forms); | |
| 890 ASSERT_EQ(1U, forms.size()); | |
| 891 | |
| 892 const std::vector<FormFieldData>& fields = forms[0].fields; | |
| 893 ASSERT_EQ(4U, fields.size()); | |
| 894 | |
| 895 FormFieldData expected; | |
| 896 expected.form_control_type = "text"; | |
| 897 expected.max_length = WebInputElement::defaultMaxLength(); | |
| 898 | |
| 899 expected.name = ASCIIToUTF16("firstname"); | |
| 900 expected.value = ASCIIToUTF16("John"); | |
| 901 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); | |
| 902 | |
| 903 expected.name = ASCIIToUTF16("lastname"); | |
| 904 expected.value = ASCIIToUTF16("Smith"); | |
| 905 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | |
| 906 | |
| 907 expected.name = ASCIIToUTF16("email"); | |
| 908 expected.value = ASCIIToUTF16("john@example.com"); | |
| 909 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | |
| 910 | |
| 911 expected.name = ASCIIToUTF16("telephone"); | |
| 912 expected.value = ASCIIToUTF16("12345"); | |
| 913 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); | |
| 914 | |
| 915 forms.clear(); | |
| 916 | |
| 917 // Completely new form will also be extracted. | |
| 918 ExecuteJavaScript( | |
| 919 "var newForm=document.createElement('form');" | |
| 920 "newForm.id='new_testform';" | |
| 921 "newForm.action='http://google.com';" | |
| 922 "newForm.method='post';" | |
| 923 "var newFirstname=document.createElement('input');" | |
| 924 "newFirstname.setAttribute('type', 'text');" | |
| 925 "newFirstname.setAttribute('id', 'second_firstname');" | |
| 926 "newFirstname.value = 'Bob';" | |
| 927 "var newLastname=document.createElement('input');" | |
| 928 "newLastname.setAttribute('type', 'text');" | |
| 929 "newLastname.setAttribute('id', 'second_lastname');" | |
| 930 "newLastname.value = 'Hope';" | |
| 931 "var newEmail=document.createElement('input');" | |
| 932 "newEmail.setAttribute('type', 'text');" | |
| 933 "newEmail.setAttribute('id', 'second_email');" | |
| 934 "newEmail.value = 'bobhope@example.com';" | |
| 935 "newForm.appendChild(newFirstname);" | |
| 936 "newForm.appendChild(newLastname);" | |
| 937 "newForm.appendChild(newEmail);" | |
| 938 "document.body.appendChild(newForm);"); | |
| 939 msg_loop_.RunUntilIdle(); | |
| 940 | |
| 941 web_frame = GetMainFrame(); | |
| 942 form_cache.ExtractNewForms(*web_frame, &forms); | |
| 943 ASSERT_EQ(1U, forms.size()); | |
| 944 | |
| 945 const std::vector<FormFieldData>& fields2 = forms[0].fields; | |
| 946 ASSERT_EQ(3U, fields2.size()); | |
| 947 | |
| 948 expected.name = ASCIIToUTF16("second_firstname"); | |
| 949 expected.value = ASCIIToUTF16("Bob"); | |
| 950 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | |
| 951 | |
| 952 expected.name = ASCIIToUTF16("second_lastname"); | |
| 953 expected.value = ASCIIToUTF16("Hope"); | |
| 954 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | |
| 955 | |
| 956 expected.name = ASCIIToUTF16("second_email"); | |
| 957 expected.value = ASCIIToUTF16("bobhope@example.com"); | |
| 958 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | |
| 959 } | |
| 960 | |
| 961 // We should not extract a form if it has too few fillable fields. | 858 // We should not extract a form if it has too few fillable fields. |
| 962 TEST_F(FormAutofillTest, ExtractFormsTooFewFields) { | 859 TEST_F(FormAutofillTest, ExtractFormsTooFewFields) { |
| 963 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 860 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 964 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 861 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
| 965 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 862 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
| 966 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 863 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 967 "</FORM>"); | 864 "</FORM>"); |
| 968 | 865 |
| 969 WebFrame* web_frame = GetMainFrame(); | 866 WebFrame* web_frame = GetMainFrame(); |
| 970 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 867 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 971 | 868 |
| 972 FormCache form_cache; | 869 FormCache form_cache; |
| 973 std::vector<FormData> forms; | 870 std::vector<FormData> forms; |
| 974 form_cache.ExtractNewForms(*web_frame, &forms); | 871 form_cache.ExtractForms(*web_frame, &forms); |
| 975 EXPECT_EQ(0U, forms.size()); | 872 EXPECT_EQ(0U, forms.size()); |
| 976 } | 873 } |
| 977 | 874 |
| 978 // We should not report additional forms for empty forms. | 875 // We should not report additional forms for empty forms. |
| 979 TEST_F(FormAutofillTest, ExtractFormsSkippedForms) { | 876 TEST_F(FormAutofillTest, ExtractFormsSkippedForms) { |
| 980 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 877 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 981 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 878 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
| 982 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 879 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
| 983 "</FORM>"); | 880 "</FORM>"); |
| 984 | 881 |
| 985 WebFrame* web_frame = GetMainFrame(); | 882 WebFrame* web_frame = GetMainFrame(); |
| 986 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 883 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 987 | 884 |
| 988 FormCache form_cache; | 885 FormCache form_cache; |
| 989 std::vector<FormData> forms; | 886 std::vector<FormData> forms; |
| 990 form_cache.ExtractNewForms(*web_frame, &forms); | 887 bool has_skipped_forms = form_cache.ExtractFormsAndFormElements(*web_frame, |
| 888 3, |
| 889 &forms, |
| 890 NULL); |
| 991 EXPECT_EQ(0U, forms.size()); | 891 EXPECT_EQ(0U, forms.size()); |
| 892 EXPECT_TRUE(has_skipped_forms); |
| 992 } | 893 } |
| 993 | 894 |
| 994 // We should not report additional forms for empty forms. | 895 // We should not report additional forms for empty forms. |
| 995 TEST_F(FormAutofillTest, ExtractFormsNoFields) { | 896 TEST_F(FormAutofillTest, ExtractFormsNoFields) { |
| 996 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 897 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 997 "</FORM>"); | 898 "</FORM>"); |
| 998 | 899 |
| 999 WebFrame* web_frame = GetMainFrame(); | 900 WebFrame* web_frame = GetMainFrame(); |
| 1000 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 901 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 1001 | 902 |
| 1002 FormCache form_cache; | 903 FormCache form_cache; |
| 1003 std::vector<FormData> forms; | 904 std::vector<FormData> forms; |
| 1004 form_cache.ExtractNewForms(*web_frame, &forms); | 905 bool has_skipped_forms = form_cache.ExtractFormsAndFormElements(*web_frame, |
| 906 3, |
| 907 &forms, |
| 908 NULL); |
| 1005 EXPECT_EQ(0U, forms.size()); | 909 EXPECT_EQ(0U, forms.size()); |
| 910 EXPECT_FALSE(has_skipped_forms); |
| 1006 } | 911 } |
| 1007 | 912 |
| 1008 // We should not extract a form if it has too few fillable fields. | 913 // We should not extract a form if it has too few fillable fields. |
| 1009 // Make sure radio and checkbox fields don't count. | 914 // Make sure radio and checkbox fields don't count. |
| 1010 TEST_F(FormAutofillTest, ExtractFormsTooFewFieldsSkipsCheckable) { | 915 TEST_F(FormAutofillTest, ExtractFormsTooFewFieldsSkipsCheckable) { |
| 1011 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" | 916 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\">" |
| 1012 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 917 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
| 1013 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 918 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
| 1014 " <INPUT type=\"radio\" id=\"a_radio\" value=\"0\"/>" | 919 " <INPUT type=\"radio\" id=\"a_radio\" value=\"0\"/>" |
| 1015 " <INPUT type=\"checkbox\" id=\"a_check\" value=\"1\"/>" | 920 " <INPUT type=\"checkbox\" id=\"a_check\" value=\"1\"/>" |
| 1016 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 921 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1017 "</FORM>"); | 922 "</FORM>"); |
| 1018 | 923 |
| 1019 WebFrame* web_frame = GetMainFrame(); | 924 WebFrame* web_frame = GetMainFrame(); |
| 1020 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 925 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 1021 | 926 |
| 1022 FormCache form_cache; | 927 FormCache form_cache; |
| 1023 std::vector<FormData> forms; | 928 std::vector<FormData> forms; |
| 1024 form_cache.ExtractNewForms(*web_frame, &forms); | 929 form_cache.ExtractForms(*web_frame, &forms); |
| 1025 EXPECT_EQ(0U, forms.size()); | 930 EXPECT_EQ(0U, forms.size()); |
| 1026 } | 931 } |
| 1027 | 932 |
| 1028 TEST_F(FormAutofillTest, WebFormElementToFormDataAutocomplete) { | 933 TEST_F(FormAutofillTest, WebFormElementToFormDataAutocomplete) { |
| 1029 { | 934 { |
| 1030 // Form is not auto-completable due to autocomplete=off. | 935 // Form is not auto-completable due to autocomplete=off. |
| 1031 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\"" | 936 LoadHTML("<FORM name=\"TestForm\" action=\"http://cnn.com\" method=\"post\"" |
| 1032 " autocomplete=off>" | 937 " autocomplete=off>" |
| 1033 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 938 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
| 1034 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 939 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 "autocomplete=\"off\" />" | 1016 "autocomplete=\"off\" />" |
| 1112 " <INPUT type=\"text\" id=\"phone\" value=\"1.800.555.1234\"/>" | 1017 " <INPUT type=\"text\" id=\"phone\" value=\"1.800.555.1234\"/>" |
| 1113 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1018 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1114 "</FORM>"); | 1019 "</FORM>"); |
| 1115 | 1020 |
| 1116 WebFrame* web_frame = GetMainFrame(); | 1021 WebFrame* web_frame = GetMainFrame(); |
| 1117 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 1022 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 1118 | 1023 |
| 1119 FormCache form_cache; | 1024 FormCache form_cache; |
| 1120 std::vector<FormData> forms; | 1025 std::vector<FormData> forms; |
| 1121 form_cache.ExtractNewForms(*web_frame, &forms); | 1026 form_cache.ExtractForms(*web_frame, &forms); |
| 1122 ASSERT_EQ(1U, forms.size()); | 1027 ASSERT_EQ(1U, forms.size()); |
| 1123 | 1028 |
| 1124 // Get the input element we want to find. | 1029 // Get the input element we want to find. |
| 1125 WebElement element = web_frame->document().getElementById("firstname"); | 1030 WebElement element = web_frame->document().getElementById("firstname"); |
| 1126 WebInputElement input_element = element.to<WebInputElement>(); | 1031 WebInputElement input_element = element.to<WebInputElement>(); |
| 1127 | 1032 |
| 1128 // Find the form and verify it's the correct form. | 1033 // Find the form and verify it's the correct form. |
| 1129 FormData form; | 1034 FormData form; |
| 1130 FormFieldData field; | 1035 FormFieldData field; |
| 1131 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, | 1036 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 "Apt. 42" | 1110 "Apt. 42" |
| 1206 "</TEXTAREA>" | 1111 "</TEXTAREA>" |
| 1207 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1112 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1208 "</FORM>"); | 1113 "</FORM>"); |
| 1209 | 1114 |
| 1210 WebFrame* web_frame = GetMainFrame(); | 1115 WebFrame* web_frame = GetMainFrame(); |
| 1211 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 1116 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 1212 | 1117 |
| 1213 FormCache form_cache; | 1118 FormCache form_cache; |
| 1214 std::vector<FormData> forms; | 1119 std::vector<FormData> forms; |
| 1215 form_cache.ExtractNewForms(*web_frame, &forms); | 1120 form_cache.ExtractForms(*web_frame, &forms); |
| 1216 ASSERT_EQ(1U, forms.size()); | 1121 ASSERT_EQ(1U, forms.size()); |
| 1217 | 1122 |
| 1218 // Get the textarea element we want to find. | 1123 // Get the textarea element we want to find. |
| 1219 WebElement element = web_frame->document().getElementById("street-address"); | 1124 WebElement element = web_frame->document().getElementById("street-address"); |
| 1220 WebTextAreaElement textarea_element = element.to<WebTextAreaElement>(); | 1125 WebTextAreaElement textarea_element = element.to<WebTextAreaElement>(); |
| 1221 | 1126 |
| 1222 // Find the form and verify it's the correct form. | 1127 // Find the form and verify it's the correct form. |
| 1223 FormData form; | 1128 FormData form; |
| 1224 FormFieldData field; | 1129 FormFieldData field; |
| 1225 EXPECT_TRUE(FindFormAndFieldForFormControlElement(textarea_element, | 1130 EXPECT_TRUE(FindFormAndFieldForFormControlElement(textarea_element, |
| (...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 " <INPUT type=\"text\" id=\"lastname\" maxlength=\"7\"/>" | 2207 " <INPUT type=\"text\" id=\"lastname\" maxlength=\"7\"/>" |
| 2303 " <INPUT type=\"text\" id=\"email\" maxlength=\"9\"/>" | 2208 " <INPUT type=\"text\" id=\"email\" maxlength=\"9\"/>" |
| 2304 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 2209 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 2305 "</FORM>"); | 2210 "</FORM>"); |
| 2306 | 2211 |
| 2307 WebFrame* web_frame = GetMainFrame(); | 2212 WebFrame* web_frame = GetMainFrame(); |
| 2308 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2213 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 2309 | 2214 |
| 2310 FormCache form_cache; | 2215 FormCache form_cache; |
| 2311 std::vector<FormData> forms; | 2216 std::vector<FormData> forms; |
| 2312 form_cache.ExtractNewForms(*web_frame, &forms); | 2217 form_cache.ExtractForms(*web_frame, &forms); |
| 2313 ASSERT_EQ(1U, forms.size()); | 2218 ASSERT_EQ(1U, forms.size()); |
| 2314 | 2219 |
| 2315 // Get the input element we want to find. | 2220 // Get the input element we want to find. |
| 2316 WebElement element = web_frame->document().getElementById("firstname"); | 2221 WebElement element = web_frame->document().getElementById("firstname"); |
| 2317 WebInputElement input_element = element.to<WebInputElement>(); | 2222 WebInputElement input_element = element.to<WebInputElement>(); |
| 2318 | 2223 |
| 2319 // Find the form that contains the input element. | 2224 // Find the form that contains the input element. |
| 2320 FormData form; | 2225 FormData form; |
| 2321 FormFieldData field; | 2226 FormFieldData field; |
| 2322 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, | 2227 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2399 " <INPUT type=\"text\" id=\"lastname\" maxlength=\"-10\"/>" | 2304 " <INPUT type=\"text\" id=\"lastname\" maxlength=\"-10\"/>" |
| 2400 " <INPUT type=\"text\" id=\"email\" maxlength=\"-13\"/>" | 2305 " <INPUT type=\"text\" id=\"email\" maxlength=\"-13\"/>" |
| 2401 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 2306 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 2402 "</FORM>"); | 2307 "</FORM>"); |
| 2403 | 2308 |
| 2404 WebFrame* web_frame = GetMainFrame(); | 2309 WebFrame* web_frame = GetMainFrame(); |
| 2405 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2310 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 2406 | 2311 |
| 2407 FormCache form_cache; | 2312 FormCache form_cache; |
| 2408 std::vector<FormData> forms; | 2313 std::vector<FormData> forms; |
| 2409 form_cache.ExtractNewForms(*web_frame, &forms); | 2314 form_cache.ExtractForms(*web_frame, &forms); |
| 2410 ASSERT_EQ(1U, forms.size()); | 2315 ASSERT_EQ(1U, forms.size()); |
| 2411 | 2316 |
| 2412 // Get the input element we want to find. | 2317 // Get the input element we want to find. |
| 2413 WebElement element = web_frame->document().getElementById("firstname"); | 2318 WebElement element = web_frame->document().getElementById("firstname"); |
| 2414 WebInputElement input_element = element.to<WebInputElement>(); | 2319 WebInputElement input_element = element.to<WebInputElement>(); |
| 2415 | 2320 |
| 2416 // Find the form that contains the input element. | 2321 // Find the form that contains the input element. |
| 2417 FormData form; | 2322 FormData form; |
| 2418 FormFieldData field; | 2323 FormFieldData field; |
| 2419 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, | 2324 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2480 " <INPUT type=\"text\" id=\"lastname\"/>" | 2385 " <INPUT type=\"text\" id=\"lastname\"/>" |
| 2481 " <INPUT type=\"text\" id=\"email\"/>" | 2386 " <INPUT type=\"text\" id=\"email\"/>" |
| 2482 " <INPUT type=\"submit\" value=\"Send\"/>" | 2387 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 2483 "</FORM>"); | 2388 "</FORM>"); |
| 2484 | 2389 |
| 2485 WebFrame* web_frame = GetMainFrame(); | 2390 WebFrame* web_frame = GetMainFrame(); |
| 2486 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2391 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 2487 | 2392 |
| 2488 FormCache form_cache; | 2393 FormCache form_cache; |
| 2489 std::vector<FormData> forms; | 2394 std::vector<FormData> forms; |
| 2490 form_cache.ExtractNewForms(*web_frame, &forms); | 2395 form_cache.ExtractForms(*web_frame, &forms); |
| 2491 ASSERT_EQ(1U, forms.size()); | 2396 ASSERT_EQ(1U, forms.size()); |
| 2492 | 2397 |
| 2493 // Get the input element we want to find. | 2398 // Get the input element we want to find. |
| 2494 WebElement element = web_frame->document().getElementById("firstname"); | 2399 WebElement element = web_frame->document().getElementById("firstname"); |
| 2495 WebInputElement input_element = element.to<WebInputElement>(); | 2400 WebInputElement input_element = element.to<WebInputElement>(); |
| 2496 | 2401 |
| 2497 // Find the form that contains the input element. | 2402 // Find the form that contains the input element. |
| 2498 FormData form; | 2403 FormData form; |
| 2499 FormFieldData field; | 2404 FormFieldData field; |
| 2500 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, | 2405 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2570 " <INPUT type=\"text\" id=\"banana\"/>" | 2475 " <INPUT type=\"text\" id=\"banana\"/>" |
| 2571 " <INPUT type=\"text\" id=\"cantelope\"/>" | 2476 " <INPUT type=\"text\" id=\"cantelope\"/>" |
| 2572 " <INPUT type=\"submit\" value=\"Send\"/>" | 2477 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 2573 "</FORM>"); | 2478 "</FORM>"); |
| 2574 | 2479 |
| 2575 WebFrame* web_frame = GetMainFrame(); | 2480 WebFrame* web_frame = GetMainFrame(); |
| 2576 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2481 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 2577 | 2482 |
| 2578 FormCache form_cache; | 2483 FormCache form_cache; |
| 2579 std::vector<FormData> forms; | 2484 std::vector<FormData> forms; |
| 2580 form_cache.ExtractNewForms(*web_frame, &forms); | 2485 form_cache.ExtractForms(*web_frame, &forms); |
| 2581 ASSERT_EQ(2U, forms.size()); | 2486 ASSERT_EQ(2U, forms.size()); |
| 2582 | 2487 |
| 2583 // Get the input element we want to find. | 2488 // Get the input element we want to find. |
| 2584 WebElement element = web_frame->document().getElementById("apple"); | 2489 WebElement element = web_frame->document().getElementById("apple"); |
| 2585 WebInputElement input_element = element.to<WebInputElement>(); | 2490 WebInputElement input_element = element.to<WebInputElement>(); |
| 2586 | 2491 |
| 2587 // Find the form that contains the input element. | 2492 // Find the form that contains the input element. |
| 2588 FormData form; | 2493 FormData form; |
| 2589 FormFieldData field; | 2494 FormFieldData field; |
| 2590 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, | 2495 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2790 " <INPUT type=\"text\" id=\"lastname\"/>" | 2695 " <INPUT type=\"text\" id=\"lastname\"/>" |
| 2791 " <INPUT type=\"text\" id=\"email\"/>" | 2696 " <INPUT type=\"text\" id=\"email\"/>" |
| 2792 " <INPUT type=\"submit\" value=\"Send\"/>" | 2697 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 2793 "</FORM>"); | 2698 "</FORM>"); |
| 2794 | 2699 |
| 2795 WebFrame* web_frame = GetMainFrame(); | 2700 WebFrame* web_frame = GetMainFrame(); |
| 2796 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2701 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 2797 | 2702 |
| 2798 FormCache form_cache; | 2703 FormCache form_cache; |
| 2799 std::vector<FormData> forms; | 2704 std::vector<FormData> forms; |
| 2800 form_cache.ExtractNewForms(*web_frame, &forms); | 2705 form_cache.ExtractForms(*web_frame, &forms); |
| 2801 ASSERT_EQ(1U, forms.size()); | 2706 ASSERT_EQ(1U, forms.size()); |
| 2802 | 2707 |
| 2803 // Get the input element we want to find. | 2708 // Get the input element we want to find. |
| 2804 WebElement element = web_frame->document().getElementById("firstname"); | 2709 WebElement element = web_frame->document().getElementById("firstname"); |
| 2805 WebInputElement input_element = element.to<WebInputElement>(); | 2710 WebInputElement input_element = element.to<WebInputElement>(); |
| 2806 | 2711 |
| 2807 // Simulate typing by modifying the field value. | 2712 // Simulate typing by modifying the field value. |
| 2808 input_element.setValue(ASCIIToUTF16("Wy")); | 2713 input_element.setValue(ASCIIToUTF16("Wy")); |
| 2809 | 2714 |
| 2810 // Find the form that contains the input element. | 2715 // Find the form that contains the input element. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2902 " </TEXTAREA>" | 2807 " </TEXTAREA>" |
| 2903 " <TEXTAREA id=\"textarea-noAC\" autocomplete=\"off\">Carrot?</TEXTAREA>" | 2808 " <TEXTAREA id=\"textarea-noAC\" autocomplete=\"off\">Carrot?</TEXTAREA>" |
| 2904 " <INPUT type=\"submit\" value=\"Send\"/>" | 2809 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 2905 "</FORM>"); | 2810 "</FORM>"); |
| 2906 | 2811 |
| 2907 WebFrame* web_frame = GetMainFrame(); | 2812 WebFrame* web_frame = GetMainFrame(); |
| 2908 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2813 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 2909 | 2814 |
| 2910 FormCache form_cache; | 2815 FormCache form_cache; |
| 2911 std::vector<FormData> forms; | 2816 std::vector<FormData> forms; |
| 2912 form_cache.ExtractNewForms(*web_frame, &forms); | 2817 form_cache.ExtractForms(*web_frame, &forms); |
| 2913 ASSERT_EQ(1U, forms.size()); | 2818 ASSERT_EQ(1U, forms.size()); |
| 2914 | 2819 |
| 2915 // Set the auto-filled attribute on the firstname element. | 2820 // Set the auto-filled attribute on the firstname element. |
| 2916 WebInputElement firstname = | 2821 WebInputElement firstname = |
| 2917 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 2822 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 2918 firstname.setAutofilled(true); | 2823 firstname.setAutofilled(true); |
| 2919 | 2824 |
| 2920 // Set the value of the disabled text input element. | 2825 // Set the value of the disabled text input element. |
| 2921 WebInputElement notenabled = | 2826 WebInputElement notenabled = |
| 2922 web_frame->document().getElementById("notenabled").to<WebInputElement>(); | 2827 web_frame->document().getElementById("notenabled").to<WebInputElement>(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 " <OPTION>AK</OPTION>" | 2911 " <OPTION>AK</OPTION>" |
| 3007 " </SELECT>" | 2912 " </SELECT>" |
| 3008 " <INPUT type=\"submit\" value=\"Send\"/>" | 2913 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 3009 "</FORM>"); | 2914 "</FORM>"); |
| 3010 | 2915 |
| 3011 WebFrame* web_frame = GetMainFrame(); | 2916 WebFrame* web_frame = GetMainFrame(); |
| 3012 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2917 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 3013 | 2918 |
| 3014 FormCache form_cache; | 2919 FormCache form_cache; |
| 3015 std::vector<FormData> forms; | 2920 std::vector<FormData> forms; |
| 3016 form_cache.ExtractNewForms(*web_frame, &forms); | 2921 form_cache.ExtractForms(*web_frame, &forms); |
| 3017 ASSERT_EQ(1U, forms.size()); | 2922 ASSERT_EQ(1U, forms.size()); |
| 3018 | 2923 |
| 3019 // Set the auto-filled attribute on the firstname element. | 2924 // Set the auto-filled attribute on the firstname element. |
| 3020 WebInputElement firstname = | 2925 WebInputElement firstname = |
| 3021 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 2926 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 3022 firstname.setAutofilled(true); | 2927 firstname.setAutofilled(true); |
| 3023 | 2928 |
| 3024 // Set the value of the select-one. | 2929 // Set the value of the select-one. |
| 3025 WebSelectElement select_element = | 2930 WebSelectElement select_element = |
| 3026 web_frame->document().getElementById("state").to<WebSelectElement>(); | 2931 web_frame->document().getElementById("state").to<WebSelectElement>(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 " <INPUT type=\"email\" id=\"email2\"/>" | 2984 " <INPUT type=\"email\" id=\"email2\"/>" |
| 3080 " <INPUT type=\"tel\" id=\"phone\"/>" | 2985 " <INPUT type=\"tel\" id=\"phone\"/>" |
| 3081 " <INPUT type=\"submit\" value=\"Send\"/>" | 2986 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 3082 "</FORM>"); | 2987 "</FORM>"); |
| 3083 | 2988 |
| 3084 WebFrame* web_frame = GetMainFrame(); | 2989 WebFrame* web_frame = GetMainFrame(); |
| 3085 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 2990 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 3086 | 2991 |
| 3087 FormCache form_cache; | 2992 FormCache form_cache; |
| 3088 std::vector<FormData> forms; | 2993 std::vector<FormData> forms; |
| 3089 form_cache.ExtractNewForms(*web_frame, &forms); | 2994 form_cache.ExtractForms(*web_frame, &forms); |
| 3090 ASSERT_EQ(1U, forms.size()); | 2995 ASSERT_EQ(1U, forms.size()); |
| 3091 | 2996 |
| 3092 // Set the auto-filled attribute. | 2997 // Set the auto-filled attribute. |
| 3093 WebInputElement firstname = | 2998 WebInputElement firstname = |
| 3094 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 2999 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 3095 firstname.setAutofilled(true); | 3000 firstname.setAutofilled(true); |
| 3096 WebInputElement lastname = | 3001 WebInputElement lastname = |
| 3097 web_frame->document().getElementById("lastname").to<WebInputElement>(); | 3002 web_frame->document().getElementById("lastname").to<WebInputElement>(); |
| 3098 lastname.setAutofilled(true); | 3003 lastname.setAutofilled(true); |
| 3099 WebInputElement email = | 3004 WebInputElement email = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 " <INPUT type=\"email\" id=\"email2\"/>" | 3052 " <INPUT type=\"email\" id=\"email2\"/>" |
| 3148 " <INPUT type=\"tel\" id=\"phone\"/>" | 3053 " <INPUT type=\"tel\" id=\"phone\"/>" |
| 3149 " <INPUT type=\"submit\" value=\"Send\"/>" | 3054 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 3150 "</FORM>"); | 3055 "</FORM>"); |
| 3151 | 3056 |
| 3152 WebFrame* web_frame = GetMainFrame(); | 3057 WebFrame* web_frame = GetMainFrame(); |
| 3153 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 3058 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 3154 | 3059 |
| 3155 FormCache form_cache; | 3060 FormCache form_cache; |
| 3156 std::vector<FormData> forms; | 3061 std::vector<FormData> forms; |
| 3157 form_cache.ExtractNewForms(*web_frame, &forms); | 3062 form_cache.ExtractForms(*web_frame, &forms); |
| 3158 ASSERT_EQ(1U, forms.size()); | 3063 ASSERT_EQ(1U, forms.size()); |
| 3159 | 3064 |
| 3160 // Set the auto-filled attribute. | 3065 // Set the auto-filled attribute. |
| 3161 WebInputElement firstname = | 3066 WebInputElement firstname = |
| 3162 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 3067 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 3163 firstname.setAutofilled(true); | 3068 firstname.setAutofilled(true); |
| 3164 WebInputElement lastname = | 3069 WebInputElement lastname = |
| 3165 web_frame->document().getElementById("lastname").to<WebInputElement>(); | 3070 web_frame->document().getElementById("lastname").to<WebInputElement>(); |
| 3166 lastname.setAutofilled(true); | 3071 lastname.setAutofilled(true); |
| 3167 WebInputElement email = | 3072 WebInputElement email = |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3215 " <INPUT type=\"email\" id=\"email2\"/>" | 3120 " <INPUT type=\"email\" id=\"email2\"/>" |
| 3216 " <INPUT type=\"tel\" id=\"phone\"/>" | 3121 " <INPUT type=\"tel\" id=\"phone\"/>" |
| 3217 " <INPUT type=\"submit\" value=\"Send\"/>" | 3122 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 3218 "</FORM>"); | 3123 "</FORM>"); |
| 3219 | 3124 |
| 3220 WebFrame* web_frame = GetMainFrame(); | 3125 WebFrame* web_frame = GetMainFrame(); |
| 3221 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 3126 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 3222 | 3127 |
| 3223 FormCache form_cache; | 3128 FormCache form_cache; |
| 3224 std::vector<FormData> forms; | 3129 std::vector<FormData> forms; |
| 3225 form_cache.ExtractNewForms(*web_frame, &forms); | 3130 form_cache.ExtractForms(*web_frame, &forms); |
| 3226 ASSERT_EQ(1U, forms.size()); | 3131 ASSERT_EQ(1U, forms.size()); |
| 3227 | 3132 |
| 3228 // Set the auto-filled attribute. | 3133 // Set the auto-filled attribute. |
| 3229 WebInputElement firstname = | 3134 WebInputElement firstname = |
| 3230 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 3135 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 3231 firstname.setAutofilled(true); | 3136 firstname.setAutofilled(true); |
| 3232 WebInputElement lastname = | 3137 WebInputElement lastname = |
| 3233 web_frame->document().getElementById("lastname").to<WebInputElement>(); | 3138 web_frame->document().getElementById("lastname").to<WebInputElement>(); |
| 3234 lastname.setAutofilled(true); | 3139 lastname.setAutofilled(true); |
| 3235 WebInputElement email = | 3140 WebInputElement email = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3282 " <INPUT type=\"email\" id=\"email2\"/>" | 3187 " <INPUT type=\"email\" id=\"email2\"/>" |
| 3283 " <INPUT type=\"tel\" id=\"phone\"/>" | 3188 " <INPUT type=\"tel\" id=\"phone\"/>" |
| 3284 " <INPUT type=\"submit\" value=\"Send\"/>" | 3189 " <INPUT type=\"submit\" value=\"Send\"/>" |
| 3285 "</FORM>"); | 3190 "</FORM>"); |
| 3286 | 3191 |
| 3287 WebFrame* web_frame = GetMainFrame(); | 3192 WebFrame* web_frame = GetMainFrame(); |
| 3288 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 3193 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 3289 | 3194 |
| 3290 FormCache form_cache; | 3195 FormCache form_cache; |
| 3291 std::vector<FormData> forms; | 3196 std::vector<FormData> forms; |
| 3292 form_cache.ExtractNewForms(*web_frame, &forms); | 3197 form_cache.ExtractForms(*web_frame, &forms); |
| 3293 ASSERT_EQ(1U, forms.size()); | 3198 ASSERT_EQ(1U, forms.size()); |
| 3294 | 3199 |
| 3295 WebInputElement firstname = | 3200 WebInputElement firstname = |
| 3296 web_frame->document().getElementById("firstname").to<WebInputElement>(); | 3201 web_frame->document().getElementById("firstname").to<WebInputElement>(); |
| 3297 | 3202 |
| 3298 // Auto-filled attribute not set yet. | 3203 // Auto-filled attribute not set yet. |
| 3299 EXPECT_FALSE(FormWithElementIsAutofilled(firstname)); | 3204 EXPECT_FALSE(FormWithElementIsAutofilled(firstname)); |
| 3300 | 3205 |
| 3301 // Set the auto-filled attribute. | 3206 // Set the auto-filled attribute. |
| 3302 firstname.setAutofilled(true); | 3207 firstname.setAutofilled(true); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3448 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3353 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 3449 | 3354 |
| 3450 expected.name = ASCIIToUTF16("country"); | 3355 expected.name = ASCIIToUTF16("country"); |
| 3451 expected.value = ASCIIToUTF16("AL"); | 3356 expected.value = ASCIIToUTF16("AL"); |
| 3452 expected.form_control_type = "select-one"; | 3357 expected.form_control_type = "select-one"; |
| 3453 expected.max_length = 0; | 3358 expected.max_length = 0; |
| 3454 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3359 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 3455 } | 3360 } |
| 3456 | 3361 |
| 3457 } // namespace autofill | 3362 } // namespace autofill |
| OLD | NEW |