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

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 2187253002: [Password Manager] Change signature of PasswordAutofillAgent.FillSuggestion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <tuple> 5 #include <tuple>
6 6
7 #include "base/feature_list.h" 7 #include "base/feature_list.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // to prevent the form from being immediately filled. 991 // to prevent the form from being immediately filled.
992 fill_data_.wait_for_username = true; 992 fill_data_.wait_for_username = true;
993 SimulateOnFillPasswordForm(fill_data_); 993 SimulateOnFillPasswordForm(fill_data_);
994 994
995 // Neither field should have been autocompleted. 995 // Neither field should have been autocompleted.
996 CheckTextFieldsDOMState(std::string(), false, std::string(), false); 996 CheckTextFieldsDOMState(std::string(), false, std::string(), false);
997 997
998 // If the password field is not autocompletable, it should not be affected. 998 // If the password field is not autocompletable, it should not be affected.
999 SetElementReadOnly(password_element_, true); 999 SetElementReadOnly(password_element_, true);
1000 EXPECT_FALSE(password_autofill_agent_->FillSuggestion( 1000 EXPECT_FALSE(password_autofill_agent_->FillSuggestion(
1001 username_element_, kAliceUsername, kAlicePassword)); 1001 username_element_, ASCIIToUTF16(kAliceUsername),
1002 ASCIIToUTF16(kAlicePassword)));
1002 CheckTextFieldsDOMState(std::string(), false, std::string(), false); 1003 CheckTextFieldsDOMState(std::string(), false, std::string(), false);
1003 SetElementReadOnly(password_element_, false); 1004 SetElementReadOnly(password_element_, false);
1004 1005
1005 // After filling with the suggestion, both fields should be autocompleted. 1006 // After filling with the suggestion, both fields should be autocompleted.
1006 EXPECT_TRUE(password_autofill_agent_->FillSuggestion( 1007 EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
1007 username_element_, kAliceUsername, kAlicePassword)); 1008 username_element_, ASCIIToUTF16(kAliceUsername),
1009 ASCIIToUTF16(kAlicePassword)));
1008 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); 1010 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true);
1009 int username_length = strlen(kAliceUsername); 1011 int username_length = strlen(kAliceUsername);
1010 CheckUsernameSelection(username_length, username_length); 1012 CheckUsernameSelection(username_length, username_length);
1011 1013
1012 // Try Filling with a suggestion with password different from the one that was 1014 // Try Filling with a suggestion with password different from the one that was
1013 // initially sent to the renderer. 1015 // initially sent to the renderer.
1014 EXPECT_TRUE(password_autofill_agent_->FillSuggestion( 1016 EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
1015 username_element_, kBobUsername, kCarolPassword)); 1017 username_element_, ASCIIToUTF16(kBobUsername),
1018 ASCIIToUTF16(kCarolPassword)));
1016 CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true); 1019 CheckTextFieldsDOMState(kBobUsername, true, kCarolPassword, true);
1017 username_length = strlen(kBobUsername); 1020 username_length = strlen(kBobUsername);
1018 CheckUsernameSelection(username_length, username_length); 1021 CheckUsernameSelection(username_length, username_length);
1019 } 1022 }
1020 1023
1021 // Tests that |PreviewSuggestion| properly previews the username and password. 1024 // Tests that |PreviewSuggestion| properly previews the username and password.
1022 TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) { 1025 TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) {
1023 // Simulate the browser sending the login info, but set |wait_for_username| 1026 // Simulate the browser sending the login info, but set |wait_for_username|
1024 // to prevent the form from being immediately filled. 1027 // to prevent the form from being immediately filled.
1025 fill_data_.wait_for_username = true; 1028 fill_data_.wait_for_username = true;
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 // Simulate the browser sending the login info, but set |wait_for_username| 1981 // Simulate the browser sending the login info, but set |wait_for_username|
1979 // to prevent the form from being immediately filled. 1982 // to prevent the form from being immediately filled.
1980 fill_data_.wait_for_username = true; 1983 fill_data_.wait_for_username = true;
1981 fill_data_.is_possible_change_password_form = true; 1984 fill_data_.is_possible_change_password_form = true;
1982 SimulateOnFillPasswordForm(fill_data_); 1985 SimulateOnFillPasswordForm(fill_data_);
1983 1986
1984 // Neither field should have been autocompleted. 1987 // Neither field should have been autocompleted.
1985 CheckTextFieldsDOMState(std::string(), false, std::string(), false); 1988 CheckTextFieldsDOMState(std::string(), false, std::string(), false);
1986 1989
1987 EXPECT_TRUE(password_autofill_agent_->FillSuggestion( 1990 EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
1988 username_element_, kAliceUsername, kAlicePassword)); 1991 username_element_, ASCIIToUTF16(kAliceUsername),
1992 ASCIIToUTF16(kAlicePassword)));
1989 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); 1993 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true);
1990 } 1994 }
1991 1995
1992 // Tests that a password change form is properly filled with the password when 1996 // Tests that a password change form is properly filled with the password when
1993 // the user click on the password field. 1997 // the user click on the password field.
1994 TEST_F(PasswordAutofillAgentTest, 1998 TEST_F(PasswordAutofillAgentTest,
1995 FillSuggestionPasswordChangeFormsOnlyPassword) { 1999 FillSuggestionPasswordChangeFormsOnlyPassword) {
1996 LoadHTML(kPasswordChangeFormHTML); 2000 LoadHTML(kPasswordChangeFormHTML);
1997 UpdateOriginForHTML(kPasswordChangeFormHTML); 2001 UpdateOriginForHTML(kPasswordChangeFormHTML);
1998 UpdateUsernameAndPasswordElements(); 2002 UpdateUsernameAndPasswordElements();
1999 // Simulate the browser sending the login info, but set |wait_for_username| 2003 // Simulate the browser sending the login info, but set |wait_for_username|
2000 // to prevent the form from being immediately filled. 2004 // to prevent the form from being immediately filled.
2001 fill_data_.wait_for_username = true; 2005 fill_data_.wait_for_username = true;
2002 fill_data_.is_possible_change_password_form = true; 2006 fill_data_.is_possible_change_password_form = true;
2003 SimulateOnFillPasswordForm(fill_data_); 2007 SimulateOnFillPasswordForm(fill_data_);
2004 2008
2005 // Neither field should have been autocompleted. 2009 // Neither field should have been autocompleted.
2006 CheckTextFieldsDOMState(std::string(), false, std::string(), false); 2010 CheckTextFieldsDOMState(std::string(), false, std::string(), false);
2007 2011
2008 EXPECT_TRUE(password_autofill_agent_->FillSuggestion( 2012 EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
2009 password_element_, kAliceUsername, kAlicePassword)); 2013 password_element_, ASCIIToUTF16(kAliceUsername),
2014 ASCIIToUTF16(kAlicePassword)));
2010 CheckTextFieldsDOMState("", false, kAlicePassword, true); 2015 CheckTextFieldsDOMState("", false, kAlicePassword, true);
2011 } 2016 }
2012 2017
2013 // Tests that one user click on a username field is sufficient to bring up a 2018 // Tests that one user click on a username field is sufficient to bring up a
2014 // credential suggestion popup on a change password form. 2019 // credential suggestion popup on a change password form.
2015 TEST_F(PasswordAutofillAgentTest, 2020 TEST_F(PasswordAutofillAgentTest,
2016 SuggestionsOnUsernameFieldOfChangePasswordForm) { 2021 SuggestionsOnUsernameFieldOfChangePasswordForm) {
2017 LoadHTML(kPasswordChangeFormHTML); 2022 LoadHTML(kPasswordChangeFormHTML);
2018 UpdateOriginForHTML(kPasswordChangeFormHTML); 2023 UpdateOriginForHTML(kPasswordChangeFormHTML);
2019 UpdateUsernameAndPasswordElements(); 2024 UpdateUsernameAndPasswordElements();
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 CheckSuggestions("", false); 2417 CheckSuggestions("", false);
2413 2418
2414 SimulateElementClick("newpassword"); 2419 SimulateElementClick("newpassword");
2415 CheckSuggestions("", false); 2420 CheckSuggestions("", false);
2416 2421
2417 SimulateElementClick("confirmpassword"); 2422 SimulateElementClick("confirmpassword");
2418 CheckSuggestions("", false); 2423 CheckSuggestions("", false);
2419 2424
2420 // The user chooses to autofill the current password field. 2425 // The user chooses to autofill the current password field.
2421 EXPECT_TRUE(password_autofill_agent_->FillSuggestion( 2426 EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
2422 password_element_, kAliceUsername, kAlicePassword)); 2427 password_element_, ASCIIToUTF16(kAliceUsername),
2428 ASCIIToUTF16(kAlicePassword)));
2423 2429
2424 // Simulate a user clicking on not autofilled password fields. This should 2430 // Simulate a user clicking on not autofilled password fields. This should
2425 // produce 2431 // produce
2426 // no suggestion dropdowns. 2432 // no suggestion dropdowns.
2427 render_thread_->sink().ClearMessages(); 2433 render_thread_->sink().ClearMessages();
2428 SimulateElementClick("newpassword"); 2434 SimulateElementClick("newpassword");
2429 SimulateElementClick("confirmpassword"); 2435 SimulateElementClick("confirmpassword");
2430 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 2436 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
2431 AutofillHostMsg_ShowPasswordSuggestions::ID)); 2437 AutofillHostMsg_ShowPasswordSuggestions::ID));
2432 2438
2433 // But when the user clicks on the autofilled password field again it should 2439 // But when the user clicks on the autofilled password field again it should
2434 // still produce a suggestion dropdown. 2440 // still produce a suggestion dropdown.
2435 SimulateElementClick("password"); 2441 SimulateElementClick("password");
2436 CheckSuggestions("", false); 2442 CheckSuggestions("", false);
2437 } 2443 }
2438 2444
2439 } // namespace autofill 2445 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698