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

Side by Side 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 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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 AutocompletePasswordForReadonlyUsernameMatched) { 687 AutocompletePasswordForReadonlyUsernameMatched) {
688 username_element_.SetValue(WebString::FromUTF16(username3_)); 688 username_element_.SetValue(WebString::FromUTF16(username3_));
689 SetElementReadOnly(username_element_, true); 689 SetElementReadOnly(username_element_, true);
690 690
691 // Filled even though username is not the preferred match. 691 // Filled even though username is not the preferred match.
692 SimulateOnFillPasswordForm(fill_data_); 692 SimulateOnFillPasswordForm(fill_data_);
693 CheckTextFieldsState(UTF16ToUTF8(username3_), false, 693 CheckTextFieldsState(UTF16ToUTF8(username3_), false,
694 UTF16ToUTF8(password3_), true); 694 UTF16ToUTF8(password3_), true);
695 } 695 }
696 696
697 // Fill a password field if the stored username is a prefix of username in
698 // read-only field.
699 TEST_F(PasswordAutofillAgentTest,
700 AutocompletePasswordForReadonlyUsernamePrefixMatched) {
701 base::string16 username_at = username3_ + base::UTF8ToUTF16("@example.com");
702 username_element_.SetValue(WebString::FromUTF16(username3_));
703 SetElementReadOnly(username_element_, true);
704
705 // Filled even though username is not the preferred match.
706 SimulateOnFillPasswordForm(fill_data_);
707 CheckTextFieldsState(UTF16ToUTF8(username3_), false, UTF16ToUTF8(password3_),
708 true);
709 }
697 // If a username field is empty and readonly, don't autofill. 710 // If a username field is empty and readonly, don't autofill.
698 TEST_F(PasswordAutofillAgentTest, 711 TEST_F(PasswordAutofillAgentTest,
699 NoAutocompletePasswordForReadonlyUsernameUnmatched) { 712 NoAutocompletePasswordForReadonlyUsernameUnmatched) {
700 username_element_.SetValue(WebString::FromUTF8("")); 713 username_element_.SetValue(WebString::FromUTF8(""));
701 SetElementReadOnly(username_element_, true); 714 SetElementReadOnly(username_element_, true);
702 715
703 SimulateOnFillPasswordForm(fill_data_); 716 SimulateOnFillPasswordForm(fill_data_);
704 CheckTextFieldsState(std::string(), false, std::string(), false); 717 CheckTextFieldsState(std::string(), false, std::string(), false);
705 } 718 }
706 719
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 TEST_F(PasswordAutofillAgentTest, AutocompleteWhenPageUrlIsChanged) { 2932 TEST_F(PasswordAutofillAgentTest, AutocompleteWhenPageUrlIsChanged) {
2920 // Simulate that JavaScript changes url. 2933 // Simulate that JavaScript changes url.
2921 fill_data_.origin = GURL(fill_data_.origin.possibly_invalid_spec() + "/path"); 2934 fill_data_.origin = GURL(fill_data_.origin.possibly_invalid_spec() + "/path");
2922 2935
2923 SimulateOnFillPasswordForm(fill_data_); 2936 SimulateOnFillPasswordForm(fill_data_);
2924 2937
2925 // The username and password should have been autocompleted. 2938 // The username and password should have been autocompleted.
2926 CheckTextFieldsState(kAliceUsername, true, kAlicePassword, true); 2939 CheckTextFieldsState(kAliceUsername, true, kAlicePassword, true);
2927 } 2940 }
2928 } // namespace autofill 2941 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698