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

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

Issue 2906383003: Teach PasswordAutofillAgent sometimes match prefixes of usernames (Closed)
Patch Set: . 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
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/autofill/password_autofill_agent_browsertest.cc
diff --git a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
index 9e449139f3ed44e4b3bc73bd4b187221b4573f60..551dd8a99578f6160c6503d954d913c96816d4bd 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -717,6 +717,53 @@ TEST_F(PasswordAutofillAgentTest,
UTF16ToUTF8(password3_), true);
}
+// Fill a password field if the stored username is a prefix of username in
+// read-only field.
+TEST_F(PasswordAutofillAgentTest,
+ AutocompletePasswordForReadonlyUsernamePrefixMatched) {
+ base::string16 username_at = username3_ + base::UTF8ToUTF16("@example.com");
+ username_element_.SetValue(WebString::FromUTF16(username_at));
+ SetElementReadOnly(username_element_, true);
+
+ // Filled even though the username in the form is only a proper prefix of the
+ // stored username.
+ SimulateOnFillPasswordForm(fill_data_);
+ CheckTextFieldsState(UTF16ToUTF8(username_at), false, UTF16ToUTF8(password3_),
+ true);
+}
+
+// Do not fill a password field if the stored username is a prefix without @
+// of username in read-only field.
+TEST_F(PasswordAutofillAgentTest,
+ DontAutocompletePasswordForReadonlyUsernamePrefixMatched) {
+ base::string16 prefilled_username =
+ username3_ + base::UTF8ToUTF16("example.com");
+ username_element_.SetValue(WebString::FromUTF16(prefilled_username));
+ SetElementReadOnly(username_element_, true);
+
+ // Filled even though the username in the form is only a proper prefix of the
+ // stored username.
+ SimulateOnFillPasswordForm(fill_data_);
+ CheckTextFieldsState(UTF16ToUTF8(prefilled_username), false, std::string(),
+ false);
+}
+
+// Do not fill a password field if the field isn't readonly despite the stored
+// username is a prefix without @ of username in read-only field.
+TEST_F(
+ PasswordAutofillAgentTest,
+ DontAutocompletePasswordForNotReadonlyUsernameFieldEvenWhenPrefixMatched) {
+ base::string16 prefilled_username =
+ username3_ + base::UTF8ToUTF16("@example.com");
+ username_element_.SetValue(WebString::FromUTF16(prefilled_username));
+
+ // Filled even though the username in the form is only a proper prefix of the
+ // stored username.
+ SimulateOnFillPasswordForm(fill_data_);
+ CheckTextFieldsState(UTF16ToUTF8(prefilled_username), false, std::string(),
+ false);
+}
+
// If a username field is empty and readonly, don't autofill.
TEST_F(PasswordAutofillAgentTest,
NoAutocompletePasswordForReadonlyUsernameUnmatched) {
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698