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

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

Issue 2917933002: [PasswordGeneration] Improve change/confirm password field detection. (Closed)
Patch Set: Address more comments. Created 3 years, 6 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
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 ecfa0783c933e2837e511b536339f2eb12a7966f..6f0ff9e6f63815784c06e8aa43b2c4bbbe24ec15 100644
--- a/chrome/renderer/autofill/password_generation_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_generation_agent_browsertest.cc
@@ -91,13 +91,7 @@ class PasswordGenerationAgentTest : public ChromeRenderViewTest {
bool available) {
FocusField(element_id);
base::RunLoop().RunUntilIdle();
- fake_pw_client_.Flush();
- bool called = fake_pw_client_.called_show_pw_generation_popup();
- if (available)
- ASSERT_TRUE(called);
- else
- ASSERT_FALSE(called);
-
+ ASSERT_EQ(available, GetCalledShowPasswordGenerationPopup());
fake_pw_client_.reset_called_show_pw_generation_popup();
}
@@ -249,6 +243,18 @@ const char kNewPasswordAutocompleteAttributeFormHTML[] =
" <INPUT type = 'submit' value = 'LOGIN' />"
"</FORM>";
+const char kCurrentAndNewPasswordAutocompleteAttributeFormHTML[] =
+ "<FORM name = 'blah' action = 'http://www.random.com/'> "
+ " <INPUT type = 'password' id = 'old_password' "
+ " autocomplete='current-password'/>"
+ " <INPUT type = 'password' id = 'new_password' "
+ " autocomplete='new-password'/>"
+ " <INPUT type = 'password' id = 'confirm_password' "
+ " autocomplete='new-password'/>"
+ " <INPUT type = 'button' id = 'dummy'/> "
+ " <INPUT type = 'submit' value = 'LOGIN' />"
+ "</FORM>";
+
const char kPasswordChangeFormHTML[] =
"<FORM name = 'ChangeWithUsernameForm' action = 'http://www.bidule.com'> "
" <INPUT type = 'text' id = 'username'/> "
@@ -605,21 +611,27 @@ TEST_F(PasswordGenerationAgentTest, AutocompleteAttributesTest) {
LoadHTMLWithUserGesture(kBothAutocompleteAttributesFormHTML);
SetNotBlacklistedMessage(password_generation_,
kBothAutocompleteAttributesFormHTML);
-
ExpectGenerationAvailable("first_password", true);
- // Only setting one of the two attributes doesn't trigger generation.
+ // Only username autocomplete attribute enabled doesn't trigger generation.
LoadHTMLWithUserGesture(kUsernameAutocompleteAttributeFormHTML);
SetNotBlacklistedMessage(password_generation_,
kUsernameAutocompleteAttributeFormHTML);
-
ExpectGenerationAvailable("first_password", false);
+ // Only new-password autocomplete attribute enabled does trigger generation.
LoadHTMLWithUserGesture(kNewPasswordAutocompleteAttributeFormHTML);
SetNotBlacklistedMessage(password_generation_,
kNewPasswordAutocompleteAttributeFormHTML);
+ ExpectGenerationAvailable("first_password", true);
- ExpectGenerationAvailable("first_password", false);
+ // Generation is triggered if the form has only password fields.
+ LoadHTMLWithUserGesture(kCurrentAndNewPasswordAutocompleteAttributeFormHTML);
+ SetNotBlacklistedMessage(password_generation_,
+ kCurrentAndNewPasswordAutocompleteAttributeFormHTML);
+ ExpectGenerationAvailable("old_password", false);
+ ExpectGenerationAvailable("new_password", true);
+ ExpectGenerationAvailable("confirm_password", false);
}
TEST_F(PasswordGenerationAgentTest, ChangePasswordFormDetectionTest) {

Powered by Google App Engine
This is Rietveld 408576698