| 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 14246f500f8821e2d5dff5aaa66c1fd77de098c4..fda66e9e8d2bf7a74c0e058ac5b8cb3446b1a48f 100644
|
| --- a/chrome/browser/password_manager/password_manager_browsertest.cc
|
| +++ b/chrome/browser/password_manager/password_manager_browsertest.cc
|
| @@ -1491,52 +1491,6 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
|
| EXPECT_FALSE(prompt_observer->IsShowingPrompt());
|
| }
|
|
|
| -// The password manager should distinguish forms with empty actions. After
|
| -// successful login, the login form disappears, but the another one shouldn't be
|
| -// recognized as the login form. The save prompt should appear.
|
| -// Disabled on Mac and Android.
|
| -// TODO(kolos) Turn on this when the update prompt will be implemented on Mac
|
| -// and Android.
|
| -#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
|
| -IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
|
| - PromptForPushStateWhenFormWithEmptyActionDisappears) {
|
| - NavigateToFile("/password/password_push_state.html");
|
| -
|
| - NavigationObserver observer(WebContents());
|
| - observer.set_quit_on_entry_committed(true);
|
| - scoped_ptr<PromptObserver> prompt_observer(
|
| - PromptObserver::Create(WebContents()));
|
| - std::string fill_and_submit =
|
| - "document.getElementById('ea_username_field').value = 'temp';"
|
| - "document.getElementById('ea_password_field').value = 'random';"
|
| - "document.getElementById('ea_submit_button').click()";
|
| - ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
|
| - observer.Wait();
|
| - EXPECT_TRUE(prompt_observer->IsShowingPrompt());
|
| -}
|
| -
|
| -// Similar to the case above, but this time the form persists after
|
| -// 'history.pushState()'. The password manager should find the login form even
|
| -// if the action of the form is empty. Save password prompt should not show up.
|
| -IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
|
| - PromptForPushStateWhenFormWithEmptyActionPersists) {
|
| - NavigateToFile("/password/password_push_state.html");
|
| -
|
| - NavigationObserver observer(WebContents());
|
| - observer.set_quit_on_entry_committed(true);
|
| - scoped_ptr<PromptObserver> prompt_observer(
|
| - PromptObserver::Create(WebContents()));
|
| - std::string fill_and_submit =
|
| - "should_delete_testform = false;"
|
| - "document.getElementById('ea_username_field').value = 'temp';"
|
| - "document.getElementById('ea_password_field').value = 'random';"
|
| - "document.getElementById('ea_submit_button').click()";
|
| - ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
|
| - observer.Wait();
|
| - EXPECT_FALSE(prompt_observer->IsShowingPrompt());
|
| -}
|
| -#endif // !OS_MACOSX && !OS_ANDROID
|
| -
|
| IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
|
| InFrameNavigationDoesNotClearPopupState) {
|
| // Mock out the AutofillClient so we know how long to wait. Unfortunately
|
| @@ -2213,4 +2167,275 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
|
| }
|
| #endif
|
|
|
| +// Test whether the password form with the username and password fields having
|
| +// ambiguity in id attribute gets autofilled correctly.
|
| +IN_PROC_BROWSER_TEST_F(
|
| + PasswordManagerBrowserTestBase,
|
| + AutofillSuggetionsForPasswordFormWithAmbiguousIdAttribute) {
|
| + // 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 password form having ambiguous Ids for username and
|
| + // password fields and verify whether username and password is autofilled.
|
| + NavigateToFile("/password/ambiguous_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('ambiguous_form').elements[0].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('ambiguous_form').elements[1].value);";
|
| + std::string actual_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_password, &actual_password));
|
| + EXPECT_EQ("mypassword", actual_password);
|
| +}
|
| +
|
| +// Test whether the password form having username and password fields without
|
| +// name and id attribute gets autofilled correctly.
|
| +IN_PROC_BROWSER_TEST_F(
|
| + PasswordManagerBrowserTestBase,
|
| + AutofillSuggetionsForPasswordFormWithoutNameOrIdAttribute) {
|
| + // 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 password form having no Ids for username and password
|
| + // fields and verify whether username and password is autofilled.
|
| + NavigateToFile("/password/ambiguous_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('no_name_id_form').elements[0].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('no_name_id_form').elements[1].value);";
|
| + std::string actual_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_password, &actual_password));
|
| + EXPECT_EQ("mypassword", actual_password);
|
| +}
|
| +
|
| +// Test whether the change password form having username and password fields
|
| +// without name and id attribute gets autofilled correctly.
|
| +IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
|
| + AutofillSuggetionsForChangePwdWithEmptyNames) {
|
| + // 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 password form having no Ids for username and password
|
| + // fields and verify whether username and password is autofilled.
|
| + NavigateToFile("/password/ambiguous_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("
|
| + " 'change_pwd_but_no_autocomplete').elements[0].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("
|
| + " 'change_pwd_but_no_autocomplete').elements[1].value);";
|
| + std::string actual_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_password, &actual_password));
|
| + EXPECT_EQ("mypassword", actual_password);
|
| +
|
| + std::string get_new_password =
|
| + "window.domAutomationController.send("
|
| + " document.getElementById("
|
| + " 'change_pwd_but_no_autocomplete').elements[2].value);";
|
| + std::string new_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_new_password, &new_password));
|
| + EXPECT_EQ("", new_password);
|
| +}
|
| +
|
| +// Test whether the change password form having username and password fields
|
| +// with empty names but having |autocomplete='current-password'| gets autofilled
|
| +// correctly.
|
| +IN_PROC_BROWSER_TEST_F(
|
| + PasswordManagerBrowserTestBase,
|
| + AutofillSuggetionsForChangePwdWithEmptyNamesAndAutocomplete) {
|
| + // 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 password form having no Ids for username and password
|
| + // fields and verify whether username and password is autofilled.
|
| + NavigateToFile("/password/ambiguous_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('change_pwd').elements[0].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('change_pwd').elements[1].value);";
|
| + std::string actual_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_password, &actual_password));
|
| + EXPECT_EQ("mypassword", actual_password);
|
| +
|
| + std::string get_new_password =
|
| + "window.domAutomationController.send("
|
| + " document.getElementById('change_pwd').elements[2].value);";
|
| + std::string new_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_new_password, &new_password));
|
| + EXPECT_EQ("", new_password);
|
| +}
|
| +
|
| +// Test whether the change password form having username and password fields
|
| +// with empty names but having only new password fields having
|
| +// |autocomplete='new-password'| atrribute do not get autofilled.
|
| +IN_PROC_BROWSER_TEST_F(
|
| + PasswordManagerBrowserTestBase,
|
| + AutofillSuggetionsForChangePwdWithEmptyNamesButOnlyNewPwdField) {
|
| + // 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 password form having no Ids for username and password
|
| + // fields and verify whether username and password is autofilled.
|
| + NavigateToFile("/password/ambiguous_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("
|
| + " 'change_pwd_but_no_old_pwd').elements[0].value);";
|
| + std::string actual_username;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_username, &actual_username));
|
| + EXPECT_EQ("", actual_username);
|
| +
|
| + std::string get_new_password =
|
| + "window.domAutomationController.send("
|
| + " document.getElementById("
|
| + " 'change_pwd_but_no_old_pwd').elements[1].value);";
|
| + std::string new_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_new_password, &new_password));
|
| + EXPECT_EQ("", new_password);
|
| +
|
| + std::string get_retype_password =
|
| + "window.domAutomationController.send("
|
| + " document.getElementById("
|
| + " 'change_pwd_but_no_old_pwd').elements[2].value);";
|
| + std::string retyped_password;
|
| + ASSERT_TRUE(content::ExecuteScriptAndExtractString(
|
| + RenderViewHost(), get_retype_password, &retyped_password));
|
| + EXPECT_EQ("", retyped_password);
|
| +}
|
| +
|
| } // namespace password_manager
|
|
|