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

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 2906383003: Teach PasswordAutofillAgent sometimes match prefixes of usernames (Closed)
Patch Set: dvadym@ 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 AutocompletePasswordForReadonlyUsernameMatched) { 710 AutocompletePasswordForReadonlyUsernameMatched) {
711 username_element_.SetValue(WebString::FromUTF16(username3_)); 711 username_element_.SetValue(WebString::FromUTF16(username3_));
712 SetElementReadOnly(username_element_, true); 712 SetElementReadOnly(username_element_, true);
713 713
714 // Filled even though username is not the preferred match. 714 // Filled even though username is not the preferred match.
715 SimulateOnFillPasswordForm(fill_data_); 715 SimulateOnFillPasswordForm(fill_data_);
716 CheckTextFieldsState(UTF16ToUTF8(username3_), false, 716 CheckTextFieldsState(UTF16ToUTF8(username3_), false,
717 UTF16ToUTF8(password3_), true); 717 UTF16ToUTF8(password3_), true);
718 } 718 }
719 719
720 // Fill a password field if the stored username is a prefix of username in
721 // read-only field.
722 TEST_F(PasswordAutofillAgentTest,
723 AutocompletePasswordForReadonlyUsernamePrefixMatched) {
vabr (Chromium) 2017/06/12 18:56:58 Could you please also add a negative test? For exa
melandory 2017/06/19 10:53:48 Done
724 base::string16 username_at = username3_ + base::UTF8ToUTF16("@example.com");
725 username_element_.SetValue(WebString::FromUTF16(username3_));
726 SetElementReadOnly(username_element_, true);
727
728 // Filled even though username is not the preferred match.
vabr (Chromium) 2017/06/12 18:56:58 nit: "preferred match" is a sort of a term, used i
melandory 2017/06/19 10:53:48 Done.
729 SimulateOnFillPasswordForm(fill_data_);
730 CheckTextFieldsState(UTF16ToUTF8(username3_), false, UTF16ToUTF8(password3_),
731 true);
732 }
720 // If a username field is empty and readonly, don't autofill. 733 // If a username field is empty and readonly, don't autofill.
721 TEST_F(PasswordAutofillAgentTest, 734 TEST_F(PasswordAutofillAgentTest,
722 NoAutocompletePasswordForReadonlyUsernameUnmatched) { 735 NoAutocompletePasswordForReadonlyUsernameUnmatched) {
723 username_element_.SetValue(WebString::FromUTF8("")); 736 username_element_.SetValue(WebString::FromUTF8(""));
724 SetElementReadOnly(username_element_, true); 737 SetElementReadOnly(username_element_, true);
725 738
726 SimulateOnFillPasswordForm(fill_data_); 739 SimulateOnFillPasswordForm(fill_data_);
727 CheckTextFieldsState(std::string(), false, std::string(), false); 740 CheckTextFieldsState(std::string(), false, std::string(), false);
728 } 741 }
729 742
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 TEST_F(PasswordAutofillAgentTest, AutocompleteWhenPageUrlIsChanged) { 2967 TEST_F(PasswordAutofillAgentTest, AutocompleteWhenPageUrlIsChanged) {
2955 // Simulate that JavaScript changes url. 2968 // Simulate that JavaScript changes url.
2956 fill_data_.origin = GURL(fill_data_.origin.possibly_invalid_spec() + "/path"); 2969 fill_data_.origin = GURL(fill_data_.origin.possibly_invalid_spec() + "/path");
2957 2970
2958 SimulateOnFillPasswordForm(fill_data_); 2971 SimulateOnFillPasswordForm(fill_data_);
2959 2972
2960 // The username and password should have been autocompleted. 2973 // The username and password should have been autocompleted.
2961 CheckTextFieldsState(kAliceUsername, true, kAlicePassword, true); 2974 CheckTextFieldsState(kAliceUsername, true, kAlicePassword, true);
2962 } 2975 }
2963 } // namespace autofill 2976 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698