| 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..540604dda0a953312aa0c9617e10e4ffc3062770 100644
|
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
|
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
|
| @@ -90,6 +90,14 @@ const char kNonVisibleFormHTML[] =
|
| " </form>"
|
| "</body>";
|
|
|
| +const char kSignupFormHTML[] =
|
| + "<FORM name='LoginTestForm' action='http://www.bidule.com'>"
|
| + " <INPUT type='text' id='random_info'/>"
|
| + " <INPUT type='password' id='new_password'/>"
|
| + " <INPUT type='password' id='confirm_password'/>"
|
| + " <INPUT type='submit' value='Login'/>"
|
| + "</FORM>";
|
| +
|
| const char kEmptyWebpage[] =
|
| "<html>"
|
| " <head>"
|
| @@ -256,6 +264,10 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
|
|
|
| LoadHTML(kFormHTML);
|
|
|
| + // Necessary for SimulateElementClick() to work correctly.
|
| + GetWebWidget()->resize(blink::WebSize(500, 500));
|
| + GetWebWidget()->setFocus(true);
|
| +
|
| // Now retrieve the input elements so the test can access them.
|
| UpdateUsernameAndPasswordElements();
|
| }
|
| @@ -1863,4 +1875,42 @@ TEST_F(PasswordAutofillAgentTest,
|
| ExpectFormSubmittedWithUsernameAndPasswords(kAliceUsername, "NewPass22", "");
|
| }
|
|
|
| +// If password generation is enabled for a field, password autofill should not
|
| +// show UI.
|
| +TEST_F(PasswordAutofillAgentTest, PasswordGenerationSupersedesAutofill) {
|
| + LoadHTML(kSignupFormHTML);
|
| +
|
| + // Update password_element_;
|
| + WebDocument document = GetMainFrame()->document();
|
| + WebElement element =
|
| + document.getElementById(WebString::fromUTF8("new_password"));
|
| + ASSERT_FALSE(element.isNull());
|
| + password_element_ = element.to<blink::WebInputElement>();
|
| +
|
| + // Update fill_data_ for the new form and simulate filling. Pretend as if
|
| + // the password manager didn't detect a username field so it will try to
|
| + // show UI when the password field is focused.
|
| + fill_data_.wait_for_username = true;
|
| + fill_data_.username_field = FormFieldData();
|
| + fill_data_.password_field.name = base::ASCIIToUTF16("new_password");
|
| + UpdateOriginForHTML(kSignupFormHTML);
|
| + SimulateOnFillPasswordForm(fill_data_);
|
| +
|
| + // Simulate generation triggering.
|
| + SetNotBlacklistedMessage(password_generation_,
|
| + kSignupFormHTML);
|
| + SetAccountCreationFormsDetectedMessage(password_generation_,
|
| + GetMainFrame()->document(),
|
| + 0);
|
| +
|
| + // Simulate the field being clicked to start typing. This should trigger
|
| + // generation but not password autofill.
|
| + SetFocused(password_element_);
|
| + SimulateElementClick("new_password");
|
| + EXPECT_EQ(nullptr,
|
| + render_thread_->sink().GetFirstMessageMatching(
|
| + AutofillHostMsg_ShowPasswordSuggestions::ID));
|
| + ExpectPasswordGenerationAvailable(password_generation_, true);
|
| +}
|
| +
|
| } // namespace autofill
|
|
|