Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: chrome/browser/autofill/form_structure_unittest.cc

Issue 11198048: [Autofill] Update the autocomplete types implementation to match the current HTML spec. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: string16 -> std::string and other fixes + cleanup Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autofill/form_structure.h" 8 #include "chrome/browser/autofill/form_structure.h"
9 #include "chrome/common/form_data.h" 9 #include "chrome/common/form_data.h"
10 #include "chrome/common/form_field_data.h" 10 #include "chrome/common/form_field_data.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 }; 46 };
47 47
48 TEST(FormStructureTest, FieldCount) { 48 TEST(FormStructureTest, FieldCount) {
49 FormData form; 49 FormData form;
50 form.method = ASCIIToUTF16("post"); 50 form.method = ASCIIToUTF16("post");
51 51
52 FormFieldData field; 52 FormFieldData field;
53 field.label = ASCIIToUTF16("username"); 53 field.label = ASCIIToUTF16("username");
54 field.name = ASCIIToUTF16("username"); 54 field.name = ASCIIToUTF16("username");
55 field.form_control_type = ASCIIToUTF16("text"); 55 field.form_control_type = "text";
56 form.fields.push_back(field); 56 form.fields.push_back(field);
57 57
58 field.label = ASCIIToUTF16("password"); 58 field.label = ASCIIToUTF16("password");
59 field.name = ASCIIToUTF16("password"); 59 field.name = ASCIIToUTF16("password");
60 field.form_control_type = ASCIIToUTF16("password"); 60 field.form_control_type = "password";
61 form.fields.push_back(field); 61 form.fields.push_back(field);
62 62
63 field.label = string16(); 63 field.label = string16();
64 field.name = ASCIIToUTF16("Submit"); 64 field.name = ASCIIToUTF16("Submit");
65 field.form_control_type = ASCIIToUTF16("submit"); 65 field.form_control_type = "submit";
66 form.fields.push_back(field); 66 form.fields.push_back(field);
67 67
68 FormStructure form_structure(form); 68 FormStructure form_structure(form);
69 69
70 // All fields are counted. 70 // All fields are counted.
71 EXPECT_EQ(3U, form_structure.field_count()); 71 EXPECT_EQ(3U, form_structure.field_count());
72 } 72 }
73 73
74 TEST(FormStructureTest, AutofillCount) { 74 TEST(FormStructureTest, AutofillCount) {
75 FormData form; 75 FormData form;
76 form.method = ASCIIToUTF16("post"); 76 form.method = ASCIIToUTF16("post");
77 77
78 FormFieldData field; 78 FormFieldData field;
79 field.label = ASCIIToUTF16("username"); 79 field.label = ASCIIToUTF16("username");
80 field.name = ASCIIToUTF16("username"); 80 field.name = ASCIIToUTF16("username");
81 field.form_control_type = ASCIIToUTF16("text"); 81 field.form_control_type = "text";
82 form.fields.push_back(field); 82 form.fields.push_back(field);
83 83
84 field.label = ASCIIToUTF16("password"); 84 field.label = ASCIIToUTF16("password");
85 field.name = ASCIIToUTF16("password"); 85 field.name = ASCIIToUTF16("password");
86 field.form_control_type = ASCIIToUTF16("password"); 86 field.form_control_type = "password";
87 form.fields.push_back(field); 87 form.fields.push_back(field);
88 88
89 field.label = ASCIIToUTF16("state"); 89 field.label = ASCIIToUTF16("state");
90 field.name = ASCIIToUTF16("state"); 90 field.name = ASCIIToUTF16("state");
91 field.form_control_type = ASCIIToUTF16("select-one"); 91 field.form_control_type = "select-one";
92 form.fields.push_back(field); 92 form.fields.push_back(field);
93 93
94 field.label = string16(); 94 field.label = string16();
95 field.name = ASCIIToUTF16("Submit"); 95 field.name = ASCIIToUTF16("Submit");
96 field.form_control_type = ASCIIToUTF16("submit"); 96 field.form_control_type = "submit";
97 form.fields.push_back(field); 97 form.fields.push_back(field);
98 98
99 FormStructure form_structure(form); 99 FormStructure form_structure(form);
100 form_structure.DetermineHeuristicTypes(); 100 form_structure.DetermineHeuristicTypes();
101 101
102 // Only text and select fields that are heuristically matched are counted. 102 // Only text and select fields that are heuristically matched are counted.
103 EXPECT_EQ(1U, form_structure.autofill_count()); 103 EXPECT_EQ(1U, form_structure.autofill_count());
104 } 104 }
105 105
106 TEST(FormStructureTest, SourceURL) { 106 TEST(FormStructureTest, SourceURL) {
107 FormData form; 107 FormData form;
108 form.origin = GURL("http://www.foo.com/"); 108 form.origin = GURL("http://www.foo.com/");
109 form.method = ASCIIToUTF16("post"); 109 form.method = ASCIIToUTF16("post");
110 FormStructure form_structure(form); 110 FormStructure form_structure(form);
111 111
112 EXPECT_EQ(form.origin, form_structure.source_url()); 112 EXPECT_EQ(form.origin, form_structure.source_url());
113 } 113 }
114 114
115 TEST(FormStructureTest, IsAutofillable) { 115 TEST(FormStructureTest, IsAutofillable) {
116 scoped_ptr<FormStructure> form_structure; 116 scoped_ptr<FormStructure> form_structure;
117 FormData form; 117 FormData form;
118 118
119 // We need at least three text fields to be auto-fillable. 119 // We need at least three text fields to be auto-fillable.
120 form.method = ASCIIToUTF16("post"); 120 form.method = ASCIIToUTF16("post");
121 121
122 FormFieldData field; 122 FormFieldData field;
123 field.label = ASCIIToUTF16("username"); 123 field.label = ASCIIToUTF16("username");
124 field.name = ASCIIToUTF16("username"); 124 field.name = ASCIIToUTF16("username");
125 field.form_control_type = ASCIIToUTF16("text"); 125 field.form_control_type = "text";
126 form.fields.push_back(field); 126 form.fields.push_back(field);
127 127
128 field.label = ASCIIToUTF16("password"); 128 field.label = ASCIIToUTF16("password");
129 field.name = ASCIIToUTF16("password"); 129 field.name = ASCIIToUTF16("password");
130 field.form_control_type = ASCIIToUTF16("password"); 130 field.form_control_type = "password";
131 form.fields.push_back(field); 131 form.fields.push_back(field);
132 132
133 field.label = string16(); 133 field.label = string16();
134 field.name = ASCIIToUTF16("Submit"); 134 field.name = ASCIIToUTF16("Submit");
135 field.form_control_type = ASCIIToUTF16("submit"); 135 field.form_control_type = "submit";
136 form.fields.push_back(field); 136 form.fields.push_back(field);
137 137
138 form_structure.reset(new FormStructure(form)); 138 form_structure.reset(new FormStructure(form));
139 form_structure->DetermineHeuristicTypes(); 139 form_structure->DetermineHeuristicTypes();
140 EXPECT_FALSE(form_structure->IsAutofillable(true)); 140 EXPECT_FALSE(form_structure->IsAutofillable(true));
141 141
142 // We now have three text fields, but only two auto-fillable fields. 142 // We now have three text fields, but only two auto-fillable fields.
143 field.label = ASCIIToUTF16("First Name"); 143 field.label = ASCIIToUTF16("First Name");
144 field.name = ASCIIToUTF16("firstname"); 144 field.name = ASCIIToUTF16("firstname");
145 field.form_control_type = ASCIIToUTF16("text"); 145 field.form_control_type = "text";
146 form.fields.push_back(field); 146 form.fields.push_back(field);
147 147
148 field.label = ASCIIToUTF16("Last Name"); 148 field.label = ASCIIToUTF16("Last Name");
149 field.name = ASCIIToUTF16("lastname"); 149 field.name = ASCIIToUTF16("lastname");
150 field.form_control_type = ASCIIToUTF16("text"); 150 field.form_control_type = "text";
151 form.fields.push_back(field); 151 form.fields.push_back(field);
152 152
153 form_structure.reset(new FormStructure(form)); 153 form_structure.reset(new FormStructure(form));
154 form_structure->DetermineHeuristicTypes(); 154 form_structure->DetermineHeuristicTypes();
155 EXPECT_FALSE(form_structure->IsAutofillable(true)); 155 EXPECT_FALSE(form_structure->IsAutofillable(true));
156 156
157 // We now have three auto-fillable fields. 157 // We now have three auto-fillable fields.
158 field.label = ASCIIToUTF16("Email"); 158 field.label = ASCIIToUTF16("Email");
159 field.name = ASCIIToUTF16("email"); 159 field.name = ASCIIToUTF16("email");
160 field.form_control_type = ASCIIToUTF16("email"); 160 field.form_control_type = "email";
161 form.fields.push_back(field); 161 form.fields.push_back(field);
162 162
163 form_structure.reset(new FormStructure(form)); 163 form_structure.reset(new FormStructure(form));
164 form_structure->DetermineHeuristicTypes(); 164 form_structure->DetermineHeuristicTypes();
165 EXPECT_TRUE(form_structure->IsAutofillable(true)); 165 EXPECT_TRUE(form_structure->IsAutofillable(true));
166 166
167 // The method must be 'post', though we can intentionally ignore this 167 // The method must be 'post', though we can intentionally ignore this
168 // criterion for the sake of providing a helpful warning message to the user. 168 // criterion for the sake of providing a helpful warning message to the user.
169 form.method = ASCIIToUTF16("get"); 169 form.method = ASCIIToUTF16("get");
170 form_structure.reset(new FormStructure(form)); 170 form_structure.reset(new FormStructure(form));
(...skipping 18 matching lines...) Expand all
189 TEST(FormStructureTest, ShouldBeParsed) { 189 TEST(FormStructureTest, ShouldBeParsed) {
190 scoped_ptr<FormStructure> form_structure; 190 scoped_ptr<FormStructure> form_structure;
191 FormData form; 191 FormData form;
192 192
193 // We need at least three text fields to be parseable. 193 // We need at least three text fields to be parseable.
194 form.method = ASCIIToUTF16("post"); 194 form.method = ASCIIToUTF16("post");
195 195
196 FormFieldData field; 196 FormFieldData field;
197 field.label = ASCIIToUTF16("username"); 197 field.label = ASCIIToUTF16("username");
198 field.name = ASCIIToUTF16("username"); 198 field.name = ASCIIToUTF16("username");
199 field.form_control_type = ASCIIToUTF16("text"); 199 field.form_control_type = "text";
200 form.fields.push_back(field); 200 form.fields.push_back(field);
201 201
202 form_structure.reset(new FormStructure(form)); 202 form_structure.reset(new FormStructure(form));
203 EXPECT_FALSE(form_structure->ShouldBeParsed(true)); 203 EXPECT_FALSE(form_structure->ShouldBeParsed(true));
204 204
205 // We now have three text fields, though only two are auto-fillable. 205 // We now have three text fields, though only two are auto-fillable.
206 field.label = ASCIIToUTF16("First Name"); 206 field.label = ASCIIToUTF16("First Name");
207 field.name = ASCIIToUTF16("firstname"); 207 field.name = ASCIIToUTF16("firstname");
208 field.form_control_type = ASCIIToUTF16("text"); 208 field.form_control_type = "text";
209 form.fields.push_back(field); 209 form.fields.push_back(field);
210 210
211 field.label = ASCIIToUTF16("Last Name"); 211 field.label = ASCIIToUTF16("Last Name");
212 field.name = ASCIIToUTF16("lastname"); 212 field.name = ASCIIToUTF16("lastname");
213 field.form_control_type = ASCIIToUTF16("text"); 213 field.form_control_type = "text";
214 form.fields.push_back(field); 214 form.fields.push_back(field);
215 215
216 form_structure.reset(new FormStructure(form)); 216 form_structure.reset(new FormStructure(form));
217 EXPECT_TRUE(form_structure->ShouldBeParsed(true)); 217 EXPECT_TRUE(form_structure->ShouldBeParsed(true));
218 218
219 // The method must be 'post', though we can intentionally ignore this 219 // The method must be 'post', though we can intentionally ignore this
220 // criterion for the sake of providing a helpful warning message to the user. 220 // criterion for the sake of providing a helpful warning message to the user.
221 form.method = ASCIIToUTF16("get"); 221 form.method = ASCIIToUTF16("get");
222 form_structure.reset(new FormStructure(form)); 222 form_structure.reset(new FormStructure(form));
223 EXPECT_FALSE(form_structure->IsAutofillable(true)); 223 EXPECT_FALSE(form_structure->IsAutofillable(true));
224 EXPECT_TRUE(form_structure->ShouldBeParsed(false)); 224 EXPECT_TRUE(form_structure->ShouldBeParsed(false));
225 225
226 // The target cannot include http(s)://*/search... 226 // The target cannot include http(s)://*/search...
227 form.method = ASCIIToUTF16("post"); 227 form.method = ASCIIToUTF16("post");
228 form.action = GURL("http://google.com/search?q=hello"); 228 form.action = GURL("http://google.com/search?q=hello");
229 form_structure.reset(new FormStructure(form)); 229 form_structure.reset(new FormStructure(form));
230 EXPECT_FALSE(form_structure->ShouldBeParsed(true)); 230 EXPECT_FALSE(form_structure->ShouldBeParsed(true));
231 231
232 // But search can be in the URL. 232 // But search can be in the URL.
233 form.action = GURL("http://search.com/?q=hello"); 233 form.action = GURL("http://search.com/?q=hello");
234 form_structure.reset(new FormStructure(form)); 234 form_structure.reset(new FormStructure(form));
235 EXPECT_TRUE(form_structure->ShouldBeParsed(true)); 235 EXPECT_TRUE(form_structure->ShouldBeParsed(true));
236 236
237 // The form need only have three fields, but at least one must be a text 237 // The form need only have three fields, but at least one must be a text
238 // field. 238 // field.
239 form.fields.clear(); 239 form.fields.clear();
240 240
241 field.label = ASCIIToUTF16("Email"); 241 field.label = ASCIIToUTF16("Email");
242 field.name = ASCIIToUTF16("email"); 242 field.name = ASCIIToUTF16("email");
243 field.form_control_type = ASCIIToUTF16("email"); 243 field.form_control_type = "email";
244 form.fields.push_back(field); 244 form.fields.push_back(field);
245 245
246 field.label = ASCIIToUTF16("State"); 246 field.label = ASCIIToUTF16("State");
247 field.name = ASCIIToUTF16("state"); 247 field.name = ASCIIToUTF16("state");
248 field.form_control_type = ASCIIToUTF16("select-one"); 248 field.form_control_type = "select-one";
249 form.fields.push_back(field); 249 form.fields.push_back(field);
250 250
251 field.label = ASCIIToUTF16("Country"); 251 field.label = ASCIIToUTF16("Country");
252 field.name = ASCIIToUTF16("country"); 252 field.name = ASCIIToUTF16("country");
253 field.form_control_type = ASCIIToUTF16("select-one"); 253 field.form_control_type = "select-one";
254 form.fields.push_back(field); 254 form.fields.push_back(field);
255 255
256 form_structure.reset(new FormStructure(form)); 256 form_structure.reset(new FormStructure(form));
257 EXPECT_TRUE(form_structure->ShouldBeParsed(true)); 257 EXPECT_TRUE(form_structure->ShouldBeParsed(true));
258 258
259 form.fields[0].form_control_type = ASCIIToUTF16("select-one"); 259 form.fields[0].form_control_type = "select-one";
260 form_structure.reset(new FormStructure(form)); 260 form_structure.reset(new FormStructure(form));
261 EXPECT_FALSE(form_structure->ShouldBeParsed(true)); 261 EXPECT_FALSE(form_structure->ShouldBeParsed(true));
262 } 262 }
263 263
264 TEST(FormStructureTest, HeuristicsContactInfo) { 264 TEST(FormStructureTest, HeuristicsContactInfo) {
265 scoped_ptr<FormStructure> form_structure; 265 scoped_ptr<FormStructure> form_structure;
266 FormData form; 266 FormData form;
267 form.method = ASCIIToUTF16("post"); 267 form.method = ASCIIToUTF16("post");
268 268
269 FormFieldData field; 269 FormFieldData field;
270 field.form_control_type = ASCIIToUTF16("text"); 270 field.form_control_type = "text";
271 271
272 field.label = ASCIIToUTF16("First Name"); 272 field.label = ASCIIToUTF16("First Name");
273 field.name = ASCIIToUTF16("firstname"); 273 field.name = ASCIIToUTF16("firstname");
274 form.fields.push_back(field); 274 form.fields.push_back(field);
275 275
276 field.label = ASCIIToUTF16("Last Name"); 276 field.label = ASCIIToUTF16("Last Name");
277 field.name = ASCIIToUTF16("lastname"); 277 field.name = ASCIIToUTF16("lastname");
278 form.fields.push_back(field); 278 form.fields.push_back(field);
279 279
280 field.label = ASCIIToUTF16("Email"); 280 field.label = ASCIIToUTF16("Email");
(...skipping 11 matching lines...) Expand all
292 field.label = ASCIIToUTF16("City"); 292 field.label = ASCIIToUTF16("City");
293 field.name = ASCIIToUTF16("city"); 293 field.name = ASCIIToUTF16("city");
294 form.fields.push_back(field); 294 form.fields.push_back(field);
295 295
296 field.label = ASCIIToUTF16("Zip code"); 296 field.label = ASCIIToUTF16("Zip code");
297 field.name = ASCIIToUTF16("zipcode"); 297 field.name = ASCIIToUTF16("zipcode");
298 form.fields.push_back(field); 298 form.fields.push_back(field);
299 299
300 field.label = string16(); 300 field.label = string16();
301 field.name = ASCIIToUTF16("Submit"); 301 field.name = ASCIIToUTF16("Submit");
302 field.form_control_type = ASCIIToUTF16("submit"); 302 field.form_control_type = "submit";
303 form.fields.push_back(field); 303 form.fields.push_back(field);
304 304
305 form_structure.reset(new FormStructure(form)); 305 form_structure.reset(new FormStructure(form));
306 form_structure->DetermineHeuristicTypes(); 306 form_structure->DetermineHeuristicTypes();
307 EXPECT_TRUE(form_structure->IsAutofillable(true)); 307 EXPECT_TRUE(form_structure->IsAutofillable(true));
308 308
309 // Expect the correct number of fields. 309 // Expect the correct number of fields.
310 ASSERT_EQ(8U, form_structure->field_count()); 310 ASSERT_EQ(8U, form_structure->field_count());
311 ASSERT_EQ(7U, form_structure->autofill_count()); 311 ASSERT_EQ(7U, form_structure->autofill_count());
312 312
313 // First name. 313 // First name.
314 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 314 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
315 // Last name. 315 // Last name.
316 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 316 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
317 // Email. 317 // Email.
318 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 318 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
319 // Phone. 319 // Phone.
320 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, 320 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER,
321 form_structure->field(3)->heuristic_type()); 321 form_structure->field(3)->heuristic_type());
322 // Address. 322 // Address.
323 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(4)->heuristic_type()); 323 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(4)->heuristic_type());
324 // City. 324 // City.
325 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type()); 325 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(5)->heuristic_type());
326 // Zip. 326 // Zip.
327 EXPECT_EQ(ADDRESS_HOME_ZIP, form_structure->field(6)->heuristic_type()); 327 EXPECT_EQ(ADDRESS_HOME_ZIP, form_structure->field(6)->heuristic_type());
328 // Submit. 328 // Submit.
329 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(7)->heuristic_type()); 329 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(7)->heuristic_type());
330 } 330 }
331 331
332 // Verify that we can correctly process the |autocompletetype| attribute. 332 // Verify that we can correctly process the |autocomplete| attribute.
333 TEST(FormStructureTest, HeuristicsAutocompletetype) { 333 TEST(FormStructureTest, HeuristicsAutocompleteAttribute) {
334 scoped_ptr<FormStructure> form_structure; 334 scoped_ptr<FormStructure> form_structure;
335 FormData form; 335 FormData form;
336 form.method = ASCIIToUTF16("post"); 336 form.method = ASCIIToUTF16("post");
337 337
338 FormFieldData field; 338 FormFieldData field;
339 field.form_control_type = ASCIIToUTF16("text"); 339 field.form_control_type = "text";
340 340
341 field.label = string16(); 341 field.label = string16();
342 field.name = ASCIIToUTF16("field1"); 342 field.name = ASCIIToUTF16("field1");
343 field.autocomplete_type = ASCIIToUTF16("given-name"); 343 field.autocomplete_attribute = "given-name";
344 form.fields.push_back(field); 344 form.fields.push_back(field);
345 345
346 field.label = string16(); 346 field.label = string16();
347 field.name = ASCIIToUTF16("field2"); 347 field.name = ASCIIToUTF16("field2");
348 field.autocomplete_type = ASCIIToUTF16("surname"); 348 field.autocomplete_attribute = "family-name";
349 form.fields.push_back(field); 349 form.fields.push_back(field);
350 350
351 field.label = string16(); 351 field.label = string16();
352 field.name = ASCIIToUTF16("field3"); 352 field.name = ASCIIToUTF16("field3");
353 field.autocomplete_type = ASCIIToUTF16("email"); 353 field.autocomplete_attribute = "email";
354 form.fields.push_back(field); 354 form.fields.push_back(field);
355 355
356 form_structure.reset(new FormStructure(form)); 356 form_structure.reset(new FormStructure(form));
357 form_structure->DetermineHeuristicTypes(); 357 form_structure->DetermineHeuristicTypes();
358 EXPECT_TRUE(form_structure->IsAutofillable(true)); 358 EXPECT_TRUE(form_structure->IsAutofillable(true));
359 359
360 // Expect the correct number of fields. 360 // Expect the correct number of fields.
361 ASSERT_EQ(3U, form_structure->field_count()); 361 ASSERT_EQ(3U, form_structure->field_count());
362 ASSERT_EQ(3U, form_structure->autofill_count()); 362 ASSERT_EQ(3U, form_structure->autofill_count());
363 363
364 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 364 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
365 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 365 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
366 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 366 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
367 } 367 }
368 368
369 // Verify that we can correctly process the |autocompletetype| attribute for 369 // Verify that we can correctly process the 'autocomplete' attribute for phone
370 // phone number types (especially phone prefixes and suffixes). 370 // number types (especially phone prefixes and suffixes).
371 TEST(FormStructureTest, HeuristicsAutocompletetypePhones) { 371 TEST(FormStructureTest, HeuristicsAutocompleteAttributePhoneTypes) {
372 scoped_ptr<FormStructure> form_structure; 372 scoped_ptr<FormStructure> form_structure;
373 FormData form; 373 FormData form;
374 form.method = ASCIIToUTF16("post"); 374 form.method = ASCIIToUTF16("post");
375 375
376 FormFieldData field; 376 FormFieldData field;
377 field.form_control_type = ASCIIToUTF16("text"); 377 field.form_control_type = "text";
378 378
379 field.label = string16(); 379 field.label = string16();
380 field.name = ASCIIToUTF16("field1"); 380 field.name = ASCIIToUTF16("field1");
381 field.autocomplete_type = ASCIIToUTF16("phone-local"); 381 field.autocomplete_attribute = "tel-local";
382 form.fields.push_back(field); 382 form.fields.push_back(field);
383 383
384 field.label = string16(); 384 field.label = string16();
385 field.name = ASCIIToUTF16("field2"); 385 field.name = ASCIIToUTF16("field2");
386 field.autocomplete_type = ASCIIToUTF16("phone-local-prefix"); 386 field.autocomplete_attribute = "tel-local-prefix";
387 form.fields.push_back(field); 387 form.fields.push_back(field);
388 388
389 field.label = string16(); 389 field.label = string16();
390 field.name = ASCIIToUTF16("field3"); 390 field.name = ASCIIToUTF16("field3");
391 field.autocomplete_type = ASCIIToUTF16("phone-local-suffix"); 391 field.autocomplete_attribute = "tel-local-suffix";
392 form.fields.push_back(field); 392 form.fields.push_back(field);
393 393
394 form_structure.reset(new FormStructure(form)); 394 form_structure.reset(new FormStructure(form));
395 form_structure->DetermineHeuristicTypes(); 395 form_structure->DetermineHeuristicTypes();
396 EXPECT_TRUE(form_structure->IsAutofillable(true)); 396 EXPECT_TRUE(form_structure->IsAutofillable(true));
397 397
398 // Expect the correct number of fields. 398 // Expect the correct number of fields.
399 ASSERT_EQ(3U, form_structure->field_count()); 399 ASSERT_EQ(3U, form_structure->field_count());
400 EXPECT_EQ(3U, form_structure->autofill_count()); 400 EXPECT_EQ(3U, form_structure->autofill_count());
401 401
402 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(0)->heuristic_type()); 402 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(0)->heuristic_type());
403 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part()); 403 EXPECT_EQ(AutofillField::IGNORED, form_structure->field(0)->phone_part());
404 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(1)->heuristic_type()); 404 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(1)->heuristic_type());
405 EXPECT_EQ(AutofillField::PHONE_PREFIX, 405 EXPECT_EQ(AutofillField::PHONE_PREFIX,
406 form_structure->field(1)->phone_part()); 406 form_structure->field(1)->phone_part());
407 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(2)->heuristic_type()); 407 EXPECT_EQ(PHONE_HOME_NUMBER, form_structure->field(2)->heuristic_type());
408 EXPECT_EQ(AutofillField::PHONE_SUFFIX, 408 EXPECT_EQ(AutofillField::PHONE_SUFFIX,
409 form_structure->field(2)->phone_part()); 409 form_structure->field(2)->phone_part());
410 } 410 }
411 411
412 // If at least one field includes the |autocompletetype| attribute, we should 412 // If at least one field includes type hints in the 'autocomplete' attribute, we
413 // not try to apply any other heuristics. 413 // should not try to apply any other heuristics.
414 TEST(FormStructureTest, AutocompletetypeOverridesOtherHeuristics) { 414 TEST(FormStructureTest, AutocompleteAttributeOverridesOtherHeuristics) {
415 scoped_ptr<FormStructure> form_structure; 415 scoped_ptr<FormStructure> form_structure;
416 FormData form; 416 FormData form;
417 form.method = ASCIIToUTF16("post"); 417 form.method = ASCIIToUTF16("post");
418 418
419 // Start with a regular contact form. 419 // Start with a regular contact form.
420 FormFieldData field; 420 FormFieldData field;
421 field.form_control_type = ASCIIToUTF16("text"); 421 field.form_control_type = "text";
422 422
423 field.label = ASCIIToUTF16("First Name"); 423 field.label = ASCIIToUTF16("First Name");
424 field.name = ASCIIToUTF16("firstname"); 424 field.name = ASCIIToUTF16("firstname");
425 form.fields.push_back(field); 425 form.fields.push_back(field);
426 426
427 field.label = ASCIIToUTF16("Last Name"); 427 field.label = ASCIIToUTF16("Last Name");
428 field.name = ASCIIToUTF16("lastname"); 428 field.name = ASCIIToUTF16("lastname");
429 form.fields.push_back(field); 429 form.fields.push_back(field);
430 430
431 field.label = ASCIIToUTF16("Email"); 431 field.label = ASCIIToUTF16("Email");
432 field.name = ASCIIToUTF16("email"); 432 field.name = ASCIIToUTF16("email");
433 form.fields.push_back(field); 433 form.fields.push_back(field);
434 434
435 form_structure.reset(new FormStructure(form)); 435 form_structure.reset(new FormStructure(form));
436 form_structure->DetermineHeuristicTypes(); 436 form_structure->DetermineHeuristicTypes();
437 EXPECT_TRUE(form_structure->IsAutofillable(true)); 437 EXPECT_TRUE(form_structure->IsAutofillable(true));
438 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); 438 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced());
439 439
440 ASSERT_EQ(3U, form_structure->field_count()); 440 ASSERT_EQ(3U, form_structure->field_count());
441 ASSERT_EQ(3U, form_structure->autofill_count()); 441 ASSERT_EQ(3U, form_structure->autofill_count());
442 442
443 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 443 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
444 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 444 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
445 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 445 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
446 446
447 // Now update the first form field to include an 'autocompletetype' attribute. 447 // Now update the first form field to include an 'autocomplete' attribute.
448 form.fields.front().autocomplete_type = ASCIIToUTF16("x-other"); 448 form.fields.front().autocomplete_attribute = "x-other";
449 form_structure.reset(new FormStructure(form)); 449 form_structure.reset(new FormStructure(form));
450 form_structure->DetermineHeuristicTypes(); 450 form_structure->DetermineHeuristicTypes();
451 EXPECT_FALSE(form_structure->IsAutofillable(true)); 451 EXPECT_FALSE(form_structure->IsAutofillable(true));
452 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); 452 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced());
453 453
454 ASSERT_EQ(3U, form_structure->field_count()); 454 ASSERT_EQ(3U, form_structure->field_count());
455 ASSERT_EQ(0U, form_structure->autofill_count()); 455 ASSERT_EQ(0U, form_structure->autofill_count());
456 456
457 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); 457 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type());
458 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); 458 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type());
459 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); 459 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type());
460 } 460 }
461 461
462 // Verify that we can correctly process sections listed in the |autocomplete| 462 // Verify that we can correctly process sections listed in the |autocomplete|
463 // attribute. 463 // attribute.
464 TEST(FormStructureTest, HeuristicsAutocompletetypeWithSections) { 464 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) {
465 scoped_ptr<FormStructure> form_structure; 465 FormData form;
466 FormData form; 466 form.method = ASCIIToUTF16("post");
467 form.method = ASCIIToUTF16("post"); 467
468 468 FormFieldData field;
469 FormFieldData field; 469 field.form_control_type = "text";
470 field.form_control_type = ASCIIToUTF16("text"); 470
471 471 // Some fields will have no section specified. These fall into the default
472 // We expect "shipping" and "billing" to be the most common sections. 472 // section.
473 field.label = string16(); 473 field.autocomplete_attribute = "email";
474 field.name = ASCIIToUTF16("field1");
475 field.autocomplete_type = ASCIIToUTF16("section-shipping given-name");
476 form.fields.push_back(field);
477
478 // Some field will have no section specified. These fall into the default
479 // section, with an empty name.
480 field.label = string16();
481 field.name = ASCIIToUTF16("field2");
482 field.autocomplete_type = ASCIIToUTF16("surname");
483 form.fields.push_back(field); 474 form.fields.push_back(field);
484 475
485 // We allow arbitrary section names. 476 // We allow arbitrary section names.
486 field.label = string16(); 477 field.autocomplete_attribute = "section-foo email";
487 field.name = ASCIIToUTF16("field3"); 478 form.fields.push_back(field);
488 field.autocomplete_type = ASCIIToUTF16("section-foo address-line1"); 479
489 form.fields.push_back(field); 480 // "shipping" and "billing" are special section tokens that don't require the
490 481 // "section-" prefix.
491 // Specifying "section-" is equivalent to not specifying a section. 482 field.autocomplete_attribute = "shipping email";
492 field.label = string16(); 483 form.fields.push_back(field);
493 field.name = ASCIIToUTF16("field4"); 484 field.autocomplete_attribute = "billing email";
494 field.autocomplete_type = ASCIIToUTF16("section- address-line2"); 485 form.fields.push_back(field);
486
487 // "shipping" and "billing" can be combined with other section names.
488 field.autocomplete_attribute = "section-foo shipping email";
489 form.fields.push_back(field);
490 field.autocomplete_attribute = "section-foo billing email";
495 form.fields.push_back(field); 491 form.fields.push_back(field);
496 492
497 // We don't do anything clever to try to coalesce sections; it's up to site 493 // We don't do anything clever to try to coalesce sections; it's up to site
498 // authors to avoid typos. 494 // authors to avoid typos.
499 field.label = string16(); 495 field.autocomplete_attribute = "section--foo email";
500 field.name = ASCIIToUTF16("field5"); 496 form.fields.push_back(field);
501 field.autocomplete_type = ASCIIToUTF16("section--shipping locality"); 497
498 // "shipping email" and "section--shipping" email should be parsed as
499 // different sections. This is only an interesting test due to how we
500 // implement implicit section names from attributes like "shipping email"; see
501 // the implementation for more details.
502 field.autocomplete_attribute = "section--shipping email";
502 form.fields.push_back(field); 503 form.fields.push_back(field);
503 504
504 // Credit card fields are implicitly in a separate section from other fields. 505 // Credit card fields are implicitly in a separate section from other fields.
505 field.label = string16(); 506 field.autocomplete_attribute = "section-foo cc-number";
506 field.name = ASCIIToUTF16("field6"); 507 form.fields.push_back(field);
507 field.autocomplete_type = ASCIIToUTF16("section-shipping cc-number"); 508
508 form.fields.push_back(field); 509 FormStructure form_structure(form);
509 510 form_structure.DetermineHeuristicTypes();
510 form_structure.reset(new FormStructure(form)); 511 EXPECT_TRUE(form_structure.IsAutofillable(true));
511 form_structure->DetermineHeuristicTypes(); 512
512 EXPECT_TRUE(form_structure->IsAutofillable(true)); 513 // Expect the correct number of fields.
513 514 ASSERT_EQ(9U, form_structure.field_count());
514 // Expect the correct number of fields. 515 EXPECT_EQ(9U, form_structure.autofill_count());
515 ASSERT_EQ(6U, form_structure->field_count()); 516
516 ASSERT_EQ(6U, form_structure->autofill_count()); 517 // All of the fields in this form should be parsed as belonging to different
517 518 // sections.
518 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 519 std::set<std::string> section_names;
519 EXPECT_EQ(ASCIIToUTF16("shipping-default"), 520 for (size_t i = 0; i < 9; ++i) {
520 form_structure->field(0)->section()); 521 section_names.insert(form_structure.field(i)->section());
521 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 522 }
522 EXPECT_EQ(ASCIIToUTF16("-default"), form_structure->field(1)->section()); 523 EXPECT_EQ(9U, section_names.size());
523 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(2)->heuristic_type()); 524 }
524 EXPECT_EQ(ASCIIToUTF16("foo-default"), form_structure->field(2)->section()); 525
525 EXPECT_EQ(ADDRESS_HOME_LINE2, form_structure->field(3)->heuristic_type()); 526 // Verify that we can correctly process a degenerate section listed in the
526 EXPECT_EQ(ASCIIToUTF16("-default"), form_structure->field(3)->section()); 527 // |autocomplete| attribute.
527 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(4)->heuristic_type()); 528 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsDegenerate) {
528 EXPECT_EQ(ASCIIToUTF16("-shipping-default"), 529 FormData form;
529 form_structure->field(4)->section()); 530 form.method = ASCIIToUTF16("post");
530 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(5)->heuristic_type()); 531
531 EXPECT_EQ(ASCIIToUTF16("shipping-cc"), form_structure->field(5)->section()); 532 FormFieldData field;
532 } 533 field.form_control_type = "text";
533 534
534 // Verify that we can correctly process fallback types listed in the 535 // Some fields will have no section specified. These fall into the default
535 // |autocompletetype| attribute. 536 // section.
536 TEST(FormStructureTest, HeuristicsAutocompletetypeWithFallbacks) { 537 field.autocomplete_attribute = "email";
537 scoped_ptr<FormStructure> form_structure; 538 form.fields.push_back(field);
538 FormData form; 539
539 form.method = ASCIIToUTF16("post"); 540 // Specifying "section-" is equivalent to not specifying a section.
540 541 field.autocomplete_attribute = "section- email";
541 FormFieldData field; 542 form.fields.push_back(field);
542 field.form_control_type = ASCIIToUTF16("text"); 543
543 544 FormStructure form_structure(form);
544 // Skip over any sections and "x"-prefixed types. 545 form_structure.DetermineHeuristicTypes();
545 field.label = string16(); 546
546 field.name = ASCIIToUTF16("field1"); 547 // Expect the correct number of fields.
547 field.autocomplete_type = 548 ASSERT_EQ(2U, form_structure.field_count());
548 ASCIIToUTF16("section-full-name x-given-name-initial given-name"); 549 EXPECT_EQ(2U, form_structure.autofill_count());
549 form.fields.push_back(field); 550
550 551 // All of the fields in this form should be parsed as belonging to the same
551 // Stop processing once we see a known type. 552 // section.
552 field.label = string16(); 553 std::set<std::string> section_names;
553 field.name = ASCIIToUTF16("field2"); 554 for (size_t i = 0; i < 2; ++i) {
554 field.autocomplete_type = ASCIIToUTF16("section-full-name surname full-name"); 555 section_names.insert(form_structure.field(i)->section());
555 form.fields.push_back(field); 556 }
556 557 EXPECT_EQ(1U, section_names.size());
557 // Skip over unknown types even if they are not prefixed with "x-". 558 }
558 field.label = string16(); 559
559 field.name = ASCIIToUTF16("field3"); 560 // Verify that we can correctly ignore sections from an 'autocomplete' attribute
560 field.autocomplete_type = 561 // containing invalid tokens.
561 ASCIIToUTF16("section-shipping mobile-phone-full phone-full"); 562 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsInvalid) {
562 form.fields.push_back(field); 563 FormData form;
563 564 form.method = ASCIIToUTF16("post");
564 form_structure.reset(new FormStructure(form)); 565
565 form_structure->DetermineHeuristicTypes(); 566 FormFieldData field;
566 EXPECT_TRUE(form_structure->IsAutofillable(true)); 567 field.form_control_type = "text";
567 568
568 // Expect the correct number of fields. 569 // Invalid tokens should prevent us from setting a section name.
569 ASSERT_EQ(3U, form_structure->field_count()); 570 field.autocomplete_attribute = "garbage section-foo email";
570 ASSERT_EQ(3U, form_structure->autofill_count()); 571 form.fields.push_back(field);
571 572 field.autocomplete_attribute = "garbage section-bar email";
572 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 573 form.fields.push_back(field);
573 EXPECT_EQ(ASCIIToUTF16("full-name-default"), 574 field.autocomplete_attribute = "garbage shipping email";
574 form_structure->field(0)->section()); 575 form.fields.push_back(field);
575 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 576 field.autocomplete_attribute = "garbage billing email";
576 EXPECT_EQ(ASCIIToUTF16("full-name-default"), 577 form.fields.push_back(field);
577 form_structure->field(1)->section()); 578
578 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, 579 FormStructure form_structure(form);
579 form_structure->field(2)->heuristic_type()); 580 form_structure.DetermineHeuristicTypes();
580 EXPECT_EQ(ASCIIToUTF16("shipping-default"), 581
581 form_structure->field(2)->section()); 582 // Expect the correct number of fields.
583 ASSERT_EQ(4U, form_structure.field_count());
584 EXPECT_EQ(0U, form_structure.autofill_count());
585
586 // All of the fields in this form should be parsed as belonging to the same
587 // section.
588 std::set<std::string> section_names;
589 for (size_t i = 0; i < 4; ++i) {
590 section_names.insert(form_structure.field(i)->section());
591 }
592 EXPECT_EQ(1U, section_names.size());
593 }
594
595 // Verify that we can correctly process repeated sections listed in the
596 // |autocomplete| attribute.
597 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSectionsRepeated) {
598 FormData form;
599 form.method = ASCIIToUTF16("post");
600
601 FormFieldData field;
602 field.form_control_type = "text";
603
604 field.autocomplete_attribute = "section-foo email";
605 form.fields.push_back(field);
606 field.autocomplete_attribute = "section-foo street-address";
607 form.fields.push_back(field);
608
609 FormStructure form_structure(form);
610 form_structure.DetermineHeuristicTypes();
611
612 // Expect the correct number of fields.
613 ASSERT_EQ(2U, form_structure.field_count());
614 EXPECT_EQ(2U, form_structure.autofill_count());
615
616 // All of the fields in this form should be parsed as belonging to the same
617 // section.
618 std::set<std::string> section_names;
619 for (size_t i = 0; i < 2; ++i) {
620 section_names.insert(form_structure.field(i)->section());
621 }
622 EXPECT_EQ(1U, section_names.size());
623 }
624
625 // Verify that we do not override the author-specified sections from a form with
626 // local heuristics.
627 TEST(FormStructureTest, HeuristicsDontOverrideAutocompleteAttributeSections) {
628 FormData form;
629 form.method = ASCIIToUTF16("post");
630
631 FormFieldData field;
632 field.form_control_type = "text";
633
634 field.name = ASCIIToUTF16("one");
635 field.autocomplete_attribute = "street-address";
636 form.fields.push_back(field);
637 field.name = string16();
638 field.autocomplete_attribute = "section-foo email";
639 form.fields.push_back(field);
640 field.name = string16();
641 field.autocomplete_attribute = "name";
642 form.fields.push_back(field);
643 field.name = ASCIIToUTF16("two");
644 field.autocomplete_attribute = "street-address";
645 form.fields.push_back(field);
646
647 FormStructure form_structure(form);
648 form_structure.DetermineHeuristicTypes();
649
650 // Expect the correct number of fields.
651 ASSERT_EQ(4U, form_structure.field_count());
652 EXPECT_EQ(4U, form_structure.autofill_count());
653
654 // Normally, the two separate address fields would cause us to detect two
655 // separate sections; but because there is an author-specified section in this
656 // form, we do not apply these usual heuristics.
657 EXPECT_EQ(ASCIIToUTF16("one"), form_structure.field(0)->name);
658 EXPECT_EQ(ASCIIToUTF16("two"), form_structure.field(3)->name);
659 EXPECT_EQ(form_structure.field(0)->section(),
660 form_structure.field(3)->section());
582 } 661 }
583 662
584 TEST(FormStructureTest, HeuristicsSample8) { 663 TEST(FormStructureTest, HeuristicsSample8) {
585 scoped_ptr<FormStructure> form_structure; 664 scoped_ptr<FormStructure> form_structure;
586 FormData form; 665 FormData form;
587 form.method = ASCIIToUTF16("post"); 666 form.method = ASCIIToUTF16("post");
588 667
589 FormFieldData field; 668 FormFieldData field;
590 field.form_control_type = ASCIIToUTF16("text"); 669 field.form_control_type = "text";
591 670
592 field.label = ASCIIToUTF16("Your First Name:"); 671 field.label = ASCIIToUTF16("Your First Name:");
593 field.name = ASCIIToUTF16("bill.first"); 672 field.name = ASCIIToUTF16("bill.first");
594 form.fields.push_back(field); 673 form.fields.push_back(field);
595 674
596 field.label = ASCIIToUTF16("Your Last Name:"); 675 field.label = ASCIIToUTF16("Your Last Name:");
597 field.name = ASCIIToUTF16("bill.last"); 676 field.name = ASCIIToUTF16("bill.last");
598 form.fields.push_back(field); 677 form.fields.push_back(field);
599 678
600 field.label = ASCIIToUTF16("Street Address Line 1:"); 679 field.label = ASCIIToUTF16("Street Address Line 1:");
(...skipping 19 matching lines...) Expand all
620 field.label = ASCIIToUTF16("Country:"); 699 field.label = ASCIIToUTF16("Country:");
621 field.name = ASCIIToUTF16("bill.country"); 700 field.name = ASCIIToUTF16("bill.country");
622 form.fields.push_back(field); 701 form.fields.push_back(field);
623 702
624 field.label = ASCIIToUTF16("Phone Number:"); 703 field.label = ASCIIToUTF16("Phone Number:");
625 field.name = ASCIIToUTF16("BillTo.Phone"); 704 field.name = ASCIIToUTF16("BillTo.Phone");
626 form.fields.push_back(field); 705 form.fields.push_back(field);
627 706
628 field.label = string16(); 707 field.label = string16();
629 field.name = ASCIIToUTF16("Submit"); 708 field.name = ASCIIToUTF16("Submit");
630 field.form_control_type = ASCIIToUTF16("submit"); 709 field.form_control_type = "submit";
631 form.fields.push_back(field); 710 form.fields.push_back(field);
632 711
633 form_structure.reset(new FormStructure(form)); 712 form_structure.reset(new FormStructure(form));
634 form_structure->DetermineHeuristicTypes(); 713 form_structure->DetermineHeuristicTypes();
635 EXPECT_TRUE(form_structure->IsAutofillable(true)); 714 EXPECT_TRUE(form_structure->IsAutofillable(true));
636 ASSERT_EQ(10U, form_structure->field_count()); 715 ASSERT_EQ(10U, form_structure->field_count());
637 ASSERT_EQ(9U, form_structure->autofill_count()); 716 ASSERT_EQ(9U, form_structure->autofill_count());
638 717
639 // First name. 718 // First name.
640 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 719 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
(...skipping 18 matching lines...) Expand all
659 // Submit. 738 // Submit.
660 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(9)->heuristic_type()); 739 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(9)->heuristic_type());
661 } 740 }
662 741
663 TEST(FormStructureTest, HeuristicsSample6) { 742 TEST(FormStructureTest, HeuristicsSample6) {
664 scoped_ptr<FormStructure> form_structure; 743 scoped_ptr<FormStructure> form_structure;
665 FormData form; 744 FormData form;
666 form.method = ASCIIToUTF16("post"); 745 form.method = ASCIIToUTF16("post");
667 746
668 FormFieldData field; 747 FormFieldData field;
669 field.form_control_type = ASCIIToUTF16("text"); 748 field.form_control_type = "text";
670 749
671 field.label = ASCIIToUTF16("E-mail address"); 750 field.label = ASCIIToUTF16("E-mail address");
672 field.name = ASCIIToUTF16("email"); 751 field.name = ASCIIToUTF16("email");
673 form.fields.push_back(field); 752 form.fields.push_back(field);
674 753
675 field.label = ASCIIToUTF16("Full name"); 754 field.label = ASCIIToUTF16("Full name");
676 field.name = ASCIIToUTF16("name"); 755 field.name = ASCIIToUTF16("name");
677 form.fields.push_back(field); 756 form.fields.push_back(field);
678 757
679 field.label = ASCIIToUTF16("Company"); 758 field.label = ASCIIToUTF16("Company");
680 field.name = ASCIIToUTF16("company"); 759 field.name = ASCIIToUTF16("company");
681 form.fields.push_back(field); 760 form.fields.push_back(field);
682 761
683 field.label = ASCIIToUTF16("Address"); 762 field.label = ASCIIToUTF16("Address");
684 field.name = ASCIIToUTF16("address"); 763 field.name = ASCIIToUTF16("address");
685 form.fields.push_back(field); 764 form.fields.push_back(field);
686 765
687 field.label = ASCIIToUTF16("City"); 766 field.label = ASCIIToUTF16("City");
688 field.name = ASCIIToUTF16("city"); 767 field.name = ASCIIToUTF16("city");
689 form.fields.push_back(field); 768 form.fields.push_back(field);
690 769
691 field.label = ASCIIToUTF16("Zip Code"); 770 field.label = ASCIIToUTF16("Zip Code");
692 field.name = ASCIIToUTF16("Home.PostalCode"); 771 field.name = ASCIIToUTF16("Home.PostalCode");
693 form.fields.push_back(field); 772 form.fields.push_back(field);
694 773
695 field.label = string16(); 774 field.label = string16();
696 field.name = ASCIIToUTF16("Submit"); 775 field.name = ASCIIToUTF16("Submit");
697 field.value = ASCIIToUTF16("continue"); 776 field.value = ASCIIToUTF16("continue");
698 field.form_control_type = ASCIIToUTF16("submit"); 777 field.form_control_type = "submit";
699 form.fields.push_back(field); 778 form.fields.push_back(field);
700 779
701 form_structure.reset(new FormStructure(form)); 780 form_structure.reset(new FormStructure(form));
702 form_structure->DetermineHeuristicTypes(); 781 form_structure->DetermineHeuristicTypes();
703 EXPECT_TRUE(form_structure->IsAutofillable(true)); 782 EXPECT_TRUE(form_structure->IsAutofillable(true));
704 ASSERT_EQ(7U, form_structure->field_count()); 783 ASSERT_EQ(7U, form_structure->field_count());
705 ASSERT_EQ(6U, form_structure->autofill_count()); 784 ASSERT_EQ(6U, form_structure->autofill_count());
706 785
707 // Email. 786 // Email.
708 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type()); 787 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(0)->heuristic_type());
(...skipping 13 matching lines...) Expand all
722 801
723 // Tests a sequence of FormFields where only labels are supplied to heuristics 802 // Tests a sequence of FormFields where only labels are supplied to heuristics
724 // for matching. This works because FormFieldData labels are matched in the 803 // for matching. This works because FormFieldData labels are matched in the
725 // case that input element ids (or |name| fields) are missing. 804 // case that input element ids (or |name| fields) are missing.
726 TEST(FormStructureTest, HeuristicsLabelsOnly) { 805 TEST(FormStructureTest, HeuristicsLabelsOnly) {
727 scoped_ptr<FormStructure> form_structure; 806 scoped_ptr<FormStructure> form_structure;
728 FormData form; 807 FormData form;
729 form.method = ASCIIToUTF16("post"); 808 form.method = ASCIIToUTF16("post");
730 809
731 FormFieldData field; 810 FormFieldData field;
732 field.form_control_type = ASCIIToUTF16("text"); 811 field.form_control_type = "text";
733 812
734 field.label = ASCIIToUTF16("First Name"); 813 field.label = ASCIIToUTF16("First Name");
735 field.name = string16(); 814 field.name = string16();
736 form.fields.push_back(field); 815 form.fields.push_back(field);
737 816
738 field.label = ASCIIToUTF16("Last Name"); 817 field.label = ASCIIToUTF16("Last Name");
739 field.name = string16(); 818 field.name = string16();
740 form.fields.push_back(field); 819 form.fields.push_back(field);
741 820
742 field.label = ASCIIToUTF16("Email"); 821 field.label = ASCIIToUTF16("Email");
(...skipping 11 matching lines...) Expand all
754 field.label = ASCIIToUTF16("Address"); 833 field.label = ASCIIToUTF16("Address");
755 field.name = string16(); 834 field.name = string16();
756 form.fields.push_back(field); 835 form.fields.push_back(field);
757 836
758 field.label = ASCIIToUTF16("Zip code"); 837 field.label = ASCIIToUTF16("Zip code");
759 field.name = string16(); 838 field.name = string16();
760 form.fields.push_back(field); 839 form.fields.push_back(field);
761 840
762 field.label = string16(); 841 field.label = string16();
763 field.name = ASCIIToUTF16("Submit"); 842 field.name = ASCIIToUTF16("Submit");
764 field.form_control_type = ASCIIToUTF16("submit"); 843 field.form_control_type = "submit";
765 form.fields.push_back(field); 844 form.fields.push_back(field);
766 845
767 form_structure.reset(new FormStructure(form)); 846 form_structure.reset(new FormStructure(form));
768 form_structure->DetermineHeuristicTypes(); 847 form_structure->DetermineHeuristicTypes();
769 EXPECT_TRUE(form_structure->IsAutofillable(true)); 848 EXPECT_TRUE(form_structure->IsAutofillable(true));
770 ASSERT_EQ(8U, form_structure->field_count()); 849 ASSERT_EQ(8U, form_structure->field_count());
771 ASSERT_EQ(7U, form_structure->autofill_count()); 850 ASSERT_EQ(7U, form_structure->autofill_count());
772 851
773 // First name. 852 // First name.
774 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 853 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
(...skipping 13 matching lines...) Expand all
788 // Submit. 867 // Submit.
789 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(7)->heuristic_type()); 868 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(7)->heuristic_type());
790 } 869 }
791 870
792 TEST(FormStructureTest, HeuristicsCreditCardInfo) { 871 TEST(FormStructureTest, HeuristicsCreditCardInfo) {
793 scoped_ptr<FormStructure> form_structure; 872 scoped_ptr<FormStructure> form_structure;
794 FormData form; 873 FormData form;
795 form.method = ASCIIToUTF16("post"); 874 form.method = ASCIIToUTF16("post");
796 875
797 FormFieldData field; 876 FormFieldData field;
798 field.form_control_type = ASCIIToUTF16("text"); 877 field.form_control_type = "text";
799 878
800 field.label = ASCIIToUTF16("Name on Card"); 879 field.label = ASCIIToUTF16("Name on Card");
801 field.name = ASCIIToUTF16("name_on_card"); 880 field.name = ASCIIToUTF16("name_on_card");
802 form.fields.push_back(field); 881 form.fields.push_back(field);
803 882
804 field.label = ASCIIToUTF16("Card Number"); 883 field.label = ASCIIToUTF16("Card Number");
805 field.name = ASCIIToUTF16("card_number"); 884 field.name = ASCIIToUTF16("card_number");
806 form.fields.push_back(field); 885 form.fields.push_back(field);
807 886
808 field.label = ASCIIToUTF16("Exp Month"); 887 field.label = ASCIIToUTF16("Exp Month");
809 field.name = ASCIIToUTF16("ccmonth"); 888 field.name = ASCIIToUTF16("ccmonth");
810 form.fields.push_back(field); 889 form.fields.push_back(field);
811 890
812 field.label = ASCIIToUTF16("Exp Year"); 891 field.label = ASCIIToUTF16("Exp Year");
813 field.name = ASCIIToUTF16("ccyear"); 892 field.name = ASCIIToUTF16("ccyear");
814 form.fields.push_back(field); 893 form.fields.push_back(field);
815 894
816 field.label = ASCIIToUTF16("Verification"); 895 field.label = ASCIIToUTF16("Verification");
817 field.name = ASCIIToUTF16("verification"); 896 field.name = ASCIIToUTF16("verification");
818 form.fields.push_back(field); 897 form.fields.push_back(field);
819 898
820 field.label = string16(); 899 field.label = string16();
821 field.name = ASCIIToUTF16("Submit"); 900 field.name = ASCIIToUTF16("Submit");
822 field.form_control_type = ASCIIToUTF16("submit"); 901 field.form_control_type = "submit";
823 form.fields.push_back(field); 902 form.fields.push_back(field);
824 903
825 form_structure.reset(new FormStructure(form)); 904 form_structure.reset(new FormStructure(form));
826 form_structure->DetermineHeuristicTypes(); 905 form_structure->DetermineHeuristicTypes();
827 EXPECT_TRUE(form_structure->IsAutofillable(true)); 906 EXPECT_TRUE(form_structure->IsAutofillable(true));
828 ASSERT_EQ(6U, form_structure->field_count()); 907 ASSERT_EQ(6U, form_structure->field_count());
829 ASSERT_EQ(4U, form_structure->autofill_count()); 908 ASSERT_EQ(4U, form_structure->autofill_count());
830 909
831 // Credit card name. 910 // Credit card name.
832 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); 911 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type());
833 // Credit card number. 912 // Credit card number.
834 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type()); 913 EXPECT_EQ(CREDIT_CARD_NUMBER, form_structure->field(1)->heuristic_type());
835 // Credit card expiration month. 914 // Credit card expiration month.
836 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type()); 915 EXPECT_EQ(CREDIT_CARD_EXP_MONTH, form_structure->field(2)->heuristic_type());
837 // Credit card expiration year. 916 // Credit card expiration year.
838 EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, 917 EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR,
839 form_structure->field(3)->heuristic_type()); 918 form_structure->field(3)->heuristic_type());
840 // We don't determine CVV. 919 // We don't determine CVV.
841 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(4)->heuristic_type()); 920 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(4)->heuristic_type());
842 // Submit. 921 // Submit.
843 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(5)->heuristic_type()); 922 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(5)->heuristic_type());
844 } 923 }
845 924
846 TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) { 925 TEST(FormStructureTest, HeuristicsCreditCardInfoWithUnknownCardField) {
847 scoped_ptr<FormStructure> form_structure; 926 scoped_ptr<FormStructure> form_structure;
848 FormData form; 927 FormData form;
849 form.method = ASCIIToUTF16("post"); 928 form.method = ASCIIToUTF16("post");
850 929
851 FormFieldData field; 930 FormFieldData field;
852 field.form_control_type = ASCIIToUTF16("text"); 931 field.form_control_type = "text";
853 932
854 field.label = ASCIIToUTF16("Name on Card"); 933 field.label = ASCIIToUTF16("Name on Card");
855 field.name = ASCIIToUTF16("name_on_card"); 934 field.name = ASCIIToUTF16("name_on_card");
856 form.fields.push_back(field); 935 form.fields.push_back(field);
857 936
858 // This is not a field we know how to process. But we should skip over it 937 // This is not a field we know how to process. But we should skip over it
859 // and process the other fields in the card block. 938 // and process the other fields in the card block.
860 field.label = ASCIIToUTF16("Card Type"); 939 field.label = ASCIIToUTF16("Card Type");
861 field.name = ASCIIToUTF16("card_type"); 940 field.name = ASCIIToUTF16("card_type");
862 form.fields.push_back(field); 941 form.fields.push_back(field);
863 942
864 field.label = ASCIIToUTF16("Card Number"); 943 field.label = ASCIIToUTF16("Card Number");
865 field.name = ASCIIToUTF16("card_number"); 944 field.name = ASCIIToUTF16("card_number");
866 form.fields.push_back(field); 945 form.fields.push_back(field);
867 946
868 field.label = ASCIIToUTF16("Exp Month"); 947 field.label = ASCIIToUTF16("Exp Month");
869 field.name = ASCIIToUTF16("ccmonth"); 948 field.name = ASCIIToUTF16("ccmonth");
870 form.fields.push_back(field); 949 form.fields.push_back(field);
871 950
872 field.label = ASCIIToUTF16("Exp Year"); 951 field.label = ASCIIToUTF16("Exp Year");
873 field.name = ASCIIToUTF16("ccyear"); 952 field.name = ASCIIToUTF16("ccyear");
874 form.fields.push_back(field); 953 form.fields.push_back(field);
875 954
876 field.label = ASCIIToUTF16("Verification"); 955 field.label = ASCIIToUTF16("Verification");
877 field.name = ASCIIToUTF16("verification"); 956 field.name = ASCIIToUTF16("verification");
878 form.fields.push_back(field); 957 form.fields.push_back(field);
879 958
880 field.label = string16(); 959 field.label = string16();
881 field.name = ASCIIToUTF16("Submit"); 960 field.name = ASCIIToUTF16("Submit");
882 field.form_control_type = ASCIIToUTF16("submit"); 961 field.form_control_type = "submit";
883 form.fields.push_back(field); 962 form.fields.push_back(field);
884 963
885 form_structure.reset(new FormStructure(form)); 964 form_structure.reset(new FormStructure(form));
886 form_structure->DetermineHeuristicTypes(); 965 form_structure->DetermineHeuristicTypes();
887 EXPECT_TRUE(form_structure->IsAutofillable(true)); 966 EXPECT_TRUE(form_structure->IsAutofillable(true));
888 ASSERT_EQ(7U, form_structure->field_count()); 967 ASSERT_EQ(7U, form_structure->field_count());
889 ASSERT_EQ(4U, form_structure->autofill_count()); 968 ASSERT_EQ(4U, form_structure->autofill_count());
890 969
891 // Credit card name. 970 // Credit card name.
892 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type()); 971 EXPECT_EQ(CREDIT_CARD_NAME, form_structure->field(0)->heuristic_type());
(...skipping 11 matching lines...) Expand all
904 // Submit. 983 // Submit.
905 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(6)->heuristic_type()); 984 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(6)->heuristic_type());
906 } 985 }
907 986
908 TEST(FormStructureTest, ThreeAddressLines) { 987 TEST(FormStructureTest, ThreeAddressLines) {
909 scoped_ptr<FormStructure> form_structure; 988 scoped_ptr<FormStructure> form_structure;
910 FormData form; 989 FormData form;
911 form.method = ASCIIToUTF16("post"); 990 form.method = ASCIIToUTF16("post");
912 991
913 FormFieldData field; 992 FormFieldData field;
914 field.form_control_type = ASCIIToUTF16("text"); 993 field.form_control_type = "text";
915 994
916 field.label = ASCIIToUTF16("Address Line1"); 995 field.label = ASCIIToUTF16("Address Line1");
917 field.name = ASCIIToUTF16("Address"); 996 field.name = ASCIIToUTF16("Address");
918 form.fields.push_back(field); 997 form.fields.push_back(field);
919 998
920 field.label = ASCIIToUTF16("Address Line2"); 999 field.label = ASCIIToUTF16("Address Line2");
921 field.name = ASCIIToUTF16("Address"); 1000 field.name = ASCIIToUTF16("Address");
922 form.fields.push_back(field); 1001 form.fields.push_back(field);
923 1002
924 field.label = ASCIIToUTF16("Address Line3"); 1003 field.label = ASCIIToUTF16("Address Line3");
(...skipping 21 matching lines...) Expand all
946 } 1025 }
947 1026
948 // This test verifies that "addressLine1" and "addressLine2" matches heuristics. 1027 // This test verifies that "addressLine1" and "addressLine2" matches heuristics.
949 // This occured in https://www.gorillaclothing.com/. http://crbug.com/52126. 1028 // This occured in https://www.gorillaclothing.com/. http://crbug.com/52126.
950 TEST(FormStructureTest, BillingAndShippingAddresses) { 1029 TEST(FormStructureTest, BillingAndShippingAddresses) {
951 scoped_ptr<FormStructure> form_structure; 1030 scoped_ptr<FormStructure> form_structure;
952 FormData form; 1031 FormData form;
953 form.method = ASCIIToUTF16("post"); 1032 form.method = ASCIIToUTF16("post");
954 1033
955 FormFieldData field; 1034 FormFieldData field;
956 field.form_control_type = ASCIIToUTF16("text"); 1035 field.form_control_type = "text";
957 1036
958 field.label = ASCIIToUTF16("Address Line1"); 1037 field.label = ASCIIToUTF16("Address Line1");
959 field.name = ASCIIToUTF16("shipping.address.addressLine1"); 1038 field.name = ASCIIToUTF16("shipping.address.addressLine1");
960 form.fields.push_back(field); 1039 form.fields.push_back(field);
961 1040
962 field.label = ASCIIToUTF16("Address Line2"); 1041 field.label = ASCIIToUTF16("Address Line2");
963 field.name = ASCIIToUTF16("shipping.address.addressLine2"); 1042 field.name = ASCIIToUTF16("shipping.address.addressLine2");
964 form.fields.push_back(field); 1043 form.fields.push_back(field);
965 1044
966 field.label = ASCIIToUTF16("Address Line1"); 1045 field.label = ASCIIToUTF16("Address Line1");
(...skipping 25 matching lines...) Expand all
992 // indicate a suite or apartment number. We interpret this as address line 2. 1071 // indicate a suite or apartment number. We interpret this as address line 2.
993 // And the following "Street address second line" we interpret as address line 1072 // And the following "Street address second line" we interpret as address line
994 // 3 and discard. 1073 // 3 and discard.
995 // See http://crbug.com/48197 for details. 1074 // See http://crbug.com/48197 for details.
996 TEST(FormStructureTest, ThreeAddressLinesExpedia) { 1075 TEST(FormStructureTest, ThreeAddressLinesExpedia) {
997 scoped_ptr<FormStructure> form_structure; 1076 scoped_ptr<FormStructure> form_structure;
998 FormData form; 1077 FormData form;
999 form.method = ASCIIToUTF16("post"); 1078 form.method = ASCIIToUTF16("post");
1000 1079
1001 FormFieldData field; 1080 FormFieldData field;
1002 field.form_control_type = ASCIIToUTF16("text"); 1081 field.form_control_type = "text";
1003 1082
1004 field.label = ASCIIToUTF16("Street:"); 1083 field.label = ASCIIToUTF16("Street:");
1005 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads1"); 1084 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_ads1");
1006 form.fields.push_back(field); 1085 form.fields.push_back(field);
1007 1086
1008 field.label = ASCIIToUTF16("Suite or Apt:"); 1087 field.label = ASCIIToUTF16("Suite or Apt:");
1009 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adap"); 1088 field.name = ASCIIToUTF16("FOPIH_RgWebCC_0_IHAddress_adap");
1010 form.fields.push_back(field); 1089 form.fields.push_back(field);
1011 1090
1012 field.label = ASCIIToUTF16("Street address second line"); 1091 field.label = ASCIIToUTF16("Street address second line");
(...skipping 22 matching lines...) Expand all
1035 1114
1036 // This example comes from ebay.com where the word "suite" appears in the label 1115 // This example comes from ebay.com where the word "suite" appears in the label
1037 // and the name "address2" clearly indicates that this is the address line 2. 1116 // and the name "address2" clearly indicates that this is the address line 2.
1038 // See http://crbug.com/48197 for details. 1117 // See http://crbug.com/48197 for details.
1039 TEST(FormStructureTest, TwoAddressLinesEbay) { 1118 TEST(FormStructureTest, TwoAddressLinesEbay) {
1040 scoped_ptr<FormStructure> form_structure; 1119 scoped_ptr<FormStructure> form_structure;
1041 FormData form; 1120 FormData form;
1042 form.method = ASCIIToUTF16("post"); 1121 form.method = ASCIIToUTF16("post");
1043 1122
1044 FormFieldData field; 1123 FormFieldData field;
1045 field.form_control_type = ASCIIToUTF16("text"); 1124 field.form_control_type = "text";
1046 1125
1047 field.label = ASCIIToUTF16("Address Line1"); 1126 field.label = ASCIIToUTF16("Address Line1");
1048 field.name = ASCIIToUTF16("address1"); 1127 field.name = ASCIIToUTF16("address1");
1049 form.fields.push_back(field); 1128 form.fields.push_back(field);
1050 1129
1051 field.label = ASCIIToUTF16("Floor number, suite number, etc"); 1130 field.label = ASCIIToUTF16("Floor number, suite number, etc");
1052 field.name = ASCIIToUTF16("address2"); 1131 field.name = ASCIIToUTF16("address2");
1053 form.fields.push_back(field); 1132 form.fields.push_back(field);
1054 1133
1055 field.label = ASCIIToUTF16("City:"); 1134 field.label = ASCIIToUTF16("City:");
(...skipping 13 matching lines...) Expand all
1069 // City. 1148 // City.
1070 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type()); 1149 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(2)->heuristic_type());
1071 } 1150 }
1072 1151
1073 TEST(FormStructureTest, HeuristicsStateWithProvince) { 1152 TEST(FormStructureTest, HeuristicsStateWithProvince) {
1074 scoped_ptr<FormStructure> form_structure; 1153 scoped_ptr<FormStructure> form_structure;
1075 FormData form; 1154 FormData form;
1076 form.method = ASCIIToUTF16("post"); 1155 form.method = ASCIIToUTF16("post");
1077 1156
1078 FormFieldData field; 1157 FormFieldData field;
1079 field.form_control_type = ASCIIToUTF16("text"); 1158 field.form_control_type = "text";
1080 1159
1081 field.label = ASCIIToUTF16("Address Line1"); 1160 field.label = ASCIIToUTF16("Address Line1");
1082 field.name = ASCIIToUTF16("Address"); 1161 field.name = ASCIIToUTF16("Address");
1083 form.fields.push_back(field); 1162 form.fields.push_back(field);
1084 1163
1085 field.label = ASCIIToUTF16("Address Line2"); 1164 field.label = ASCIIToUTF16("Address Line2");
1086 field.name = ASCIIToUTF16("Address"); 1165 field.name = ASCIIToUTF16("Address");
1087 form.fields.push_back(field); 1166 form.fields.push_back(field);
1088 1167
1089 field.label = ASCIIToUTF16("State/Province/Region"); 1168 field.label = ASCIIToUTF16("State/Province/Region");
(...skipping 14 matching lines...) Expand all
1104 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type()); 1183 EXPECT_EQ(ADDRESS_HOME_STATE, form_structure->field(2)->heuristic_type());
1105 } 1184 }
1106 1185
1107 // This example comes from lego.com's checkout page. 1186 // This example comes from lego.com's checkout page.
1108 TEST(FormStructureTest, HeuristicsWithBilling) { 1187 TEST(FormStructureTest, HeuristicsWithBilling) {
1109 scoped_ptr<FormStructure> form_structure; 1188 scoped_ptr<FormStructure> form_structure;
1110 FormData form; 1189 FormData form;
1111 form.method = ASCIIToUTF16("post"); 1190 form.method = ASCIIToUTF16("post");
1112 1191
1113 FormFieldData field; 1192 FormFieldData field;
1114 field.form_control_type = ASCIIToUTF16("text"); 1193 field.form_control_type = "text";
1115 1194
1116 field.label = ASCIIToUTF16("First Name*:"); 1195 field.label = ASCIIToUTF16("First Name*:");
1117 field.name = ASCIIToUTF16("editBillingAddress$firstNameBox"); 1196 field.name = ASCIIToUTF16("editBillingAddress$firstNameBox");
1118 form.fields.push_back(field); 1197 form.fields.push_back(field);
1119 1198
1120 field.label = ASCIIToUTF16("Last Name*:"); 1199 field.label = ASCIIToUTF16("Last Name*:");
1121 field.name = ASCIIToUTF16("editBillingAddress$lastNameBox"); 1200 field.name = ASCIIToUTF16("editBillingAddress$lastNameBox");
1122 form.fields.push_back(field); 1201 form.fields.push_back(field);
1123 1202
1124 field.label = ASCIIToUTF16("Company Name:"); 1203 field.label = ASCIIToUTF16("Company Name:");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 form_structure->field(9)->heuristic_type()); 1256 form_structure->field(9)->heuristic_type());
1178 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(10)->heuristic_type()); 1257 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(10)->heuristic_type());
1179 } 1258 }
1180 1259
1181 TEST(FormStructureTest, ThreePartPhoneNumber) { 1260 TEST(FormStructureTest, ThreePartPhoneNumber) {
1182 scoped_ptr<FormStructure> form_structure; 1261 scoped_ptr<FormStructure> form_structure;
1183 FormData form; 1262 FormData form;
1184 form.method = ASCIIToUTF16("post"); 1263 form.method = ASCIIToUTF16("post");
1185 1264
1186 FormFieldData field; 1265 FormFieldData field;
1187 field.form_control_type = ASCIIToUTF16("text"); 1266 field.form_control_type = "text";
1188 1267
1189 field.label = ASCIIToUTF16("Phone:"); 1268 field.label = ASCIIToUTF16("Phone:");
1190 field.name = ASCIIToUTF16("dayphone1"); 1269 field.name = ASCIIToUTF16("dayphone1");
1191 field.max_length = 0; 1270 field.max_length = 0;
1192 form.fields.push_back(field); 1271 form.fields.push_back(field);
1193 1272
1194 field.label = ASCIIToUTF16("-"); 1273 field.label = ASCIIToUTF16("-");
1195 field.name = ASCIIToUTF16("dayphone2"); 1274 field.name = ASCIIToUTF16("dayphone2");
1196 field.max_length = 3; // Size of prefix is 3. 1275 field.max_length = 3; // Size of prefix is 3.
1197 form.fields.push_back(field); 1276 form.fields.push_back(field);
(...skipping 27 matching lines...) Expand all
1225 // Unknown. 1304 // Unknown.
1226 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type()); 1305 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type());
1227 } 1306 }
1228 1307
1229 TEST(FormStructureTest, HeuristicsInfernoCC) { 1308 TEST(FormStructureTest, HeuristicsInfernoCC) {
1230 scoped_ptr<FormStructure> form_structure; 1309 scoped_ptr<FormStructure> form_structure;
1231 FormData form; 1310 FormData form;
1232 form.method = ASCIIToUTF16("post"); 1311 form.method = ASCIIToUTF16("post");
1233 1312
1234 FormFieldData field; 1313 FormFieldData field;
1235 field.form_control_type = ASCIIToUTF16("text"); 1314 field.form_control_type = "text";
1236 1315
1237 field.label = ASCIIToUTF16("Name on Card"); 1316 field.label = ASCIIToUTF16("Name on Card");
1238 field.name = ASCIIToUTF16("name_on_card"); 1317 field.name = ASCIIToUTF16("name_on_card");
1239 form.fields.push_back(field); 1318 form.fields.push_back(field);
1240 1319
1241 field.label = ASCIIToUTF16("Address"); 1320 field.label = ASCIIToUTF16("Address");
1242 field.name = ASCIIToUTF16("billing_address"); 1321 field.name = ASCIIToUTF16("billing_address");
1243 form.fields.push_back(field); 1322 form.fields.push_back(field);
1244 1323
1245 field.label = ASCIIToUTF16("Card Number"); 1324 field.label = ASCIIToUTF16("Card Number");
(...skipping 28 matching lines...) Expand all
1274 EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, 1353 EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR,
1275 form_structure->field(4)->heuristic_type()); 1354 form_structure->field(4)->heuristic_type());
1276 } 1355 }
1277 1356
1278 TEST(FormStructureTest, CVCCodeClash) { 1357 TEST(FormStructureTest, CVCCodeClash) {
1279 scoped_ptr<FormStructure> form_structure; 1358 scoped_ptr<FormStructure> form_structure;
1280 FormData form; 1359 FormData form;
1281 form.method = ASCIIToUTF16("post"); 1360 form.method = ASCIIToUTF16("post");
1282 1361
1283 FormFieldData field; 1362 FormFieldData field;
1284 field.form_control_type = ASCIIToUTF16("text"); 1363 field.form_control_type = "text";
1285 1364
1286 field.label = ASCIIToUTF16("Card number"); 1365 field.label = ASCIIToUTF16("Card number");
1287 field.name = ASCIIToUTF16("ccnumber"); 1366 field.name = ASCIIToUTF16("ccnumber");
1288 form.fields.push_back(field); 1367 form.fields.push_back(field);
1289 1368
1290 field.label = ASCIIToUTF16("First name"); 1369 field.label = ASCIIToUTF16("First name");
1291 field.name = ASCIIToUTF16("first_name"); 1370 field.name = ASCIIToUTF16("first_name");
1292 form.fields.push_back(field); 1371 form.fields.push_back(field);
1293 1372
1294 field.label = ASCIIToUTF16("Last name"); 1373 field.label = ASCIIToUTF16("Last name");
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 form_structure->field(4)->heuristic_type()); 1407 form_structure->field(4)->heuristic_type());
1329 // CVC code should not match. 1408 // CVC code should not match.
1330 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(5)->heuristic_type()); 1409 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(5)->heuristic_type());
1331 } 1410 }
1332 1411
1333 TEST(FormStructureTest, EncodeQueryRequest) { 1412 TEST(FormStructureTest, EncodeQueryRequest) {
1334 FormData form; 1413 FormData form;
1335 form.method = ASCIIToUTF16("post"); 1414 form.method = ASCIIToUTF16("post");
1336 1415
1337 FormFieldData field; 1416 FormFieldData field;
1338 field.form_control_type = ASCIIToUTF16("text"); 1417 field.form_control_type = "text";
1339 1418
1340 field.label = ASCIIToUTF16("Name on Card"); 1419 field.label = ASCIIToUTF16("Name on Card");
1341 field.name = ASCIIToUTF16("name_on_card"); 1420 field.name = ASCIIToUTF16("name_on_card");
1342 form.fields.push_back(field); 1421 form.fields.push_back(field);
1343 1422
1344 field.label = ASCIIToUTF16("Address"); 1423 field.label = ASCIIToUTF16("Address");
1345 field.name = ASCIIToUTF16("billing_address"); 1424 field.name = ASCIIToUTF16("billing_address");
1346 form.fields.push_back(field); 1425 form.fields.push_back(field);
1347 1426
1348 field.label = ASCIIToUTF16("Card Number"); 1427 field.label = ASCIIToUTF16("Card Number");
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1522
1444 TEST(FormStructureTest, EncodeUploadRequest) { 1523 TEST(FormStructureTest, EncodeUploadRequest) {
1445 scoped_ptr<FormStructure> form_structure; 1524 scoped_ptr<FormStructure> form_structure;
1446 std::vector<FieldTypeSet> possible_field_types; 1525 std::vector<FieldTypeSet> possible_field_types;
1447 FormData form; 1526 FormData form;
1448 form.method = ASCIIToUTF16("post"); 1527 form.method = ASCIIToUTF16("post");
1449 form_structure.reset(new FormStructure(form)); 1528 form_structure.reset(new FormStructure(form));
1450 form_structure->DetermineHeuristicTypes(); 1529 form_structure->DetermineHeuristicTypes();
1451 1530
1452 FormFieldData field; 1531 FormFieldData field;
1453 field.form_control_type = ASCIIToUTF16("text"); 1532 field.form_control_type = "text";
1454 1533
1455 field.label = ASCIIToUTF16("First Name"); 1534 field.label = ASCIIToUTF16("First Name");
1456 field.name = ASCIIToUTF16("firstname"); 1535 field.name = ASCIIToUTF16("firstname");
1457 form.fields.push_back(field); 1536 form.fields.push_back(field);
1458 possible_field_types.push_back(FieldTypeSet()); 1537 possible_field_types.push_back(FieldTypeSet());
1459 possible_field_types.back().insert(NAME_FIRST); 1538 possible_field_types.back().insert(NAME_FIRST);
1460 1539
1461 field.label = ASCIIToUTF16("Last Name"); 1540 field.label = ASCIIToUTF16("Last Name");
1462 field.name = ASCIIToUTF16("lastname"); 1541 field.name = ASCIIToUTF16("lastname");
1463 form.fields.push_back(field); 1542 form.fields.push_back(field);
1464 possible_field_types.push_back(FieldTypeSet()); 1543 possible_field_types.push_back(FieldTypeSet());
1465 possible_field_types.back().insert(NAME_LAST); 1544 possible_field_types.back().insert(NAME_LAST);
1466 1545
1467 field.label = ASCIIToUTF16("Email"); 1546 field.label = ASCIIToUTF16("Email");
1468 field.name = ASCIIToUTF16("email"); 1547 field.name = ASCIIToUTF16("email");
1469 field.form_control_type = ASCIIToUTF16("email"); 1548 field.form_control_type = "email";
1470 form.fields.push_back(field); 1549 form.fields.push_back(field);
1471 possible_field_types.push_back(FieldTypeSet()); 1550 possible_field_types.push_back(FieldTypeSet());
1472 possible_field_types.back().insert(EMAIL_ADDRESS); 1551 possible_field_types.back().insert(EMAIL_ADDRESS);
1473 1552
1474 field.label = ASCIIToUTF16("Phone"); 1553 field.label = ASCIIToUTF16("Phone");
1475 field.name = ASCIIToUTF16("phone"); 1554 field.name = ASCIIToUTF16("phone");
1476 field.form_control_type = ASCIIToUTF16("number"); 1555 field.form_control_type = "number";
1477 form.fields.push_back(field); 1556 form.fields.push_back(field);
1478 possible_field_types.push_back(FieldTypeSet()); 1557 possible_field_types.push_back(FieldTypeSet());
1479 possible_field_types.back().insert(PHONE_HOME_WHOLE_NUMBER); 1558 possible_field_types.back().insert(PHONE_HOME_WHOLE_NUMBER);
1480 1559
1481 field.label = ASCIIToUTF16("Country"); 1560 field.label = ASCIIToUTF16("Country");
1482 field.name = ASCIIToUTF16("country"); 1561 field.name = ASCIIToUTF16("country");
1483 field.form_control_type = ASCIIToUTF16("select-one"); 1562 field.form_control_type = "select-one";
1484 form.fields.push_back(field); 1563 form.fields.push_back(field);
1485 possible_field_types.push_back(FieldTypeSet()); 1564 possible_field_types.push_back(FieldTypeSet());
1486 possible_field_types.back().insert(ADDRESS_HOME_COUNTRY); 1565 possible_field_types.back().insert(ADDRESS_HOME_COUNTRY);
1487 form_structure.reset(new FormStructure(form)); 1566 form_structure.reset(new FormStructure(form));
1488 1567
1489 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); 1568 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
1490 for (size_t i = 0; i < form_structure->field_count(); ++i) 1569 for (size_t i = 0; i < form_structure->field_count(); ++i)
1491 form_structure->field(i)->set_possible_types(possible_field_types[i]); 1570 form_structure->field(i)->set_possible_types(possible_field_types[i]);
1492 1571
1493 FieldTypeSet available_field_types; 1572 FieldTypeSet available_field_types;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 "<field signature=\"1029417091\" autofilltype=\"9\"/>" 1605 "<field signature=\"1029417091\" autofilltype=\"9\"/>"
1527 "<field signature=\"466116101\" autofilltype=\"14\"/>" 1606 "<field signature=\"466116101\" autofilltype=\"14\"/>"
1528 "<field signature=\"2799270304\" autofilltype=\"36\"/>" 1607 "<field signature=\"2799270304\" autofilltype=\"36\"/>"
1529 "</autofillupload>", 1608 "</autofillupload>",
1530 encoded_xml); 1609 encoded_xml);
1531 1610
1532 // Add 2 address fields - this should be still a valid form. 1611 // Add 2 address fields - this should be still a valid form.
1533 for (size_t i = 0; i < 2; ++i) { 1612 for (size_t i = 0; i < 2; ++i) {
1534 field.label = ASCIIToUTF16("Address"); 1613 field.label = ASCIIToUTF16("Address");
1535 field.name = ASCIIToUTF16("address"); 1614 field.name = ASCIIToUTF16("address");
1536 field.form_control_type = ASCIIToUTF16("text"); 1615 field.form_control_type = "text";
1537 form.fields.push_back(field); 1616 form.fields.push_back(field);
1538 possible_field_types.push_back(FieldTypeSet()); 1617 possible_field_types.push_back(FieldTypeSet());
1539 possible_field_types.back().insert(ADDRESS_HOME_LINE1); 1618 possible_field_types.back().insert(ADDRESS_HOME_LINE1);
1540 possible_field_types.back().insert(ADDRESS_HOME_LINE2); 1619 possible_field_types.back().insert(ADDRESS_HOME_LINE2);
1541 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); 1620 possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
1542 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); 1621 possible_field_types.back().insert(ADDRESS_BILLING_LINE2);
1543 } 1622 }
1544 1623
1545 form_structure.reset(new FormStructure(form)); 1624 form_structure.reset(new FormStructure(form));
1546 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); 1625 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
(...skipping 19 matching lines...) Expand all
1566 "<field signature=\"509334676\" autofilltype=\"31\"/>" 1645 "<field signature=\"509334676\" autofilltype=\"31\"/>"
1567 "<field signature=\"509334676\" autofilltype=\"37\"/>" 1646 "<field signature=\"509334676\" autofilltype=\"37\"/>"
1568 "<field signature=\"509334676\" autofilltype=\"38\"/>" 1647 "<field signature=\"509334676\" autofilltype=\"38\"/>"
1569 "</autofillupload>", 1648 "</autofillupload>",
1570 encoded_xml); 1649 encoded_xml);
1571 1650
1572 // Add 50 address fields - now the form is invalid, as it has too many fields. 1651 // Add 50 address fields - now the form is invalid, as it has too many fields.
1573 for (size_t i = 0; i < 50; ++i) { 1652 for (size_t i = 0; i < 50; ++i) {
1574 field.label = ASCIIToUTF16("Address"); 1653 field.label = ASCIIToUTF16("Address");
1575 field.name = ASCIIToUTF16("address"); 1654 field.name = ASCIIToUTF16("address");
1576 field.form_control_type = ASCIIToUTF16("text"); 1655 field.form_control_type = "text";
1577 form.fields.push_back(field); 1656 form.fields.push_back(field);
1578 possible_field_types.push_back(FieldTypeSet()); 1657 possible_field_types.push_back(FieldTypeSet());
1579 possible_field_types.back().insert(ADDRESS_HOME_LINE1); 1658 possible_field_types.back().insert(ADDRESS_HOME_LINE1);
1580 possible_field_types.back().insert(ADDRESS_HOME_LINE2); 1659 possible_field_types.back().insert(ADDRESS_HOME_LINE2);
1581 possible_field_types.back().insert(ADDRESS_BILLING_LINE1); 1660 possible_field_types.back().insert(ADDRESS_BILLING_LINE1);
1582 possible_field_types.back().insert(ADDRESS_BILLING_LINE2); 1661 possible_field_types.back().insert(ADDRESS_BILLING_LINE2);
1583 } 1662 }
1584 form_structure.reset(new FormStructure(form)); 1663 form_structure.reset(new FormStructure(form));
1585 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); 1664 ASSERT_EQ(form_structure->field_count(), possible_field_types.size());
1586 for (size_t i = 0; i < form_structure->field_count(); ++i) 1665 for (size_t i = 0; i < form_structure->field_count(); ++i)
1587 form_structure->field(i)->set_possible_types(possible_field_types[i]); 1666 form_structure->field(i)->set_possible_types(possible_field_types[i]);
1588 EXPECT_FALSE(form_structure->EncodeUploadRequest(available_field_types, false, 1667 EXPECT_FALSE(form_structure->EncodeUploadRequest(available_field_types, false,
1589 &encoded_xml)); 1668 &encoded_xml));
1590 } 1669 }
1591 1670
1592 // Check that we compute the "datapresent" string correctly for the given 1671 // Check that we compute the "datapresent" string correctly for the given
1593 // |available_types|. 1672 // |available_types|.
1594 TEST(FormStructureTest, CheckDataPresence) { 1673 TEST(FormStructureTest, CheckDataPresence) {
1595 FormData form; 1674 FormData form;
1596 form.method = ASCIIToUTF16("post"); 1675 form.method = ASCIIToUTF16("post");
1597 1676
1598 FormFieldData field; 1677 FormFieldData field;
1599 field.form_control_type = ASCIIToUTF16("text"); 1678 field.form_control_type = "text";
1600 1679
1601 field.label = ASCIIToUTF16("First Name"); 1680 field.label = ASCIIToUTF16("First Name");
1602 field.name = ASCIIToUTF16("first"); 1681 field.name = ASCIIToUTF16("first");
1603 form.fields.push_back(field); 1682 form.fields.push_back(field);
1604 1683
1605 field.label = ASCIIToUTF16("Last Name"); 1684 field.label = ASCIIToUTF16("Last Name");
1606 field.name = ASCIIToUTF16("last"); 1685 field.name = ASCIIToUTF16("last");
1607 form.fields.push_back(field); 1686 form.fields.push_back(field);
1608 1687
1609 field.label = ASCIIToUTF16("Email"); 1688 field.label = ASCIIToUTF16("Email");
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 available_field_types.insert(ADDRESS_HOME_STATE); 1922 available_field_types.insert(ADDRESS_HOME_STATE);
1844 available_field_types.insert(COMPANY_NAME); 1923 available_field_types.insert(COMPANY_NAME);
1845 1924
1846 // Check that multiple types for the field are processed correctly. 1925 // Check that multiple types for the field are processed correctly.
1847 scoped_ptr<FormStructure> form_structure; 1926 scoped_ptr<FormStructure> form_structure;
1848 std::vector<FieldTypeSet> possible_field_types; 1927 std::vector<FieldTypeSet> possible_field_types;
1849 FormData form; 1928 FormData form;
1850 form.method = ASCIIToUTF16("post"); 1929 form.method = ASCIIToUTF16("post");
1851 1930
1852 FormFieldData field; 1931 FormFieldData field;
1853 field.form_control_type = ASCIIToUTF16("text"); 1932 field.form_control_type = "text";
1854 1933
1855 field.label = ASCIIToUTF16("email"); 1934 field.label = ASCIIToUTF16("email");
1856 field.name = ASCIIToUTF16("email"); 1935 field.name = ASCIIToUTF16("email");
1857 form.fields.push_back(field); 1936 form.fields.push_back(field);
1858 possible_field_types.push_back(FieldTypeSet()); 1937 possible_field_types.push_back(FieldTypeSet());
1859 possible_field_types.back().insert(EMAIL_ADDRESS); 1938 possible_field_types.back().insert(EMAIL_ADDRESS);
1860 1939
1861 field.label = ASCIIToUTF16("First Name"); 1940 field.label = ASCIIToUTF16("First Name");
1862 field.name = ASCIIToUTF16("first"); 1941 field.name = ASCIIToUTF16("first");
1863 form.fields.push_back(field); 1942 form.fields.push_back(field);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 encoded_xml); 2028 encoded_xml);
1950 } 2029 }
1951 2030
1952 TEST(FormStructureTest, CheckFormSignature) { 2031 TEST(FormStructureTest, CheckFormSignature) {
1953 // Check that form signature is created correctly. 2032 // Check that form signature is created correctly.
1954 scoped_ptr<FormStructure> form_structure; 2033 scoped_ptr<FormStructure> form_structure;
1955 FormData form; 2034 FormData form;
1956 form.method = ASCIIToUTF16("post"); 2035 form.method = ASCIIToUTF16("post");
1957 2036
1958 FormFieldData field; 2037 FormFieldData field;
1959 field.form_control_type = ASCIIToUTF16("text"); 2038 field.form_control_type = "text";
1960 2039
1961 field.label = ASCIIToUTF16("email"); 2040 field.label = ASCIIToUTF16("email");
1962 field.name = ASCIIToUTF16("email"); 2041 field.name = ASCIIToUTF16("email");
1963 form.fields.push_back(field); 2042 form.fields.push_back(field);
1964 2043
1965 field.label = ASCIIToUTF16("First Name"); 2044 field.label = ASCIIToUTF16("First Name");
1966 field.name = ASCIIToUTF16("first"); 2045 field.name = ASCIIToUTF16("first");
1967 form.fields.push_back(field); 2046 form.fields.push_back(field);
1968 2047
1969 form_structure.reset(new FormStructure(form)); 2048 form_structure.reset(new FormStructure(form));
(...skipping 13 matching lines...) Expand all
1983 EXPECT_EQ(FormStructureTest::Hash64Bit( 2062 EXPECT_EQ(FormStructureTest::Hash64Bit(
1984 std::string("https://login.facebook.com&&email&first")), 2063 std::string("https://login.facebook.com&&email&first")),
1985 form_structure->FormSignature()); 2064 form_structure->FormSignature());
1986 2065
1987 form.name = ASCIIToUTF16("login_form"); 2066 form.name = ASCIIToUTF16("login_form");
1988 form_structure.reset(new FormStructure(form)); 2067 form_structure.reset(new FormStructure(form));
1989 EXPECT_EQ(FormStructureTest::Hash64Bit( 2068 EXPECT_EQ(FormStructureTest::Hash64Bit(
1990 std::string("https://login.facebook.com&login_form&email&first")), 2069 std::string("https://login.facebook.com&login_form&email&first")),
1991 form_structure->FormSignature()); 2070 form_structure->FormSignature());
1992 } 2071 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698