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

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

Issue 1169903007: [NOT FOR REVIEW][Omnibox] Changing protocol scheme from https:// to http:// results in DCHECK. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months 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/renderer/autofill/password_autofill_agent_browsertest.cc » ('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 e1e76ebba00e0f3be8d7eeca865c039d822266c5..8d3e07e024e53cde701c5fab11f572e7c5951a16 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -2167,4 +2167,148 @@ 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,
+ AutofillSuggetionsForChangePasswordFormWithoutNameOrIdAttribute) {
+ // 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_no_name_id').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_no_name_id').elements[1].value);";
+ std::string actual_password;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ RenderViewHost(), get_password, &actual_password));
+ EXPECT_EQ("mypassword", actual_password);
+}
+
} // namespace password_manager
« no previous file with comments | « no previous file | chrome/renderer/autofill/password_autofill_agent_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698