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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 values.push_back(ASCIIToUTF16("Smith")); | 152 values.push_back(ASCIIToUTF16("Smith")); |
153 | 153 |
154 labels.push_back(ASCIIToUTF16("Email:")); | 154 labels.push_back(ASCIIToUTF16("Email:")); |
155 names.push_back(ASCIIToUTF16("email")); | 155 names.push_back(ASCIIToUTF16("email")); |
156 values.push_back(ASCIIToUTF16("john@example.com")); | 156 values.push_back(ASCIIToUTF16("john@example.com")); |
157 | 157 |
158 ExpectLabels(html, labels, names, values); | 158 ExpectLabels(html, labels, names, values); |
159 } | 159 } |
160 | 160 |
161 typedef void (*FillFormFunction)(const FormData& form, | 161 typedef void (*FillFormFunction)(const FormData& form, |
162 const WebInputElement& element); | 162 const WebFormControlElement& element); |
163 | 163 |
164 typedef WebString (*GetValueFunction)(WebFormControlElement element); | 164 typedef WebString (*GetValueFunction)(WebFormControlElement element); |
165 | 165 |
166 // Test FormFillxxx functions. | 166 // Test FormFillxxx functions. |
167 void TestFormFillFunctions(const char* html, | 167 void TestFormFillFunctions(const char* html, |
168 const AutofillFieldCase* field_cases, | 168 const AutofillFieldCase* field_cases, |
169 size_t number_of_field_cases, | 169 size_t number_of_field_cases, |
170 FillFormFunction fill_form_function, | 170 FillFormFunction fill_form_function, |
171 GetValueFunction get_value_function) { | 171 GetValueFunction get_value_function) { |
172 LoadHTML(html); | 172 LoadHTML(html); |
173 | 173 |
174 WebFrame* web_frame = GetMainFrame(); | 174 WebFrame* web_frame = GetMainFrame(); |
175 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 175 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
176 | 176 |
177 FormCache form_cache; | 177 FormCache form_cache; |
178 std::vector<FormData> forms; | 178 std::vector<FormData> forms; |
179 form_cache.ExtractForms(*web_frame, &forms); | 179 form_cache.ExtractForms(*web_frame, &forms); |
180 ASSERT_EQ(1U, forms.size()); | 180 ASSERT_EQ(1U, forms.size()); |
181 | 181 |
182 // Get the input element we want to find. | 182 // Get the input element we want to find. |
183 WebElement element = web_frame->document().getElementById("firstname"); | 183 WebElement element = web_frame->document().getElementById("firstname"); |
184 WebInputElement input_element = element.to<WebInputElement>(); | 184 WebInputElement input_element = element.to<WebInputElement>(); |
185 | 185 |
186 // Find the form that contains the input element. | 186 // Find the form that contains the input element. |
187 FormData form_data; | 187 FormData form_data; |
188 FormFieldData field; | 188 FormFieldData field; |
189 EXPECT_TRUE( | 189 EXPECT_TRUE( |
190 FindFormAndFieldForInputElement(input_element, | 190 FindFormAndFieldForFormControlElement(input_element, |
191 &form_data, | 191 &form_data, |
192 &field, | 192 &field, |
193 autofill::REQUIRE_AUTOCOMPLETE)); | 193 autofill::REQUIRE_AUTOCOMPLETE)); |
194 EXPECT_EQ(ASCIIToUTF16("TestForm"), form_data.name); | 194 EXPECT_EQ(ASCIIToUTF16("TestForm"), form_data.name); |
195 EXPECT_EQ(GURL(web_frame->document().url()), form_data.origin); | 195 EXPECT_EQ(GURL(web_frame->document().url()), form_data.origin); |
196 EXPECT_EQ(GURL("http://buh.com"), form_data.action); | 196 EXPECT_EQ(GURL("http://buh.com"), form_data.action); |
197 | 197 |
198 const std::vector<FormFieldData>& fields = form_data.fields; | 198 const std::vector<FormFieldData>& fields = form_data.fields; |
199 ASSERT_EQ(number_of_field_cases, fields.size()); | 199 ASSERT_EQ(number_of_field_cases, fields.size()); |
200 | 200 |
201 FormFieldData expected; | 201 FormFieldData expected; |
202 // Verify field's initial value. | 202 // Verify field's initial value. |
203 for (size_t i = 0; i < number_of_field_cases; ++i) { | 203 for (size_t i = 0; i < number_of_field_cases; ++i) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 EXPECT_EQ(field_case.should_be_autofilled, element.isAutofilled()); | 251 EXPECT_EQ(field_case.should_be_autofilled, element.isAutofilled()); |
252 } | 252 } |
253 | 253 |
254 static void FillFormForAllFieldsWrapper(const FormData& form, | 254 static void FillFormForAllFieldsWrapper(const FormData& form, |
255 const WebInputElement& element) { | 255 const WebInputElement& element) { |
256 FillFormForAllElements(form, element.form()); | 256 FillFormForAllElements(form, element.form()); |
257 } | 257 } |
258 | 258 |
259 static void FillFormIncludingNonFocusableElementsWrapper( | 259 static void FillFormIncludingNonFocusableElementsWrapper( |
260 const FormData& form, | 260 const FormData& form, |
261 const WebInputElement& element) { | 261 const WebFormControlElement& element) { |
262 FillFormIncludingNonFocusableElements(form, element.form()); | 262 FillFormIncludingNonFocusableElements(form, element.form()); |
263 } | 263 } |
264 | 264 |
265 static WebString GetValueWrapper(WebFormControlElement element) { | 265 static WebString GetValueWrapper(WebFormControlElement element) { |
266 if (element.formControlType() == "textarea") | 266 if (element.formControlType() == "textarea") |
267 return element.to<WebTextAreaElement>().value(); | 267 return element.to<WebTextAreaElement>().value(); |
268 | 268 |
269 return element.to<WebInputElement>().value(); | 269 return element.to<WebInputElement>().value(); |
270 } | 270 } |
271 | 271 |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 expected.name = ASCIIToUTF16("lastname"); | 995 expected.name = ASCIIToUTF16("lastname"); |
996 expected.value = ASCIIToUTF16("Smith"); | 996 expected.value = ASCIIToUTF16("Smith"); |
997 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 997 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
998 | 998 |
999 expected.name = ASCIIToUTF16("email"); | 999 expected.name = ASCIIToUTF16("email"); |
1000 expected.value = ASCIIToUTF16("john@example.com"); | 1000 expected.value = ASCIIToUTF16("john@example.com"); |
1001 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 1001 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
1002 } | 1002 } |
1003 } | 1003 } |
1004 | 1004 |
1005 TEST_F(FormAutofillTest, FindForm) { | 1005 TEST_F(FormAutofillTest, FindFormForInputElement) { |
1006 LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" | 1006 LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" |
1007 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" | 1007 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
1008 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" | 1008 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
1009 " <INPUT type=\"text\" id=\"email\" value=\"john@example.com\"" | 1009 " <INPUT type=\"text\" id=\"email\" value=\"john@example.com\"" |
1010 "autocomplete=\"off\" />" | 1010 "autocomplete=\"off\" />" |
1011 " <INPUT type=\"text\" id=\"phone\" value=\"1.800.555.1234\"/>" | 1011 " <INPUT type=\"text\" id=\"phone\" value=\"1.800.555.1234\"/>" |
1012 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" | 1012 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
1013 "</FORM>"); | 1013 "</FORM>"); |
1014 | 1014 |
1015 WebFrame* web_frame = GetMainFrame(); | 1015 WebFrame* web_frame = GetMainFrame(); |
1016 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); | 1016 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
1017 | 1017 |
1018 FormCache form_cache; | 1018 FormCache form_cache; |
1019 std::vector<FormData> forms; | 1019 std::vector<FormData> forms; |
1020 form_cache.ExtractForms(*web_frame, &forms); | 1020 form_cache.ExtractForms(*web_frame, &forms); |
1021 ASSERT_EQ(1U, forms.size()); | 1021 ASSERT_EQ(1U, forms.size()); |
1022 | 1022 |
1023 // Get the input element we want to find. | 1023 // Get the input element we want to find. |
1024 WebElement element = web_frame->document().getElementById("firstname"); | 1024 WebElement element = web_frame->document().getElementById("firstname"); |
1025 WebInputElement input_element = element.to<WebInputElement>(); | 1025 WebInputElement input_element = element.to<WebInputElement>(); |
1026 | 1026 |
1027 // Find the form and verify it's the correct form. | 1027 // Find the form and verify it's the correct form. |
1028 FormData form; | 1028 FormData form; |
1029 FormFieldData field; | 1029 FormFieldData field; |
1030 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 1030 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
1031 autofill::REQUIRE_NONE)); | 1031 &form, |
| 1032 &field, |
| 1033 autofill::REQUIRE_NONE)); |
1032 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 1034 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
1033 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 1035 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
1034 EXPECT_EQ(GURL("http://buh.com"), form.action); | 1036 EXPECT_EQ(GURL("http://buh.com"), form.action); |
1035 | 1037 |
1036 const std::vector<FormFieldData>& fields = form.fields; | 1038 const std::vector<FormFieldData>& fields = form.fields; |
1037 ASSERT_EQ(4U, fields.size()); | 1039 ASSERT_EQ(4U, fields.size()); |
1038 | 1040 |
1039 FormFieldData expected; | 1041 FormFieldData expected; |
1040 expected.form_control_type = "text"; | 1042 expected.form_control_type = "text"; |
1041 expected.max_length = WebInputElement::defaultMaxLength(); | 1043 expected.max_length = WebInputElement::defaultMaxLength(); |
(...skipping 13 matching lines...) Expand all Loading... |
1055 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 1057 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
1056 expected.autocomplete_attribute = std::string(); // reset | 1058 expected.autocomplete_attribute = std::string(); // reset |
1057 | 1059 |
1058 expected.name = ASCIIToUTF16("phone"); | 1060 expected.name = ASCIIToUTF16("phone"); |
1059 expected.value = ASCIIToUTF16("1.800.555.1234"); | 1061 expected.value = ASCIIToUTF16("1.800.555.1234"); |
1060 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); | 1062 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); |
1061 | 1063 |
1062 // Try again, but require autocomplete. | 1064 // Try again, but require autocomplete. |
1063 FormData form2; | 1065 FormData form2; |
1064 FormFieldData field2; | 1066 FormFieldData field2; |
1065 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 1067 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
1066 autofill::REQUIRE_AUTOCOMPLETE)); | 1068 input_element, |
| 1069 &form2, |
| 1070 &field2, |
| 1071 autofill::REQUIRE_AUTOCOMPLETE)); |
1067 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 1072 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
1068 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 1073 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
1069 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 1074 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
1070 | 1075 |
1071 const std::vector<FormFieldData>& fields2 = form2.fields; | 1076 const std::vector<FormFieldData>& fields2 = form2.fields; |
1072 ASSERT_EQ(3U, fields2.size()); | 1077 ASSERT_EQ(3U, fields2.size()); |
1073 | 1078 |
1074 expected.form_control_type = "text"; | 1079 expected.form_control_type = "text"; |
1075 expected.max_length = WebInputElement::defaultMaxLength(); | 1080 expected.max_length = WebInputElement::defaultMaxLength(); |
1076 | 1081 |
1077 expected.name = ASCIIToUTF16("firstname"); | 1082 expected.name = ASCIIToUTF16("firstname"); |
1078 expected.value = ASCIIToUTF16("John"); | 1083 expected.value = ASCIIToUTF16("John"); |
1079 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); | 1084 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
1080 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); | 1085 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); |
1081 | 1086 |
1082 expected.name = ASCIIToUTF16("lastname"); | 1087 expected.name = ASCIIToUTF16("lastname"); |
1083 expected.value = ASCIIToUTF16("Smith"); | 1088 expected.value = ASCIIToUTF16("Smith"); |
1084 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); | 1089 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
1085 | 1090 |
1086 expected.name = ASCIIToUTF16("phone"); | 1091 expected.name = ASCIIToUTF16("phone"); |
1087 expected.value = ASCIIToUTF16("1.800.555.1234"); | 1092 expected.value = ASCIIToUTF16("1.800.555.1234"); |
1088 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); | 1093 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
1089 } | 1094 } |
1090 | 1095 |
| 1096 TEST_F(FormAutofillTest, FindFormForTextAreaElement) { |
| 1097 LoadHTML("<FORM name=\"TestForm\" action=\"http://buh.com\" method=\"post\">" |
| 1098 " <INPUT type=\"text\" id=\"firstname\" value=\"John\"/>" |
| 1099 " <INPUT type=\"text\" id=\"lastname\" value=\"Smith\"/>" |
| 1100 " <INPUT type=\"text\" id=\"email\" value=\"john@example.com\"" |
| 1101 "autocomplete=\"off\" />" |
| 1102 " <TEXTAREA id=\"street-address\">" |
| 1103 "123 Fantasy Ln. " |
| 1104 "Apt. 42" |
| 1105 "</TEXTAREA>" |
| 1106 " <INPUT type=\"submit\" name=\"reply-send\" value=\"Send\"/>" |
| 1107 "</FORM>"); |
| 1108 |
| 1109 WebFrame* web_frame = GetMainFrame(); |
| 1110 ASSERT_NE(static_cast<WebFrame*>(NULL), web_frame); |
| 1111 |
| 1112 FormCache form_cache; |
| 1113 std::vector<FormData> forms; |
| 1114 form_cache.ExtractForms(*web_frame, &forms); |
| 1115 ASSERT_EQ(1U, forms.size()); |
| 1116 |
| 1117 // Get the textarea element we want to find. |
| 1118 WebElement element = web_frame->document().getElementById("street-address"); |
| 1119 WebTextAreaElement textarea_element = element.to<WebTextAreaElement>(); |
| 1120 |
| 1121 // Find the form and verify it's the correct form. |
| 1122 FormData form; |
| 1123 FormFieldData field; |
| 1124 EXPECT_TRUE(FindFormAndFieldForFormControlElement(textarea_element, |
| 1125 &form, |
| 1126 &field, |
| 1127 autofill::REQUIRE_NONE)); |
| 1128 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
| 1129 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
| 1130 EXPECT_EQ(GURL("http://buh.com"), form.action); |
| 1131 |
| 1132 const std::vector<FormFieldData>& fields = form.fields; |
| 1133 ASSERT_EQ(4U, fields.size()); |
| 1134 |
| 1135 FormFieldData expected; |
| 1136 |
| 1137 expected.name = ASCIIToUTF16("firstname"); |
| 1138 expected.value = ASCIIToUTF16("John"); |
| 1139 expected.form_control_type = "text"; |
| 1140 expected.max_length = WebInputElement::defaultMaxLength(); |
| 1141 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); |
| 1142 |
| 1143 expected.name = ASCIIToUTF16("lastname"); |
| 1144 expected.value = ASCIIToUTF16("Smith"); |
| 1145 expected.form_control_type = "text"; |
| 1146 expected.max_length = WebInputElement::defaultMaxLength(); |
| 1147 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
| 1148 |
| 1149 expected.name = ASCIIToUTF16("email"); |
| 1150 expected.value = ASCIIToUTF16("john@example.com"); |
| 1151 expected.autocomplete_attribute = "off"; |
| 1152 expected.form_control_type = "text"; |
| 1153 expected.max_length = WebInputElement::defaultMaxLength(); |
| 1154 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
| 1155 expected.autocomplete_attribute = std::string(); // reset |
| 1156 |
| 1157 expected.name = ASCIIToUTF16("street-address"); |
| 1158 expected.value = ASCIIToUTF16("123 Fantasy Ln.\nApt. 42"); |
| 1159 expected.form_control_type = "textarea"; |
| 1160 expected.max_length = 0; |
| 1161 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[3]); |
| 1162 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); |
| 1163 |
| 1164 // Try again, but require autocomplete. |
| 1165 FormData form2; |
| 1166 FormFieldData field2; |
| 1167 EXPECT_TRUE(FindFormAndFieldForFormControlElement( |
| 1168 textarea_element, |
| 1169 &form2, |
| 1170 &field2, |
| 1171 autofill::REQUIRE_AUTOCOMPLETE)); |
| 1172 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
| 1173 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
| 1174 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
| 1175 |
| 1176 const std::vector<FormFieldData>& fields2 = form2.fields; |
| 1177 ASSERT_EQ(3U, fields2.size()); |
| 1178 |
| 1179 expected.name = ASCIIToUTF16("firstname"); |
| 1180 expected.value = ASCIIToUTF16("John"); |
| 1181 expected.form_control_type = "text"; |
| 1182 expected.max_length = WebInputElement::defaultMaxLength(); |
| 1183 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[0]); |
| 1184 |
| 1185 expected.name = ASCIIToUTF16("lastname"); |
| 1186 expected.value = ASCIIToUTF16("Smith"); |
| 1187 expected.form_control_type = "text"; |
| 1188 expected.max_length = WebInputElement::defaultMaxLength(); |
| 1189 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[1]); |
| 1190 |
| 1191 expected.name = ASCIIToUTF16("street-address"); |
| 1192 expected.value = ASCIIToUTF16("123 Fantasy Ln.\nApt. 42"); |
| 1193 expected.form_control_type = "textarea"; |
| 1194 expected.max_length = 0; |
| 1195 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields2[2]); |
| 1196 EXPECT_FORM_FIELD_DATA_EQUALS(expected, field); |
| 1197 } |
| 1198 |
1091 // Test regular FillForm function. | 1199 // Test regular FillForm function. |
1092 TEST_F(FormAutofillTest, FillForm) { | 1200 TEST_F(FormAutofillTest, FillForm) { |
1093 static const AutofillFieldCase field_cases[] = { | 1201 static const AutofillFieldCase field_cases[] = { |
1094 // fields: form_control_type, name, initial_value, autocomplete_attribute, | 1202 // fields: form_control_type, name, initial_value, autocomplete_attribute, |
1095 // should_be_autofilled, autofill_value, expected_value | 1203 // should_be_autofilled, autofill_value, expected_value |
1096 | 1204 |
1097 // Regular empty fields (firstname & lastname) should be autofilled. | 1205 // Regular empty fields (firstname & lastname) should be autofilled. |
1098 {"text", "firstname", "", "", true, "filled firstname", | 1206 {"text", "firstname", "", "", true, "filled firstname", |
1099 "filled firstname"}, | 1207 "filled firstname"}, |
1100 {"text", "lastname", "", "", true, "filled lastname", "filled lastname"}, | 1208 {"text", "lastname", "", "", true, "filled lastname", "filled lastname"}, |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 form_cache.ExtractForms(*web_frame, &forms); | 2210 form_cache.ExtractForms(*web_frame, &forms); |
2103 ASSERT_EQ(1U, forms.size()); | 2211 ASSERT_EQ(1U, forms.size()); |
2104 | 2212 |
2105 // Get the input element we want to find. | 2213 // Get the input element we want to find. |
2106 WebElement element = web_frame->document().getElementById("firstname"); | 2214 WebElement element = web_frame->document().getElementById("firstname"); |
2107 WebInputElement input_element = element.to<WebInputElement>(); | 2215 WebInputElement input_element = element.to<WebInputElement>(); |
2108 | 2216 |
2109 // Find the form that contains the input element. | 2217 // Find the form that contains the input element. |
2110 FormData form; | 2218 FormData form; |
2111 FormFieldData field; | 2219 FormFieldData field; |
2112 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 2220 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2113 autofill::REQUIRE_NONE)); | 2221 &form, |
| 2222 &field, |
| 2223 autofill::REQUIRE_NONE)); |
2114 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 2224 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
2115 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2225 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
2116 EXPECT_EQ(GURL("http://buh.com"), form.action); | 2226 EXPECT_EQ(GURL("http://buh.com"), form.action); |
2117 | 2227 |
2118 const std::vector<FormFieldData>& fields = form.fields; | 2228 const std::vector<FormFieldData>& fields = form.fields; |
2119 ASSERT_EQ(3U, fields.size()); | 2229 ASSERT_EQ(3U, fields.size()); |
2120 | 2230 |
2121 FormFieldData expected; | 2231 FormFieldData expected; |
2122 expected.form_control_type = "text"; | 2232 expected.form_control_type = "text"; |
2123 | 2233 |
(...skipping 14 matching lines...) Expand all Loading... |
2138 | 2248 |
2139 // Fill the form. | 2249 // Fill the form. |
2140 form.fields[0].value = ASCIIToUTF16("Brother"); | 2250 form.fields[0].value = ASCIIToUTF16("Brother"); |
2141 form.fields[1].value = ASCIIToUTF16("Jonathan"); | 2251 form.fields[1].value = ASCIIToUTF16("Jonathan"); |
2142 form.fields[2].value = ASCIIToUTF16("brotherj@example.com"); | 2252 form.fields[2].value = ASCIIToUTF16("brotherj@example.com"); |
2143 FillForm(form, input_element); | 2253 FillForm(form, input_element); |
2144 | 2254 |
2145 // Find the newly-filled form that contains the input element. | 2255 // Find the newly-filled form that contains the input element. |
2146 FormData form2; | 2256 FormData form2; |
2147 FormFieldData field2; | 2257 FormFieldData field2; |
2148 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 2258 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2149 autofill::REQUIRE_NONE)); | 2259 &form2, |
| 2260 &field2, |
| 2261 autofill::REQUIRE_NONE)); |
2150 | 2262 |
2151 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2263 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
2152 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2264 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2153 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2265 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
2154 | 2266 |
2155 const std::vector<FormFieldData>& fields2 = form2.fields; | 2267 const std::vector<FormFieldData>& fields2 = form2.fields; |
2156 ASSERT_EQ(3U, fields2.size()); | 2268 ASSERT_EQ(3U, fields2.size()); |
2157 | 2269 |
2158 expected.form_control_type = "text"; | 2270 expected.form_control_type = "text"; |
2159 | 2271 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 form_cache.ExtractForms(*web_frame, &forms); | 2307 form_cache.ExtractForms(*web_frame, &forms); |
2196 ASSERT_EQ(1U, forms.size()); | 2308 ASSERT_EQ(1U, forms.size()); |
2197 | 2309 |
2198 // Get the input element we want to find. | 2310 // Get the input element we want to find. |
2199 WebElement element = web_frame->document().getElementById("firstname"); | 2311 WebElement element = web_frame->document().getElementById("firstname"); |
2200 WebInputElement input_element = element.to<WebInputElement>(); | 2312 WebInputElement input_element = element.to<WebInputElement>(); |
2201 | 2313 |
2202 // Find the form that contains the input element. | 2314 // Find the form that contains the input element. |
2203 FormData form; | 2315 FormData form; |
2204 FormFieldData field; | 2316 FormFieldData field; |
2205 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 2317 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2206 autofill::REQUIRE_NONE)); | 2318 &form, |
| 2319 &field, |
| 2320 autofill::REQUIRE_NONE)); |
2207 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 2321 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
2208 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2322 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
2209 EXPECT_EQ(GURL("http://buh.com"), form.action); | 2323 EXPECT_EQ(GURL("http://buh.com"), form.action); |
2210 | 2324 |
2211 const std::vector<FormFieldData>& fields = form.fields; | 2325 const std::vector<FormFieldData>& fields = form.fields; |
2212 ASSERT_EQ(3U, fields.size()); | 2326 ASSERT_EQ(3U, fields.size()); |
2213 | 2327 |
2214 FormFieldData expected; | 2328 FormFieldData expected; |
2215 expected.form_control_type = "text"; | 2329 expected.form_control_type = "text"; |
2216 expected.max_length = WebInputElement::defaultMaxLength(); | 2330 expected.max_length = WebInputElement::defaultMaxLength(); |
2217 | 2331 |
2218 expected.name = ASCIIToUTF16("firstname"); | 2332 expected.name = ASCIIToUTF16("firstname"); |
2219 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); | 2333 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); |
2220 | 2334 |
2221 expected.name = ASCIIToUTF16("lastname"); | 2335 expected.name = ASCIIToUTF16("lastname"); |
2222 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 2336 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
2223 | 2337 |
2224 expected.name = ASCIIToUTF16("email"); | 2338 expected.name = ASCIIToUTF16("email"); |
2225 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2339 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
2226 | 2340 |
2227 // Fill the form. | 2341 // Fill the form. |
2228 form.fields[0].value = ASCIIToUTF16("Brother"); | 2342 form.fields[0].value = ASCIIToUTF16("Brother"); |
2229 form.fields[1].value = ASCIIToUTF16("Jonathan"); | 2343 form.fields[1].value = ASCIIToUTF16("Jonathan"); |
2230 form.fields[2].value = ASCIIToUTF16("brotherj@example.com"); | 2344 form.fields[2].value = ASCIIToUTF16("brotherj@example.com"); |
2231 FillForm(form, input_element); | 2345 FillForm(form, input_element); |
2232 | 2346 |
2233 // Find the newly-filled form that contains the input element. | 2347 // Find the newly-filled form that contains the input element. |
2234 FormData form2; | 2348 FormData form2; |
2235 FormFieldData field2; | 2349 FormFieldData field2; |
2236 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 2350 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2237 autofill::REQUIRE_NONE)); | 2351 &form2, |
| 2352 &field2, |
| 2353 autofill::REQUIRE_NONE)); |
2238 | 2354 |
2239 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2355 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
2240 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2356 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2241 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2357 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
2242 | 2358 |
2243 const std::vector<FormFieldData>& fields2 = form2.fields; | 2359 const std::vector<FormFieldData>& fields2 = form2.fields; |
2244 ASSERT_EQ(3U, fields2.size()); | 2360 ASSERT_EQ(3U, fields2.size()); |
2245 | 2361 |
2246 expected.name = ASCIIToUTF16("firstname"); | 2362 expected.name = ASCIIToUTF16("firstname"); |
2247 expected.value = ASCIIToUTF16("Brother"); | 2363 expected.value = ASCIIToUTF16("Brother"); |
(...skipping 24 matching lines...) Expand all Loading... |
2272 form_cache.ExtractForms(*web_frame, &forms); | 2388 form_cache.ExtractForms(*web_frame, &forms); |
2273 ASSERT_EQ(1U, forms.size()); | 2389 ASSERT_EQ(1U, forms.size()); |
2274 | 2390 |
2275 // Get the input element we want to find. | 2391 // Get the input element we want to find. |
2276 WebElement element = web_frame->document().getElementById("firstname"); | 2392 WebElement element = web_frame->document().getElementById("firstname"); |
2277 WebInputElement input_element = element.to<WebInputElement>(); | 2393 WebInputElement input_element = element.to<WebInputElement>(); |
2278 | 2394 |
2279 // Find the form that contains the input element. | 2395 // Find the form that contains the input element. |
2280 FormData form; | 2396 FormData form; |
2281 FormFieldData field; | 2397 FormFieldData field; |
2282 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 2398 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2283 autofill::REQUIRE_NONE)); | 2399 &form, |
| 2400 &field, |
| 2401 autofill::REQUIRE_NONE)); |
2284 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 2402 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
2285 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2403 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
2286 EXPECT_EQ(GURL("http://buh.com"), form.action); | 2404 EXPECT_EQ(GURL("http://buh.com"), form.action); |
2287 | 2405 |
2288 const std::vector<FormFieldData>& fields = form.fields; | 2406 const std::vector<FormFieldData>& fields = form.fields; |
2289 ASSERT_EQ(3U, fields.size()); | 2407 ASSERT_EQ(3U, fields.size()); |
2290 | 2408 |
2291 FormFieldData expected; | 2409 FormFieldData expected; |
2292 expected.form_control_type = "text"; | 2410 expected.form_control_type = "text"; |
2293 expected.max_length = WebInputElement::defaultMaxLength(); | 2411 expected.max_length = WebInputElement::defaultMaxLength(); |
2294 | 2412 |
2295 expected.name = ASCIIToUTF16("firstname"); | 2413 expected.name = ASCIIToUTF16("firstname"); |
2296 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); | 2414 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]); |
2297 | 2415 |
2298 expected.name = ASCIIToUTF16("lastname"); | 2416 expected.name = ASCIIToUTF16("lastname"); |
2299 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 2417 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
2300 | 2418 |
2301 expected.name = ASCIIToUTF16("email"); | 2419 expected.name = ASCIIToUTF16("email"); |
2302 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 2420 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
2303 | 2421 |
2304 // Fill the form. | 2422 // Fill the form. |
2305 form.fields[0].value = ASCIIToUTF16("Wyatt"); | 2423 form.fields[0].value = ASCIIToUTF16("Wyatt"); |
2306 form.fields[1].value = ASCIIToUTF16("Earp"); | 2424 form.fields[1].value = ASCIIToUTF16("Earp"); |
2307 form.fields[2].value = ASCIIToUTF16("wyatt@example.com"); | 2425 form.fields[2].value = ASCIIToUTF16("wyatt@example.com"); |
2308 FillForm(form, input_element); | 2426 FillForm(form, input_element); |
2309 | 2427 |
2310 // Find the newly-filled form that contains the input element. | 2428 // Find the newly-filled form that contains the input element. |
2311 FormData form2; | 2429 FormData form2; |
2312 FormFieldData field2; | 2430 FormFieldData field2; |
2313 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 2431 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2314 autofill::REQUIRE_NONE)); | 2432 &form2, |
| 2433 &field2, |
| 2434 autofill::REQUIRE_NONE)); |
2315 | 2435 |
2316 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2436 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
2317 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2437 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2318 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2438 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
2319 | 2439 |
2320 const std::vector<FormFieldData>& fields2 = form2.fields; | 2440 const std::vector<FormFieldData>& fields2 = form2.fields; |
2321 ASSERT_EQ(3U, fields2.size()); | 2441 ASSERT_EQ(3U, fields2.size()); |
2322 | 2442 |
2323 expected.form_control_type = "text"; | 2443 expected.form_control_type = "text"; |
2324 expected.max_length = WebInputElement::defaultMaxLength(); | 2444 expected.max_length = WebInputElement::defaultMaxLength(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2358 form_cache.ExtractForms(*web_frame, &forms); | 2478 form_cache.ExtractForms(*web_frame, &forms); |
2359 ASSERT_EQ(2U, forms.size()); | 2479 ASSERT_EQ(2U, forms.size()); |
2360 | 2480 |
2361 // Get the input element we want to find. | 2481 // Get the input element we want to find. |
2362 WebElement element = web_frame->document().getElementById("apple"); | 2482 WebElement element = web_frame->document().getElementById("apple"); |
2363 WebInputElement input_element = element.to<WebInputElement>(); | 2483 WebInputElement input_element = element.to<WebInputElement>(); |
2364 | 2484 |
2365 // Find the form that contains the input element. | 2485 // Find the form that contains the input element. |
2366 FormData form; | 2486 FormData form; |
2367 FormFieldData field; | 2487 FormFieldData field; |
2368 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 2488 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2369 autofill::REQUIRE_NONE)); | 2489 &form, |
| 2490 &field, |
| 2491 autofill::REQUIRE_NONE)); |
2370 EXPECT_EQ(base::string16(), form.name); | 2492 EXPECT_EQ(base::string16(), form.name); |
2371 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2493 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
2372 EXPECT_EQ(GURL("http://abc.com"), form.action); | 2494 EXPECT_EQ(GURL("http://abc.com"), form.action); |
2373 | 2495 |
2374 const std::vector<FormFieldData>& fields = form.fields; | 2496 const std::vector<FormFieldData>& fields = form.fields; |
2375 ASSERT_EQ(3U, fields.size()); | 2497 ASSERT_EQ(3U, fields.size()); |
2376 | 2498 |
2377 FormFieldData expected; | 2499 FormFieldData expected; |
2378 expected.form_control_type = "text"; | 2500 expected.form_control_type = "text"; |
2379 expected.max_length = WebInputElement::defaultMaxLength(); | 2501 expected.max_length = WebInputElement::defaultMaxLength(); |
(...skipping 12 matching lines...) Expand all Loading... |
2392 | 2514 |
2393 // Fill the form. | 2515 // Fill the form. |
2394 form.fields[0].value = ASCIIToUTF16("Red"); | 2516 form.fields[0].value = ASCIIToUTF16("Red"); |
2395 form.fields[1].value = ASCIIToUTF16("Yellow"); | 2517 form.fields[1].value = ASCIIToUTF16("Yellow"); |
2396 form.fields[2].value = ASCIIToUTF16("Also Yellow"); | 2518 form.fields[2].value = ASCIIToUTF16("Also Yellow"); |
2397 FillForm(form, input_element); | 2519 FillForm(form, input_element); |
2398 | 2520 |
2399 // Find the newly-filled form that contains the input element. | 2521 // Find the newly-filled form that contains the input element. |
2400 FormData form2; | 2522 FormData form2; |
2401 FormFieldData field2; | 2523 FormFieldData field2; |
2402 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 2524 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2403 autofill::REQUIRE_NONE)); | 2525 &form2, |
| 2526 &field2, |
| 2527 autofill::REQUIRE_NONE)); |
2404 | 2528 |
2405 EXPECT_EQ(base::string16(), form2.name); | 2529 EXPECT_EQ(base::string16(), form2.name); |
2406 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2530 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2407 EXPECT_EQ(GURL("http://abc.com"), form2.action); | 2531 EXPECT_EQ(GURL("http://abc.com"), form2.action); |
2408 | 2532 |
2409 const std::vector<FormFieldData>& fields2 = form2.fields; | 2533 const std::vector<FormFieldData>& fields2 = form2.fields; |
2410 ASSERT_EQ(3U, fields2.size()); | 2534 ASSERT_EQ(3U, fields2.size()); |
2411 | 2535 |
2412 expected.name = ASCIIToUTF16("apple"); | 2536 expected.name = ASCIIToUTF16("apple"); |
2413 expected.value = ASCIIToUTF16("Red"); | 2537 expected.value = ASCIIToUTF16("Red"); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 // Get the input element we want to find. | 2701 // Get the input element we want to find. |
2578 WebElement element = web_frame->document().getElementById("firstname"); | 2702 WebElement element = web_frame->document().getElementById("firstname"); |
2579 WebInputElement input_element = element.to<WebInputElement>(); | 2703 WebInputElement input_element = element.to<WebInputElement>(); |
2580 | 2704 |
2581 // Simulate typing by modifying the field value. | 2705 // Simulate typing by modifying the field value. |
2582 input_element.setValue(ASCIIToUTF16("Wy")); | 2706 input_element.setValue(ASCIIToUTF16("Wy")); |
2583 | 2707 |
2584 // Find the form that contains the input element. | 2708 // Find the form that contains the input element. |
2585 FormData form; | 2709 FormData form; |
2586 FormFieldData field; | 2710 FormFieldData field; |
2587 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form, &field, | 2711 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2588 autofill::REQUIRE_NONE)); | 2712 &form, |
| 2713 &field, |
| 2714 autofill::REQUIRE_NONE)); |
2589 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); | 2715 EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name); |
2590 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); | 2716 EXPECT_EQ(GURL(web_frame->document().url()), form.origin); |
2591 EXPECT_EQ(GURL("http://buh.com"), form.action); | 2717 EXPECT_EQ(GURL("http://buh.com"), form.action); |
2592 | 2718 |
2593 const std::vector<FormFieldData>& fields = form.fields; | 2719 const std::vector<FormFieldData>& fields = form.fields; |
2594 ASSERT_EQ(3U, fields.size()); | 2720 ASSERT_EQ(3U, fields.size()); |
2595 | 2721 |
2596 FormFieldData expected; | 2722 FormFieldData expected; |
2597 expected.form_control_type = "text"; | 2723 expected.form_control_type = "text"; |
2598 expected.max_length = WebInputElement::defaultMaxLength(); | 2724 expected.max_length = WebInputElement::defaultMaxLength(); |
(...skipping 20 matching lines...) Expand all Loading... |
2619 PreviewForm(form, input_element); | 2745 PreviewForm(form, input_element); |
2620 EXPECT_EQ(2, input_element.selectionStart()); | 2746 EXPECT_EQ(2, input_element.selectionStart()); |
2621 EXPECT_EQ(5, input_element.selectionEnd()); | 2747 EXPECT_EQ(5, input_element.selectionEnd()); |
2622 | 2748 |
2623 // Fill the form. | 2749 // Fill the form. |
2624 FillForm(form, input_element); | 2750 FillForm(form, input_element); |
2625 | 2751 |
2626 // Find the newly-filled form that contains the input element. | 2752 // Find the newly-filled form that contains the input element. |
2627 FormData form2; | 2753 FormData form2; |
2628 FormFieldData field2; | 2754 FormFieldData field2; |
2629 EXPECT_TRUE(FindFormAndFieldForInputElement(input_element, &form2, &field2, | 2755 EXPECT_TRUE(FindFormAndFieldForFormControlElement(input_element, |
2630 autofill::REQUIRE_NONE)); | 2756 &form2, |
| 2757 &field2, |
| 2758 autofill::REQUIRE_NONE)); |
2631 | 2759 |
2632 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2760 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
2633 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2761 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2634 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2762 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
2635 | 2763 |
2636 const std::vector<FormFieldData>& fields2 = form2.fields; | 2764 const std::vector<FormFieldData>& fields2 = form2.fields; |
2637 ASSERT_EQ(3U, fields2.size()); | 2765 ASSERT_EQ(3U, fields2.size()); |
2638 | 2766 |
2639 expected.name = ASCIIToUTF16("firstname"); | 2767 expected.name = ASCIIToUTF16("firstname"); |
2640 expected.value = ASCIIToUTF16("Wyatt"); | 2768 expected.value = ASCIIToUTF16("Wyatt"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2694 | 2822 |
2695 // Clear the form. | 2823 // Clear the form. |
2696 EXPECT_TRUE(form_cache.ClearFormWithElement(firstname)); | 2824 EXPECT_TRUE(form_cache.ClearFormWithElement(firstname)); |
2697 | 2825 |
2698 // Verify that the auto-filled attribute has been turned off. | 2826 // Verify that the auto-filled attribute has been turned off. |
2699 EXPECT_FALSE(firstname.isAutofilled()); | 2827 EXPECT_FALSE(firstname.isAutofilled()); |
2700 | 2828 |
2701 // Verify the form is cleared. | 2829 // Verify the form is cleared. |
2702 FormData form2; | 2830 FormData form2; |
2703 FormFieldData field2; | 2831 FormFieldData field2; |
2704 EXPECT_TRUE(FindFormAndFieldForInputElement(firstname, &form2, &field2, | 2832 EXPECT_TRUE(FindFormAndFieldForFormControlElement(firstname, |
2705 autofill::REQUIRE_NONE)); | 2833 &form2, |
| 2834 &field2, |
| 2835 autofill::REQUIRE_NONE)); |
2706 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2836 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
2707 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2837 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2708 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2838 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
2709 | 2839 |
2710 const std::vector<FormFieldData>& fields2 = form2.fields; | 2840 const std::vector<FormFieldData>& fields2 = form2.fields; |
2711 ASSERT_EQ(9U, fields2.size()); | 2841 ASSERT_EQ(9U, fields2.size()); |
2712 | 2842 |
2713 FormFieldData expected; | 2843 FormFieldData expected; |
2714 expected.form_control_type = "text"; | 2844 expected.form_control_type = "text"; |
2715 expected.max_length = WebInputElement::defaultMaxLength(); | 2845 expected.max_length = WebInputElement::defaultMaxLength(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2796 | 2926 |
2797 // Clear the form. | 2927 // Clear the form. |
2798 EXPECT_TRUE(form_cache.ClearFormWithElement(firstname)); | 2928 EXPECT_TRUE(form_cache.ClearFormWithElement(firstname)); |
2799 | 2929 |
2800 // Verify that the auto-filled attribute has been turned off. | 2930 // Verify that the auto-filled attribute has been turned off. |
2801 EXPECT_FALSE(firstname.isAutofilled()); | 2931 EXPECT_FALSE(firstname.isAutofilled()); |
2802 | 2932 |
2803 // Verify the form is cleared. | 2933 // Verify the form is cleared. |
2804 FormData form2; | 2934 FormData form2; |
2805 FormFieldData field2; | 2935 FormFieldData field2; |
2806 EXPECT_TRUE(FindFormAndFieldForInputElement(firstname, &form2, &field2, | 2936 EXPECT_TRUE(FindFormAndFieldForFormControlElement(firstname, |
2807 autofill::REQUIRE_NONE)); | 2937 &form2, |
| 2938 &field2, |
| 2939 autofill::REQUIRE_NONE)); |
2808 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); | 2940 EXPECT_EQ(ASCIIToUTF16("TestForm"), form2.name); |
2809 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); | 2941 EXPECT_EQ(GURL(web_frame->document().url()), form2.origin); |
2810 EXPECT_EQ(GURL("http://buh.com"), form2.action); | 2942 EXPECT_EQ(GURL("http://buh.com"), form2.action); |
2811 | 2943 |
2812 const std::vector<FormFieldData>& fields2 = form2.fields; | 2944 const std::vector<FormFieldData>& fields2 = form2.fields; |
2813 ASSERT_EQ(3U, fields2.size()); | 2945 ASSERT_EQ(3U, fields2.size()); |
2814 | 2946 |
2815 FormFieldData expected; | 2947 FormFieldData expected; |
2816 | 2948 |
2817 expected.name = ASCIIToUTF16("firstname"); | 2949 expected.name = ASCIIToUTF16("firstname"); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3214 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); | 3346 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]); |
3215 | 3347 |
3216 expected.name = ASCIIToUTF16("country"); | 3348 expected.name = ASCIIToUTF16("country"); |
3217 expected.value = ASCIIToUTF16("AL"); | 3349 expected.value = ASCIIToUTF16("AL"); |
3218 expected.form_control_type = "select-one"; | 3350 expected.form_control_type = "select-one"; |
3219 expected.max_length = 0; | 3351 expected.max_length = 0; |
3220 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); | 3352 EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]); |
3221 } | 3353 } |
3222 | 3354 |
3223 } // namespace autofill | 3355 } // namespace autofill |
OLD | NEW |