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

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

Issue 688633004: Do not haul suggestions back to browser in AutofillHostMsg_ShowPasswordSuggestions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments removed, iterator renamed Created 6 years, 2 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
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 451b1fc527b3e895a4cef0737486c77e0e63387e..4e60b376d57f025ed61b392f32d3b47c43627e3f 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -417,47 +417,22 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
EXPECT_EQ(end, username_element_.selectionEnd());
}
- void ExpectOneCredential(const base::string16& username) {
+ // Checks the message sent to PasswordAutofillManager to build the suggestion
+ // list. |username| is the expected username field value, and |show_all| is
+ // the expected flag for the PasswordAutofillManager, whether to show all
+ // suggestions, or only those starting with |username|.
+ void CheckSuggestions(const std::string& username, bool show_all) {
const IPC::Message* message =
render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_ShowPasswordSuggestions::ID);
- ASSERT_TRUE(message);
- Tuple4<autofill::FormFieldData,
- gfx::RectF,
- std::vector<base::string16>,
- std::vector<base::string16> > args;
+ EXPECT_TRUE(message);
+ Tuple4<autofill::FormFieldData, base::string16, bool, gfx::RectF> args;
AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args);
- ASSERT_EQ(1u, args.c.size());
- EXPECT_TRUE(args.c[0] == username);
- }
-
- void ExpectAllCredentials() {
- std::set<base::string16> usernames;
- usernames.insert(username1_);
- usernames.insert(username2_);
- usernames.insert(username3_);
- usernames.insert(alternate_username3_);
-
- const IPC::Message* message =
- render_thread_->sink().GetFirstMessageMatching(
- AutofillHostMsg_ShowPasswordSuggestions::ID);
- ASSERT_TRUE(message);
- Tuple4<autofill::FormFieldData,
- gfx::RectF,
- std::vector<base::string16>,
- std::vector<base::string16> > args;
- AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args);
- ASSERT_EQ(4u, args.c.size());
- std::set<base::string16>::iterator it;
-
- for (int i = 0; i < 4; i++) {
- it = usernames.find(args.c[i]);
- EXPECT_TRUE(it != usernames.end());
- if (it != usernames.end())
- usernames.erase(it);
- }
-
- EXPECT_TRUE(usernames.empty());
+ EXPECT_EQ(2u, fill_data_.basic_data.fields.size());
+ EXPECT_EQ(fill_data_.basic_data.fields[0].name, args.a.name);
+ EXPECT_EQ(ASCIIToUTF16(username), args.a.value);
+ EXPECT_EQ(ASCIIToUTF16(username), args.b);
+ EXPECT_EQ(show_all, args.c);
render_thread_->sink().ClearMessages();
}
@@ -1455,7 +1430,7 @@ TEST_F(PasswordAutofillAgentTest, ClickAndSelect) {
SimulateOnFillPasswordForm(fill_data_);
SimulateElementClick(kUsernameName);
SimulateSuggestionChoice(username_element_);
- ExpectAllCredentials();
+ CheckSuggestions(kAliceUsername, true);
CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true);
}
@@ -1481,7 +1456,7 @@ TEST_F(PasswordAutofillAgentTest, CredentialsOnClick) {
render_thread_->sink().ClearMessages();
static_cast<PageClickListener*>(autofill_agent_)
->FormControlElementClicked(username_element_, false);
- ExpectAllCredentials();
+ CheckSuggestions(std::string(), false);
// Now simulate a user typing in an unrecognized username and then
// clicking on the username element. This should also produce a message with
@@ -1490,7 +1465,7 @@ TEST_F(PasswordAutofillAgentTest, CredentialsOnClick) {
render_thread_->sink().ClearMessages();
static_cast<PageClickListener*>(autofill_agent_)
->FormControlElementClicked(username_element_, true);
- ExpectAllCredentials();
+ CheckSuggestions("baz", true);
// Now simulate a user typing in the first letter of the username and then
// clicking on the username element. While the typing of the first letter will
@@ -1500,7 +1475,7 @@ TEST_F(PasswordAutofillAgentTest, CredentialsOnClick) {
render_thread_->sink().ClearMessages();
static_cast<PageClickListener*>(autofill_agent_)
->FormControlElementClicked(username_element_, true);
- ExpectAllCredentials();
+ CheckSuggestions(kAliceUsername, true);
}
// The user types in a password, but then just before sending the form off, a

Powered by Google App Engine
This is Rietveld 408576698