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

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

Issue 2947403003: Prefer the exact match over prefix match for the password manager filling.
Patch Set: Prefer the exact match over prefix match. 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 551dd8a99578f6160c6503d954d913c96816d4bd..2bd0b74c677a1149d6299ce3bc4473d25ed51408 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -68,6 +68,7 @@ const char kCreditCardVerificationName[] = "cvc";
const char kAliceUsername[] = "alice";
const char kAlicePassword[] = "password";
const char kBobUsername[] = "bob";
+const char kBobAtUsername[] = "bob@example.com";
const char kBobPassword[] = "secret";
const char kCarolUsername[] = "Carol";
const char kCarolPassword[] = "test";
@@ -283,6 +284,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
password1_ = ASCIIToUTF16(kAlicePassword);
username2_ = ASCIIToUTF16(kBobUsername);
password2_ = ASCIIToUTF16(kBobPassword);
+ username2at_ = ASCIIToUTF16(kBobAtUsername);
username3_ = ASCIIToUTF16(kCarolUsername);
password3_ = ASCIIToUTF16(kCarolPassword);
alternate_username3_ = ASCIIToUTF16(kCarolAlternateUsername);
@@ -304,6 +306,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
PasswordAndRealm password3;
password3.password = password3_;
fill_data_.additional_logins[username3_] = password3;
+ fill_data_.additional_logins[username2at_] = password3;
UsernamesCollectionKey key;
key.username = username3_;
@@ -619,6 +622,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
base::string16 username1_;
base::string16 username2_;
+ base::string16 username2at_;
base::string16 username3_;
base::string16 password1_;
base::string16 password2_;
@@ -764,6 +768,15 @@ TEST_F(
false);
}
+// Tests that the exact match is always preferred.
+TEST_F(PasswordAutofillAgentTest, TestThatExactMatchIsPreffered) {
+ username_element_.SetValue(WebString::FromUTF16(username2at_));
+
+ SimulateOnFillPasswordForm(fill_data_);
+ CheckTextFieldsState(UTF16ToUTF8(username2at_), false,
vabr (Chromium) 2017/06/23 06:58:11 Yes, these two "false" should be "true" (we expect
+ UTF16ToUTF8(password3_), 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