| 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 e0168719de66f2f64ddae2e2f636d6e894ecfc27..b0080c1563f138ca174f469d78e22fcd9977884d 100644
|
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
|
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
|
| @@ -1001,6 +1001,7 @@ TEST_F(PasswordAutofillAgentTest, FillSuggestion) {
|
| TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) {
|
| // Simulate the browser sending the login info, but set |wait_for_username|
|
| // to prevent the form from being immediately filled.
|
| + size_t match_start = 0;
|
| fill_data_.wait_for_username = true;
|
| SimulateOnFillPasswordForm(fill_data_);
|
|
|
| @@ -1010,7 +1011,7 @@ TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) {
|
| // If the password field is not autocompletable, it should not be affected.
|
| SetElementReadOnly(password_element_, true);
|
| EXPECT_FALSE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
| EXPECT_EQ(std::string(), username_element_.suggestedValue().utf8());
|
| EXPECT_FALSE(username_element_.isAutofilled());
|
| EXPECT_EQ(std::string(), password_element_.suggestedValue().utf8());
|
| @@ -1020,7 +1021,7 @@ TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) {
|
| // After selecting the suggestion, both fields should be previewed
|
| // with suggested values.
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
| EXPECT_EQ(
|
| kAliceUsername,
|
| static_cast<std::string>(username_element_.suggestedValue().utf8()));
|
| @@ -1035,7 +1036,7 @@ TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) {
|
| // Try previewing with a password different from the one that was initially
|
| // sent to the renderer.
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kBobUsername, kCarolPassword));
|
| + username_element_, kBobUsername, kCarolPassword, match_start));
|
| EXPECT_EQ(
|
| kBobUsername,
|
| static_cast<std::string>(username_element_.suggestedValue().utf8()));
|
| @@ -1050,6 +1051,7 @@ TEST_F(PasswordAutofillAgentTest, PreviewSuggestion) {
|
|
|
| // Tests that |PreviewSuggestion| properly sets the username selection range.
|
| TEST_F(PasswordAutofillAgentTest, PreviewSuggestionSelectionRange) {
|
| + size_t match_start = 0;
|
| username_element_.setValue(WebString::fromUTF8("ali"));
|
| username_element_.setSelectionRange(3, 3);
|
| username_element_.setAutofilled(true);
|
| @@ -1062,7 +1064,7 @@ TEST_F(PasswordAutofillAgentTest, PreviewSuggestionSelectionRange) {
|
| SimulateOnFillPasswordForm(fill_data_);
|
|
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
| EXPECT_EQ(
|
| kAliceUsername,
|
| static_cast<std::string>(username_element_.suggestedValue().utf8()));
|
| @@ -1078,6 +1080,7 @@ TEST_F(PasswordAutofillAgentTest, PreviewSuggestionSelectionRange) {
|
| // Tests that |ClearPreview| properly clears previewed username and password
|
| // with password being previously autofilled.
|
| TEST_F(PasswordAutofillAgentTest, ClearPreviewWithPasswordAutofilled) {
|
| + size_t match_start = 0;
|
| password_element_.setValue(WebString::fromUTF8("sec"));
|
| password_element_.setAutofilled(true);
|
|
|
| @@ -1089,7 +1092,7 @@ TEST_F(PasswordAutofillAgentTest, ClearPreviewWithPasswordAutofilled) {
|
| CheckTextFieldsDOMState(std::string(), false, "sec", true);
|
|
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
|
|
| EXPECT_TRUE(
|
| password_autofill_agent_->DidClearAutofillSelection(username_element_));
|
| @@ -1106,6 +1109,7 @@ TEST_F(PasswordAutofillAgentTest, ClearPreviewWithPasswordAutofilled) {
|
| // Tests that |ClearPreview| properly clears previewed username and password
|
| // with username being previously autofilled.
|
| TEST_F(PasswordAutofillAgentTest, ClearPreviewWithUsernameAutofilled) {
|
| + size_t match_start = 0;
|
| username_element_.setValue(WebString::fromUTF8("ali"));
|
| username_element_.setSelectionRange(3, 3);
|
| username_element_.setAutofilled(true);
|
| @@ -1118,7 +1122,7 @@ TEST_F(PasswordAutofillAgentTest, ClearPreviewWithUsernameAutofilled) {
|
| CheckTextFieldsDOMState("ali", true, std::string(), false);
|
|
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
|
|
| EXPECT_TRUE(
|
| password_autofill_agent_->DidClearAutofillSelection(username_element_));
|
| @@ -1136,6 +1140,7 @@ TEST_F(PasswordAutofillAgentTest, ClearPreviewWithUsernameAutofilled) {
|
| // with username and password being previously autofilled.
|
| TEST_F(PasswordAutofillAgentTest,
|
| ClearPreviewWithAutofilledUsernameAndPassword) {
|
| + size_t match_start = 0;
|
| username_element_.setValue(WebString::fromUTF8("ali"));
|
| username_element_.setSelectionRange(3, 3);
|
| username_element_.setAutofilled(true);
|
| @@ -1150,7 +1155,7 @@ TEST_F(PasswordAutofillAgentTest,
|
| CheckTextFieldsDOMState("ali", true, "sec", true);
|
|
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
|
|
| EXPECT_TRUE(
|
| password_autofill_agent_->DidClearAutofillSelection(username_element_));
|
| @@ -1170,13 +1175,14 @@ TEST_F(PasswordAutofillAgentTest,
|
| ClearPreviewWithNotAutofilledUsernameAndPassword) {
|
| // Simulate the browser sending the login info, but set |wait_for_username|
|
| // to prevent the form from being immediately filled.
|
| + size_t match_start = 0;
|
| fill_data_.wait_for_username = true;
|
| SimulateOnFillPasswordForm(fill_data_);
|
|
|
| CheckTextFieldsDOMState(std::string(), false, std::string(), false);
|
|
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, kAliceUsername, kAlicePassword));
|
| + username_element_, kAliceUsername, kAlicePassword, match_start));
|
|
|
| EXPECT_TRUE(
|
| password_autofill_agent_->DidClearAutofillSelection(username_element_));
|
| @@ -1207,8 +1213,9 @@ TEST_F(PasswordAutofillAgentTest, ClearPreviewWithInlineAutocompletedUsername) {
|
| // The selection should have been set to 'lice', the last 4 letters.
|
| CheckUsernameSelection(1, 5);
|
|
|
| + size_t match_start = 0;
|
| EXPECT_TRUE(password_autofill_agent_->PreviewSuggestion(
|
| - username_element_, "alicia", "secret"));
|
| + username_element_, "alicia", "secret", match_start));
|
| EXPECT_EQ(
|
| "alicia",
|
| static_cast<std::string>(username_element_.suggestedValue().utf8()));
|
|
|