| OLD | NEW |
| 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 <tuple> | 5 #include <tuple> |
| 6 | 6 |
| 7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 fill_data_.wait_for_username = true; | 935 fill_data_.wait_for_username = true; |
| 936 SimulateOnFillPasswordForm(fill_data_); | 936 SimulateOnFillPasswordForm(fill_data_); |
| 937 | 937 |
| 938 // The username and password should not yet have been autocompleted. | 938 // The username and password should not yet have been autocompleted. |
| 939 CheckTextFieldsState(std::string(), false, std::string(), false); | 939 CheckTextFieldsState(std::string(), false, std::string(), false); |
| 940 | 940 |
| 941 // Simulate a click just to force a user gesture, since the username value is | 941 // Simulate a click just to force a user gesture, since the username value is |
| 942 // set directly. | 942 // set directly. |
| 943 SimulateElementClick(kUsernameName); | 943 SimulateElementClick(kUsernameName); |
| 944 | 944 |
| 945 // Simulate the user entering the first letter of her username and selecting | 945 // Simulate the user entering the first letter of their username and selecting |
| 946 // the matching autofill from the dropdown. | 946 // the matching autofill from the dropdown. |
| 947 SimulateUsernameChange("a"); | 947 SimulateUsernameChange("a"); |
| 948 SimulateSuggestionChoice(username_element_); | 948 SimulateSuggestionChoice(username_element_); |
| 949 | 949 |
| 950 // The username and password should now have been autocompleted. | 950 // The username and password should now have been autocompleted. |
| 951 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); | 951 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); |
| 952 | 952 |
| 953 // JavaScript onChange events should have been triggered both for the username | 953 // JavaScript onChange events should have been triggered both for the username |
| 954 // and for the password. | 954 // and for the password. |
| 955 int username_onchange_called = -1; | 955 int username_onchange_called = -1; |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 // The user first accepts a suggestion, but then overwrites the password. This | 1447 // The user first accepts a suggestion, but then overwrites the password. This |
| 1448 // test checks that the overwritten password is not reverted back if the user | 1448 // test checks that the overwritten password is not reverted back if the user |
| 1449 // triggers autofill through focusing (but not changing) the username again. | 1449 // triggers autofill through focusing (but not changing) the username again. |
| 1450 TEST_F(PasswordAutofillAgentTest, | 1450 TEST_F(PasswordAutofillAgentTest, |
| 1451 NoopEditingDoesNotOverwriteManuallyEditedPassword) { | 1451 NoopEditingDoesNotOverwriteManuallyEditedPassword) { |
| 1452 // Simulate having credentials which needed to wait until the user starts | 1452 // Simulate having credentials which needed to wait until the user starts |
| 1453 // typing the username to be filled (e.g., PSL-matched credentials). Those are | 1453 // typing the username to be filled (e.g., PSL-matched credentials). Those are |
| 1454 // the ones which can be filled as a result of TextFieldDidEndEditing. | 1454 // the ones which can be filled as a result of TextFieldDidEndEditing. |
| 1455 fill_data_.wait_for_username = true; | 1455 fill_data_.wait_for_username = true; |
| 1456 SimulateOnFillPasswordForm(fill_data_); | 1456 SimulateOnFillPasswordForm(fill_data_); |
| 1457 // Simulate that the user typed her name to make the autofill work. | 1457 // Simulate that the user typed their name to make the autofill work. |
| 1458 SimulateUsernameChange(kAliceUsername); | 1458 SimulateUsernameChange(kAliceUsername); |
| 1459 SimulateDidEndEditing(GetMainFrame(), username_element_); | 1459 SimulateDidEndEditing(GetMainFrame(), username_element_); |
| 1460 const std::string old_username(username_element_.value().utf8()); | 1460 const std::string old_username(username_element_.value().utf8()); |
| 1461 const std::string old_password(password_element_.value().utf8()); | 1461 const std::string old_password(password_element_.value().utf8()); |
| 1462 const std::string new_password(old_password + "modify"); | 1462 const std::string new_password(old_password + "modify"); |
| 1463 | 1463 |
| 1464 // The user changes the password. | 1464 // The user changes the password. |
| 1465 SimulatePasswordChange(new_password); | 1465 SimulatePasswordChange(new_password); |
| 1466 | 1466 |
| 1467 // The user switches back into the username field, but leaves that without | 1467 // The user switches back into the username field, but leaves that without |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2374 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( | 2374 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( |
| 2375 AutofillHostMsg_ShowPasswordSuggestions::ID)); | 2375 AutofillHostMsg_ShowPasswordSuggestions::ID)); |
| 2376 | 2376 |
| 2377 // But when the user clicks on the autofilled password field again it should | 2377 // But when the user clicks on the autofilled password field again it should |
| 2378 // still produce a suggestion dropdown. | 2378 // still produce a suggestion dropdown. |
| 2379 SimulateElementClick("password"); | 2379 SimulateElementClick("password"); |
| 2380 CheckSuggestions("", false); | 2380 CheckSuggestions("", false); |
| 2381 } | 2381 } |
| 2382 | 2382 |
| 2383 } // namespace autofill | 2383 } // namespace autofill |
| OLD | NEW |