Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Unified Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 773823002: PasswordManager should trigger autofill for new forms + old PasswordFromManagers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't duplicate the blacklist & generation IPC Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/password/dynamic_password_form.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
+}
« no previous file with comments | « no previous file | chrome/test/data/password/dynamic_password_form.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698