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

Unified Diff: chrome/renderer/autofill/password_generation_agent_browsertest.cc

Issue 1817483002: [Password Manager] Presave the form with generated password till successful login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed CPMD_BAD_ORIGIN_UPDATE_PRESAVED_PASSWORD in bad_message.h Created 4 years, 8 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 | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/password_generation_agent_browsertest.cc
diff --git a/chrome/renderer/autofill/password_generation_agent_browsertest.cc b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
index 410b75b8ba8675c49412455c0a1286e1ade25051..7f89123640333db59904e9935e1695f8da295a33 100644
--- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
@@ -575,11 +575,13 @@ TEST_F(PasswordGenerationAgentTest, ChangePasswordFormDetectionTest) {
SetNotBlacklistedMessage(password_generation_, kPasswordChangeFormHTML);
ExpectGenerationAvailable("password", false);
ExpectGenerationAvailable("newpassword", false);
+ ExpectGenerationAvailable("confirmpassword", false);
SetAccountCreationFormsDetectedMessage(password_generation_,
GetMainFrame()->document(), 0, 2);
ExpectGenerationAvailable("password", false);
ExpectGenerationAvailable("newpassword", true);
+ ExpectGenerationAvailable("confirmpassword", false);
}
TEST_F(PasswordGenerationAgentTest, ManualGenerationInFormTest) {
@@ -607,4 +609,41 @@ TEST_F(PasswordGenerationAgentTest, ManualGenerationChangeFocusTest) {
ExpectGenerationAvailable("second_password", false);
}
+TEST_F(PasswordGenerationAgentTest, PresavingGeneratedPassword) {
+ const struct {
+ const char* form;
+ const char* generation_element;
+ } kTestCases[] = {{kAccountCreationFormHTML, "first_password"},
+ {kAccountCreationNoForm, "first_password"},
+ {kPasswordChangeFormHTML, "newpassword"}};
+ for (auto& test_case : kTestCases) {
+ SCOPED_TRACE(testing::Message("form: ") << test_case.form);
+ LoadHTMLWithUserGesture(test_case.form);
+ // To be able to work with input elements outside <form>'s, use manual
+ // generation.
+ ShowGenerationPopUpManually(test_case.generation_element);
+ ExpectGenerationAvailable(test_case.generation_element, true);
+
+ base::string16 password = base::ASCIIToUTF16("random_password");
+ AutofillMsg_GeneratedPasswordAccepted msg(0, password);
+ password_generation_->OnMessageReceived(msg);
+ EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_PresaveGeneratedPassword::ID));
+ render_thread_->sink().ClearMessages();
+
+ FocusField(test_case.generation_element);
+ SimulateUserTypingASCIICharacter('a', true);
+ EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_PresaveGeneratedPassword::ID));
+ render_thread_->sink().ClearMessages();
+
+ for (size_t i = 0; i < password.length(); ++i)
+ SimulateUserTypingASCIICharacter(ui::VKEY_BACK, false);
+ SimulateUserTypingASCIICharacter(ui::VKEY_BACK, true);
+ EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
+ AutofillHostMsg_PasswordNoLongerGenerated::ID));
+ render_thread_->sink().ClearMessages();
+ }
+}
+
} // namespace autofill
« no previous file with comments | « no previous file | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698