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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 9 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
10 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 const char* expected_new_password_element; | 335 const char* expected_new_password_element; |
336 const char* expected_new_password_value; | 336 const char* expected_new_password_value; |
337 } cases[] = { | 337 } cases[] = { |
338 // Two fields with the same value, and one different: we should treat this | 338 // Two fields with the same value, and one different: we should treat this |
339 // as a password change form with confirmation for the new password. Note | 339 // as a password change form with confirmation for the new password. Note |
340 // that we only recognize (current + new + new) and (new + new + current) | 340 // that we only recognize (current + new + new) and (new + new + current) |
341 // without autocomplete attributes. | 341 // without autocomplete attributes. |
342 {{"alpha", "", ""}, "password1", "alpha", "password2", ""}, | 342 {{"alpha", "", ""}, "password1", "alpha", "password2", ""}, |
343 {{"", "beta", "beta"}, "password1", "", "password2", "beta"}, | 343 {{"", "beta", "beta"}, "password1", "", "password2", "beta"}, |
344 {{"alpha", "beta", "beta"}, "password1", "alpha", "password2", "beta"}, | 344 {{"alpha", "beta", "beta"}, "password1", "alpha", "password2", "beta"}, |
345 {{"beta", "beta", "alpha"}, "password3", "alpha", "password1", "beta"}, | 345 // If confirmed password comes first, assume that the third password |
| 346 // field is related to security question, SSN, or credit card and ignore |
| 347 // it. |
| 348 {{"beta", "beta", "alpha"}, "", "", "password1", "beta"}, |
346 // If the fields are yet empty, we speculate that we will identify them as | 349 // If the fields are yet empty, we speculate that we will identify them as |
347 // (current + new + new) once they are filled out, so we should classify | 350 // (current + new + new) once they are filled out, so we should classify |
348 // them the same for now to keep our abstract interpretation less flaky. | 351 // them the same for now to keep our abstract interpretation less flaky. |
349 {{"", "", ""}, "password1", "", "password2", ""}}; | 352 {{"", "", ""}, "password1", "", "password2", ""}}; |
350 // Note: In all other cases, we give up and consider the form invalid. | 353 // Note: In all other cases, we give up and consider the form invalid. |
351 // This is tested in InvalidFormDueToConfusingPasswordFields. | 354 // This is tested in InvalidFormDueToConfusingPasswordFields. |
352 | 355 |
353 for (size_t i = 0; i < arraysize(cases); ++i) { | 356 for (size_t i = 0; i < arraysize(cases); ++i) { |
354 SCOPED_TRACE(testing::Message() << "Iteration " << i); | 357 SCOPED_TRACE(testing::Message() << "Iteration " << i); |
355 | 358 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 builder.AddPasswordField("password4", "alpha", NULL); | 586 builder.AddPasswordField("password4", "alpha", NULL); |
584 builder.AddSubmitButton("submit", true); | 587 builder.AddSubmitButton("submit", true); |
585 std::string html = builder.ProduceHTML(); | 588 std::string html = builder.ProduceHTML(); |
586 | 589 |
587 scoped_ptr<PasswordForm> password_form; | 590 scoped_ptr<PasswordForm> password_form; |
588 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); | 591 ASSERT_NO_FATAL_FAILURE(LoadHTMLAndConvertForm(html, &password_form)); |
589 EXPECT_FALSE(password_form); | 592 EXPECT_FALSE(password_form); |
590 } | 593 } |
591 | 594 |
592 } // namespace autofill | 595 } // namespace autofill |
OLD | NEW |