Chromium Code Reviews| 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 0f5dfdcf5fae27488ffa73175acdc788047d26ad..e019b3a4132f9890ee0086fbbe80e9046cbdc1fd 100644 |
| --- a/chrome/browser/password_manager/password_manager_browsertest.cc |
| +++ b/chrome/browser/password_manager/password_manager_browsertest.cc |
| @@ -2552,6 +2552,56 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| password_manager->RemoveObserver(&mock_login_model_observer); |
| } |
| +// Test whether the password form which is loaded as hidden is autofilled |
| +// correctly. This happens very often in situations when in order to sign-in the |
| +// user clicks a sign-in button and a hidden passsword form becomes visible. |
| +// This test has difference from AutofillSuggetionsForProblematicPasswordForm |
|
vabr (Chromium)
2015/11/05 16:29:46
nit: has difference ... that -> differs ... in tha
dvadym
2015/11/05 16:51:27
Done.
|
| +// that the form is hidden and in that test only some fields are hidden. |
| +IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| + AutofillSuggetionsHiddenPasswordForm) { |
| + // At first let us save credentials to the PasswordManager. |
| + scoped_refptr<password_manager::PasswordStore> password_store = |
| + PasswordStoreFactory::GetForProfile(browser()->profile(), |
| + ServiceAccessType::IMPLICIT_ACCESS); |
| + autofill::PasswordForm login_form; |
| + login_form.signon_realm = embedded_test_server()->base_url().spec(); |
| + login_form.action = embedded_test_server()->GetURL("/password/done.html"); |
| + login_form.username_value = base::ASCIIToUTF16("myusername"); |
| + login_form.password_value = base::ASCIIToUTF16("mypassword"); |
| + password_store->AddLogin(login_form); |
| + |
| + // Logins are added asynchronously to the password store. Spin the message |
| + // loop to make sure the |password_store| had a chance to store the |
| + // |login_form|. |
| + base::RunLoop run_loop; |
| + run_loop.RunUntilIdle(); |
| + |
| + // Now, navigate to the hidden password form and verify whether username and |
| + // password is autofilled. |
| + NavigateToFile("/password/password_form.html"); |
| + |
| + // Let the user interact with the page, so that DOM gets modification events, |
| + // needed for autofilling fields. |
| + content::SimulateMouseClickAt( |
| + WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(1, 1)); |
| + |
| + std::string get_username = |
| + "window.domAutomationController.send(" |
| + " document.getElementById('hidden_password_form_username').value);"; |
| + std::string actual_username; |
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| + RenderViewHost(), get_username, &actual_username)); |
| + EXPECT_EQ("myusername", actual_username); |
| + |
| + std::string get_password = |
| + "window.domAutomationController.send(" |
| + " document.getElementById('hidden_password_form_password').value);"; |
| + std::string actual_password; |
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| + RenderViewHost(), get_password, &actual_password)); |
| + EXPECT_EQ("mypassword", actual_password); |
| +} |
| + |
| // Test whether the password form with the problematic invisible password field |
| // gets autofilled correctly. |
| IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| @@ -2573,8 +2623,8 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| base::RunLoop run_loop; |
| run_loop.RunUntilIdle(); |
| - // Now, navigate to the password form having ambiguous Ids for username and |
| - // password fields and verify whether username and password is autofilled. |
| + // Now, navigate to the password form with a hidden password field and verify |
| + // whether username and password is autofilled. |
| NavigateToFile("/password/password_form.html"); |
| // Let the user interact with the page, so that DOM gets modification events, |
| @@ -2584,7 +2634,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| std::string get_username = |
| "window.domAutomationController.send(" |
| - " document.getElementById('username').value);"; |
| + " document.getElementById('form_with_hidden_password_username').value);"; |
| std::string actual_username; |
| ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| RenderViewHost(), get_username, &actual_username)); |
| @@ -2592,7 +2642,7 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| std::string get_password = |
| "window.domAutomationController.send(" |
| - " document.getElementById('password').value);"; |
| + " document.getElementById('form_with_hidden_password_password').value);"; |
| std::string actual_password; |
| ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| RenderViewHost(), get_password, &actual_password)); |