OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/form_structure.h" | 5 #include "components/autofill/core/browser/form_structure.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/autofill/content/browser/autocheckout_page_meta_data.h" | 10 #include "components/autofill/content/browser/autocheckout_page_meta_data.h" |
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2322 field.form_control_type = "text"; | 2322 field.form_control_type = "text"; |
2323 | 2323 |
2324 field.label = ASCIIToUTF16("email"); | 2324 field.label = ASCIIToUTF16("email"); |
2325 field.name = ASCIIToUTF16("email"); | 2325 field.name = ASCIIToUTF16("email"); |
2326 form.fields.push_back(field); | 2326 form.fields.push_back(field); |
2327 | 2327 |
2328 field.label = ASCIIToUTF16("First Name"); | 2328 field.label = ASCIIToUTF16("First Name"); |
2329 field.name = ASCIIToUTF16("first"); | 2329 field.name = ASCIIToUTF16("first"); |
2330 form.fields.push_back(field); | 2330 form.fields.push_back(field); |
2331 | 2331 |
2332 // Password fields shouldn't affect the signature. | 2332 // Checkable fields shouldn't affect the signature. |
2333 field.label = ASCIIToUTF16("Password"); | 2333 field.label = ASCIIToUTF16("Select"); |
2334 field.name = ASCIIToUTF16("password"); | 2334 field.name = ASCIIToUTF16("Select"); |
2335 field.form_control_type = "password"; | 2335 field.form_control_type = "checkbox"; |
| 2336 field.is_checkable = true; |
2336 form.fields.push_back(field); | 2337 form.fields.push_back(field); |
2337 | 2338 |
2338 form_structure.reset(new FormStructure(form, std::string())); | 2339 form_structure.reset(new FormStructure(form, std::string())); |
2339 | 2340 |
2340 EXPECT_EQ(FormStructureTest::Hash64Bit( | 2341 EXPECT_EQ(FormStructureTest::Hash64Bit( |
2341 std::string("://&&email&first")), | 2342 std::string("://&&email&first")), |
2342 form_structure->FormSignature()); | 2343 form_structure->FormSignature()); |
2343 | 2344 |
2344 form.origin = GURL(std::string("http://www.facebook.com")); | 2345 form.origin = GURL(std::string("http://www.facebook.com")); |
2345 form_structure.reset(new FormStructure(form, std::string())); | 2346 form_structure.reset(new FormStructure(form, std::string())); |
2346 EXPECT_EQ(FormStructureTest::Hash64Bit( | 2347 EXPECT_EQ(FormStructureTest::Hash64Bit( |
2347 std::string("http://www.facebook.com&&email&first")), | 2348 std::string("http://www.facebook.com&&email&first")), |
2348 form_structure->FormSignature()); | 2349 form_structure->FormSignature()); |
2349 | 2350 |
2350 form.action = GURL(std::string("https://login.facebook.com/path")); | 2351 form.action = GURL(std::string("https://login.facebook.com/path")); |
2351 form_structure.reset(new FormStructure(form, std::string())); | 2352 form_structure.reset(new FormStructure(form, std::string())); |
2352 EXPECT_EQ(FormStructureTest::Hash64Bit( | 2353 EXPECT_EQ(FormStructureTest::Hash64Bit( |
2353 std::string("https://login.facebook.com&&email&first")), | 2354 std::string("https://login.facebook.com&&email&first")), |
2354 form_structure->FormSignature()); | 2355 form_structure->FormSignature()); |
2355 | 2356 |
2356 form.name = ASCIIToUTF16("login_form"); | 2357 form.name = ASCIIToUTF16("login_form"); |
2357 form_structure.reset(new FormStructure(form, std::string())); | 2358 form_structure.reset(new FormStructure(form, std::string())); |
2358 EXPECT_EQ(FormStructureTest::Hash64Bit( | 2359 EXPECT_EQ(FormStructureTest::Hash64Bit( |
2359 std::string("https://login.facebook.com&login_form&email&first")), | 2360 std::string("https://login.facebook.com&login_form&email&first")), |
2360 form_structure->FormSignature()); | 2361 form_structure->FormSignature()); |
2361 | 2362 |
| 2363 field.is_checkable = false; |
2362 field.label = ASCIIToUTF16("Random Field label"); | 2364 field.label = ASCIIToUTF16("Random Field label"); |
2363 field.name = ASCIIToUTF16("random1234"); | 2365 field.name = ASCIIToUTF16("random1234"); |
2364 field.form_control_type = "text"; | 2366 field.form_control_type = "text"; |
2365 form.fields.push_back(field); | 2367 form.fields.push_back(field); |
2366 field.label = ASCIIToUTF16("Random Field label2"); | 2368 field.label = ASCIIToUTF16("Random Field label2"); |
2367 field.name = ASCIIToUTF16("random12345"); | 2369 field.name = ASCIIToUTF16("random12345"); |
2368 form.fields.push_back(field); | 2370 form.fields.push_back(field); |
2369 field.label = ASCIIToUTF16("Random Field label3"); | 2371 field.label = ASCIIToUTF16("Random Field label3"); |
2370 field.name = ASCIIToUTF16("1random12345678"); | 2372 field.name = ASCIIToUTF16("1random12345678"); |
2371 form.fields.push_back(field); | 2373 form.fields.push_back(field); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2417 form.method = ASCIIToUTF16("POST"); | 2419 form.method = ASCIIToUTF16("POST"); |
2418 form.origin = GURL("http://cool.com"); | 2420 form.origin = GURL("http://cool.com"); |
2419 form.action = form.origin.Resolve("/login"); | 2421 form.action = form.origin.Resolve("/login"); |
2420 | 2422 |
2421 FormFieldData field; | 2423 FormFieldData field; |
2422 field.label = ASCIIToUTF16("username"); | 2424 field.label = ASCIIToUTF16("username"); |
2423 field.name = ASCIIToUTF16("username"); | 2425 field.name = ASCIIToUTF16("username"); |
2424 field.form_control_type = "text"; | 2426 field.form_control_type = "text"; |
2425 form.fields.push_back(field); | 2427 form.fields.push_back(field); |
2426 | 2428 |
2427 field.label = ASCIIToUTF16("password"); | 2429 field.label = ASCIIToUTF16("select"); |
2428 field.name = ASCIIToUTF16("password"); | 2430 field.name = ASCIIToUTF16("select"); |
2429 field.form_control_type = "password"; | 2431 field.form_control_type = "checkbox"; |
| 2432 field.is_checkable = true; |
2430 form.fields.push_back(field); | 2433 form.fields.push_back(field); |
2431 | 2434 |
2432 field.label = base::string16(); | 2435 field.label = base::string16(); |
2433 field.name = ASCIIToUTF16("email"); | 2436 field.name = ASCIIToUTF16("email"); |
2434 field.form_control_type = "text"; | 2437 field.form_control_type = "text"; |
| 2438 field.is_checkable = false; |
2435 form.fields.push_back(field); | 2439 form.fields.push_back(field); |
2436 | 2440 |
2437 ScopedVector<FormStructure> forms; | 2441 ScopedVector<FormStructure> forms; |
2438 forms.push_back(new FormStructure(form, std::string())); | 2442 forms.push_back(new FormStructure(form, std::string())); |
2439 std::vector<std::string> encoded_signatures; | 2443 std::vector<std::string> encoded_signatures; |
2440 std::string encoded_xml; | 2444 std::string encoded_xml; |
2441 | 2445 |
2442 const char * const kSignature = "18006745212084723782"; | 2446 const char * const kSignature = "18006745212084723782"; |
2443 const char * const kResponse = | 2447 const char * const kResponse = |
2444 "<\?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery " | 2448 "<\?xml version=\"1.0\" encoding=\"UTF-8\"?><autofillquery " |
(...skipping 12 matching lines...) Expand all Loading... |
2457 "<autofillqueryresponse><field autofilltype=\"3\" />" | 2461 "<autofillqueryresponse><field autofilltype=\"3\" />" |
2458 "<field autofilltype=\"9\" /></autofillqueryresponse>"; | 2462 "<field autofilltype=\"9\" /></autofillqueryresponse>"; |
2459 FormStructure::ParseQueryResponse(kServerResponse, forms.get(), | 2463 FormStructure::ParseQueryResponse(kServerResponse, forms.get(), |
2460 &page_meta_data, TestAutofillMetrics()); | 2464 &page_meta_data, TestAutofillMetrics()); |
2461 ASSERT_EQ(NAME_FIRST, forms[0]->field(0)->server_type()); | 2465 ASSERT_EQ(NAME_FIRST, forms[0]->field(0)->server_type()); |
2462 ASSERT_EQ(NO_SERVER_DATA, forms[0]->field(1)->server_type()); | 2466 ASSERT_EQ(NO_SERVER_DATA, forms[0]->field(1)->server_type()); |
2463 ASSERT_EQ(EMAIL_ADDRESS, forms[0]->field(2)->server_type()); | 2467 ASSERT_EQ(EMAIL_ADDRESS, forms[0]->field(2)->server_type()); |
2464 } | 2468 } |
2465 | 2469 |
2466 } // namespace autofill | 2470 } // namespace autofill |
OLD | NEW |