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 6f83caa5c02c40fb1db4dfd9473294d95e50aaa6..55db5742595390d444dadd8ee968fd7e2f2a0d4a 100644 |
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| @@ -342,7 +342,7 @@ TEST_F(PasswordAutofillAgentTest, InitialAutocompleteForEmptyAction) { |
| // Tests that if a password or input element is marked as readonly, neither |
| // field is autofilled on page load. |
| -TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForReadOnly) { |
| +TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForReadOnlyPassword) { |
| password_element_.setAttribute(WebString::fromUTF8("readonly"), |
| WebString::fromUTF8("true")); |
| @@ -353,8 +353,30 @@ TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForReadOnly) { |
| CheckTextFieldsState(std::string(), false, std::string(), false); |
| } |
| -// Tests that having a non-matching username precludes the autocomplete. |
| -TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForFilledField) { |
| +// Can still fill a password field if the username is set to a value that |
| +// matches. If it's set to something that doesn't match any username that |
| +// we know about, we leave the field untouched. |
|
Ilya Sherman
2013/11/04 23:10:48
Please write separate tests cases for the two beha
Garrett Casto
2013/11/05 00:40:35
Done.
|
| +TEST_F(PasswordAutofillAgentTest, AutocompletePasswordForReadonlyUsername) { |
| + username_element_.setValue(username3_); |
| + username_element_.setAttribute(WebString::fromUTF8("readonly"), |
| + WebString::fromUTF8("true")); |
| + |
| + SimulateOnFillPasswordForm(fill_data_); |
| + CheckTextFieldsState(UTF16ToUTF8(username3_), true, |
| + UTF16ToUTF8(password3_), true); |
| + |
| + ClearUsernameAndPasswordFields(); |
| + |
| + // If the name is empty, don't fill the password. |
| + username_element_.setValue(WebString::fromUTF8("")); |
| + |
| + SimulateOnFillPasswordForm(fill_data_); |
| + CheckTextFieldsState(std::string(), false, std::string(), false); |
| +} |
| + |
| +// Tests that having a non-matching username precludes the autocomplete, but |
| +// having a matching username will allow autofilling. |
|
Ilya Sherman
2013/11/04 23:10:48
Please write a separate test case for having a mat
Garrett Casto
2013/11/05 00:40:35
The first is different in that the field is prefil
|
| +TEST_F(PasswordAutofillAgentTest, AutocompleteForFilledField) { |
| username_element_.setValue(WebString::fromUTF8("bogus")); |
| // Simulate the browser sending back the login info, it triggers the |
| @@ -363,6 +385,15 @@ TEST_F(PasswordAutofillAgentTest, NoInitialAutocompleteForFilledField) { |
| // Neither field should be autocompleted. |
| CheckTextFieldsState("bogus", false, std::string(), false); |
| + |
| + // Make sure that even if the username isn't preferred, we will fill the |
| + // correct password if this preset. |
| + ClearUsernameAndPasswordFields(); |
| + username_element_.setValue(username2_); |
| + |
| + SimulateOnFillPasswordForm(fill_data_); |
| + CheckTextFieldsState(UTF16ToUTF8(username2_), true, |
| + UTF16ToUTF8(password2_), true); |
| } |
| // Tests that we do not autofill username/passwords if marked as |