| 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 11a4e11d4ef996b5187b038e6aded668e055e21e..a40dfddef1a9226892547111121271d362f9b986 100644
|
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
|
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
|
| @@ -175,6 +175,15 @@ const char kFormHTMLWithTwoTextFields[] =
|
| " <INPUT type='submit' value='Login'/>"
|
| "</FORM>";
|
|
|
| +const char kPasswordChangeFormHTML[] =
|
| + "<FORM name='ChangeWithUsernameForm' action='http://www.bidule.com'>"
|
| + " <INPUT type='text' id='username'/>"
|
| + " <INPUT type='password' id='password'/>"
|
| + " <INPUT type='password' id='newpassword'/>"
|
| + " <INPUT type='password' id='confirmpassword'/>"
|
| + " <INPUT type='submit' value='Login'/>"
|
| + "</FORM>";
|
| +
|
| // Sets the "readonly" attribute of |element| to the value given by |read_only|.
|
| void SetElementReadOnly(WebInputElement& element, bool read_only) {
|
| element.setAttribute(WebString::fromUTF8("readonly"),
|
| @@ -1863,4 +1872,45 @@ TEST_F(PasswordAutofillAgentTest,
|
| ExpectFormSubmittedWithUsernameAndPasswords(kAliceUsername, "NewPass22", "");
|
| }
|
|
|
| +// Tests that a password change form is properly filled with the username and
|
| +// password.
|
| +TEST_F(PasswordAutofillAgentTest, FillSuggestionPasswordChangeForms) {
|
| + LoadHTML(kPasswordChangeFormHTML);
|
| + UpdateOriginForHTML(kPasswordChangeFormHTML);
|
| + UpdateUsernameAndPasswordElements();
|
| + // Simulate the browser sending the login info, but set |wait_for_username|
|
| + // to prevent the form from being immediately filled.
|
| + fill_data_.wait_for_username = true;
|
| + fill_data_.is_password_change_form = true;
|
| + SimulateOnFillPasswordForm(fill_data_);
|
| +
|
| + // Neither field should have been autocompleted.
|
| + CheckTextFieldsDOMState(std::string(), false, std::string(), false);
|
| +
|
| + EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
|
| + username_element_, kAliceUsername, kAlicePassword));
|
| + CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true);
|
| +}
|
| +
|
| +// Tests that a password change form is properly filled with the password when
|
| +// the user click on the password field.
|
| +TEST_F(PasswordAutofillAgentTest,
|
| + FillSuggestionPasswordChangeFormsOnlyPassword) {
|
| + LoadHTML(kPasswordChangeFormHTML);
|
| + UpdateOriginForHTML(kPasswordChangeFormHTML);
|
| + UpdateUsernameAndPasswordElements();
|
| + // Simulate the browser sending the login info, but set |wait_for_username|
|
| + // to prevent the form from being immediately filled.
|
| + fill_data_.wait_for_username = true;
|
| + fill_data_.is_password_change_form = true;
|
| + SimulateOnFillPasswordForm(fill_data_);
|
| +
|
| + // Neither field should have been autocompleted.
|
| + CheckTextFieldsDOMState(std::string(), false, std::string(), false);
|
| +
|
| + EXPECT_TRUE(password_autofill_agent_->FillSuggestion(
|
| + password_element_, kAliceUsername, kAlicePassword));
|
| + CheckTextFieldsDOMState("", false, kAlicePassword, true);
|
| +}
|
| +
|
| } // namespace autofill
|
|
|