Chromium Code Reviews| Index: chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| index c1c12b2184f07173fabfadfdd38b541e0cb5bf7a..02eef49a6eb142f44553ef85359279a3e24672b5 100644 |
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| @@ -1274,9 +1274,8 @@ TEST_F(PasswordAutofillAgentTest, CredentialsOnClick) { |
| ClearUsernameAndPasswordFields(); |
| } |
| -// Tests that there are no autosuggestions from the password manager when the |
| -// user clicks on the password field and the username field is editable when |
| -// FillOnAccountSelect is enabled. |
| +// Tests that there is an autosuggestion from the password manager when the |
| +// user clicks on the password field when FillOnAccountSelect is enabled. |
| TEST_F(PasswordAutofillAgentTest, |
| FillOnAccountSelectOnlyNoCredentialsOnPasswordClick) { |
| base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| @@ -1297,7 +1296,7 @@ TEST_F(PasswordAutofillAgentTest, |
| render_thread_->sink().ClearMessages(); |
| static_cast<PageClickListener*>(autofill_agent_) |
| ->FormControlElementClicked(password_element_, false); |
| - EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| + EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( |
| AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| } |
| @@ -1328,15 +1327,16 @@ TEST_F(PasswordAutofillAgentTest, |
| SimulateElementClick(kUsernameName); |
| // Simulate a user clicking on the password element. This should produce a |
| - // message with "alicia" suggested as the credential. |
| + // dropdown with suggestion of all available usernames and so username |
| + // filter will be the empty string. |
| render_thread_->sink().ClearMessages(); |
| static_cast<PageClickListener*>(autofill_agent_) |
| ->FormControlElementClicked(password_element_, false); |
| - CheckSuggestions("alicia", false); |
| + CheckSuggestions("", false); |
| } |
| -// Tests that there are no autosuggestions from the password manager when the |
| -// user clicks on the password field (not the username field). |
| +// Tests that there is an autosuggestion from the password manager when the |
| +// user clicks on the password field. |
| TEST_F(PasswordAutofillAgentTest, NoCredentialsOnPasswordClick) { |
| // Simulate the browser sending back the login info. |
| SimulateOnFillPasswordForm(fill_data_); |
| @@ -1353,7 +1353,7 @@ TEST_F(PasswordAutofillAgentTest, NoCredentialsOnPasswordClick) { |
| render_thread_->sink().ClearMessages(); |
| static_cast<PageClickListener*>(autofill_agent_) |
| ->FormControlElementClicked(password_element_, false); |
| - EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| + EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( |
| AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| } |
| @@ -1979,32 +1979,6 @@ TEST_F(PasswordAutofillAgentTest, |
| CheckSuggestions("", false); |
| } |
| -// Tests that there are no autosuggestions from the password manager when the |
| -// user clicks on the password field of change password form after the user |
| -// typed in the username field. |
| -TEST_F(PasswordAutofillAgentTest, |
|
dvadym
2016/04/07 17:30:20
Due to these changes this test is not needed anymo
|
| - NoSuggestionsOnPasswordFieldOfChangePasswordFormAfterUsernameTyping) { |
| - LoadHTML(kPasswordChangeFormHTML); |
| - UpdateOriginForHTML(kPasswordChangeFormHTML); |
| - UpdateUsernameAndPasswordElements(); |
| - |
| - ClearUsernameAndPasswordFields(); |
| - fill_data_.wait_for_username = true; |
| - fill_data_.is_possible_change_password_form = true; |
| - SimulateOnFillPasswordForm(fill_data_); |
| - |
| - // Clear the text fields to start fresh. |
| - SimulateUsernameChange("temp"); |
| - |
| - // Simulate a user clicking on the password element. This should produce no |
| - // message. |
| - render_thread_->sink().ClearMessages(); |
| - static_cast<PageClickListener*>(autofill_agent_) |
| - ->FormControlElementClicked(password_element_, false); |
| - EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| - AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| -} |
| - |
| // Tests that NOT_PASSWORD field predictions are followed so that no password |
| // form is submitted. |
| TEST_F(PasswordAutofillAgentTest, IgnoreNotPasswordFields) { |
| @@ -2327,4 +2301,68 @@ TEST_F(PasswordAutofillAgentTest, |
| ExpectFormSubmittedWithUsernameAndPasswords("Alice", "mypassword", ""); |
| } |
| +// Tests that a suggestion dropdown is shown on a password field even if a |
| +// username field is present. |
| +TEST_F(PasswordAutofillAgentTest, SuggestPasswordFieldSignInForm) { |
| + // Simulate the browser sending back the login info. |
| + SimulateOnFillPasswordForm(fill_data_); |
| + |
| + // Call SimulateElementClick() to produce a user gesture on the page so |
| + // autofill will actually fill. |
| + SimulateElementClick(kUsernameName); |
| + |
| + // Simulate a user clicking on the password element. This should produce a |
| + // dropdown with suggestion of all available usernames. |
| + render_thread_->sink().ClearMessages(); |
| + static_cast<PageClickListener*>(autofill_agent_) |
| + ->FormControlElementClicked(password_element_, false); |
| + CheckSuggestions("", false); |
| +} |
| + |
| +// Tests that a suggestion dropdown is shown on each password field. But when a |
| +// user chose one of the fields to autofill, a suggestion dropdown will be shown |
| +// only on this field. |
| +TEST_F(PasswordAutofillAgentTest, SuggestMultiplePasswordFields) { |
| + LoadHTML(kPasswordChangeFormHTML); |
| + UpdateOriginForHTML(kPasswordChangeFormHTML); |
| + UpdateUsernameAndPasswordElements(); |
| + |
| + // Simulate the browser sending back the login info. |
| + SimulateOnFillPasswordForm(fill_data_); |
| + |
| + // Call SimulateElementClick() to produce a user gesture on the page so |
| + // autofill will actually fill. |
| + SimulateElementClick(kUsernameName); |
| + |
| + // Simulate a user clicking on the password elements. This should produce |
| + // dropdowns with suggestion of all available usernames. |
| + render_thread_->sink().ClearMessages(); |
| + SimulateElementClick("password"); |
| + CheckSuggestions("", false); |
| + |
| + SimulateElementClick("newpassword"); |
| + CheckSuggestions("", false); |
| + |
| + SimulateElementClick("confirmpassword"); |
| + CheckSuggestions("", false); |
| + |
| + // The user chooses to autofill the current password field. |
| + EXPECT_TRUE(password_autofill_agent_->FillSuggestion( |
| + password_element_, kAliceUsername, kAlicePassword)); |
| + |
| + // Simulate a user clicking on not autofilled password fields. This should |
| + // produce |
| + // no suggestion dropdowns. |
| + render_thread_->sink().ClearMessages(); |
| + SimulateElementClick("newpassword"); |
| + SimulateElementClick("confirmpassword"); |
| + EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| + AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| + |
| + // But when the user clicks on the autofilled password field again it should |
| + // still produce a suggestion dropdown. |
| + SimulateElementClick("password"); |
| + CheckSuggestions("", false); |
| +} |
| + |
| } // namespace autofill |