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

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

Issue 492043003: Fill on account select in the password manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit tests Created 6 years, 1 month 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 bec975b9156f5ac7d7fe1efed8757a6954ce7b8d..91b234bf44dfc284b09c2a28e616baaa25f2d046 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -10,6 +10,8 @@
#include "components/autofill/content/renderer/form_autofill_util.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
#include "components/autofill/content/renderer/test_password_autofill_agent.h"
+#include "components/autofill/core/common/autofill_constants.h"
+#include "components/autofill/core/common/autofill_switches.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -396,12 +398,13 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_ShowPasswordSuggestions::ID);
EXPECT_TRUE(message);
- Tuple5<int, base::i18n::TextDirection, base::string16, bool, gfx::RectF>
+ Tuple5<int, base::i18n::TextDirection, base::string16, int, gfx::RectF>
args;
AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args);
EXPECT_EQ(kPasswordFillFormDataId, args.a);
EXPECT_EQ(ASCIIToUTF16(username), args.c);
- EXPECT_EQ(show_all, args.d);
+ EXPECT_EQ(show_all,
+ args.d & autofill::ShowPasswordSuggestionsOptions::SHOW_ALL);
render_thread_->sink().ClearMessages();
}
@@ -1519,4 +1522,42 @@ TEST_F(PasswordAutofillAgentTest,
CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true);
}
+TEST_F(PasswordAutofillAgentTest, FormFillDataMustHaveUsername) {
+ ClearUsernameAndPasswordFields();
+
+ PasswordFormFillData no_username_fill_data = fill_data_;
+ no_username_fill_data.username_field.name = base::string16();
+ SimulateOnFillPasswordForm(no_username_fill_data);
+
+ // The username and password should not have been autocompleted.
+ CheckTextFieldsState("", false, "", false);
+}
+
+TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnly) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ autofill::switches::kEnableFillOnAccountSelect);
+
+ ClearUsernameAndPasswordFields();
+
+ // Simulate the browser sending back the login info for an initial page load.
+ SimulateOnFillPasswordForm(fill_data_);
+
+ CheckTextFieldsState(std::string(), true, std::string(), false);
+}
+
+TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyReadonlyUsername) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ autofill::switches::kEnableFillOnAccountSelect);
+
+ ClearUsernameAndPasswordFields();
+
+ username_element_.setValue("alicia");
+ SetElementReadOnly(username_element_, true);
+
+ // Simulate the browser sending back the login info for an initial page load.
+ SimulateOnFillPasswordForm(fill_data_);
+
+ CheckTextFieldsState(std::string("alicia"), false, std::string(), true);
+}
+
} // namespace autofill
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_controller_impl.cc ('k') | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698