| Index: chrome/browser/password_manager/password_manager_browsertest.cc
|
| diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
|
| index ae0d1bf10b8dca53bf5fdd612069827ebaa7920e..67f32a1e4730e49f470f00a85e401c7325cd1038 100644
|
| --- a/chrome/browser/password_manager/password_manager_browsertest.cc
|
| +++ b/chrome/browser/password_manager/password_manager_browsertest.cc
|
| @@ -1315,3 +1315,45 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
|
| // Wait until that interaction causes the password value to be revealed.
|
| WaitForElementValue("password", "mypassword");
|
| }
|
| +
|
| +// Test that if a form gets autofilled, then it gets autofilled on re-creation
|
| +// as well.
|
| +IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, ReCreatedFormsGetFilled) {
|
| + NavigateToFile("/password/dynamic_password_form.html");
|
| +
|
| + // Fill in the credentials, and make sure they are saved.
|
| + NavigationObserver form_submit_observer(WebContents());
|
| + scoped_ptr<PromptObserver> prompt_observer(
|
| + PromptObserver::Create(WebContents()));
|
| + std::string create_fill_and_submit =
|
| + "document.getElementById('create_form_button').click();"
|
| + "window.setTimeout(function() {"
|
| + " var form = document.getElementById('dynamic_form_id');"
|
| + " form.username.value = 'temp';"
|
| + " form.password.value = 'random';"
|
| + " form.submit();"
|
| + "}, 0)";
|
| + ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_fill_and_submit));
|
| + form_submit_observer.Wait();
|
| + EXPECT_TRUE(prompt_observer->IsShowingPrompt());
|
| + prompt_observer->Accept();
|
| +
|
| + // Reload the original page to have the saved credentials autofilled.
|
| + NavigationObserver reload_observer(WebContents());
|
| + NavigateToFile("/password/dynamic_password_form.html");
|
| + reload_observer.Wait();
|
| + std::string create_form =
|
| + "document.getElementById('create_form_button').click();";
|
| + ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_form));
|
| + // Wait until the username is filled, to make sure autofill kicked in.
|
| + WaitForElementValue("username_id", "temp");
|
| +
|
| + // Now the form gets deleted and created again. It should get autofilled
|
| + // again.
|
| + std::string delete_form =
|
| + "var form = document.getElementById('dynamic_form_id');"
|
| + "form.parentNode.removeChild(form);";
|
| + ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), delete_form));
|
| + ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_form));
|
| + WaitForElementValue("username_id", "temp");
|
| +}
|
|
|