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

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

Issue 2035143002: Basic implementation of showing password fill dialog on page load (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix iOS compile Created 4 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 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 02eef49a6eb142f44553ef85359279a3e24672b5..d4ffec2db103a011d602e10d4cb37b7964b7d72d 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -4,6 +4,7 @@
#include <tuple>
+#include "base/command_line.h"
#include "base/macros.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -253,6 +254,17 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
content::RenderFrame::FromWebFrame(frame)->OnMessageReceived(msg);
}
+ // Simulates the show initial password account suggestions message being sent
+ // to the renderer. We use that so we don't have to make
+ // RenderView::OnShowInitialPasswordAccountSuggestions() protected.
+ void SimulateOnShowInitialPasswordAccountSuggestions(
+ const PasswordFormFillData& fill_data) {
+ AutofillMsg_ShowInitialPasswordAccountSuggestions msg(
+ 0, kPasswordFillFormDataId, fill_data);
+ static_cast<content::RenderFrameObserver*>(autofill_agent_)
+ ->OnMessageReceived(msg);
+ }
+
void SendVisiblePasswordForms() {
static_cast<content::RenderFrameObserver*>(password_autofill_agent_)
->DidFinishLoad();
@@ -1282,7 +1294,7 @@ TEST_F(PasswordAutofillAgentTest,
autofill::switches::kEnableFillOnAccountSelect);
// Simulate the browser sending back the login info.
- SimulateOnFillPasswordForm(fill_data_);
+ SimulateOnShowInitialPasswordAccountSuggestions(fill_data_);
// Clear the text fields to start fresh.
ClearUsernameAndPasswordFields();
@@ -1312,7 +1324,7 @@ TEST_F(PasswordAutofillAgentTest,
autofill::switches::kEnableFillOnAccountSelect);
// Simulate the browser sending back the login info.
- SimulateOnFillPasswordForm(fill_data_);
+ SimulateOnShowInitialPasswordAccountSuggestions(fill_data_);
// Clear the text fields to start fresh.
ClearUsernameAndPasswordFields();
@@ -1564,9 +1576,10 @@ TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnly) {
ClearUsernameAndPasswordFields();
// Simulate the browser sending back the login info for an initial page load.
- SimulateOnFillPasswordForm(fill_data_);
+ SimulateOnShowInitialPasswordAccountSuggestions(fill_data_);
- CheckTextFieldsState(std::string(), true, std::string(), false);
+ CheckTextFieldsState(std::string(), false, std::string(), false);
+ CheckSuggestions(std::string(), true);
}
TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyReadonlyUsername) {
@@ -1579,9 +1592,9 @@ TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyReadonlyUsername) {
SetElementReadOnly(username_element_, true);
// Simulate the browser sending back the login info for an initial page load.
- SimulateOnFillPasswordForm(fill_data_);
+ SimulateOnShowInitialPasswordAccountSuggestions(fill_data_);
- CheckTextFieldsState(std::string("alice"), false, std::string(), true);
+ CheckTextFieldsState(std::string("alice"), false, std::string(), false);
}
TEST_F(PasswordAutofillAgentTest,
@@ -1595,9 +1608,9 @@ TEST_F(PasswordAutofillAgentTest,
SetElementReadOnly(username_element_, true);
// Simulate the browser sending back the login info for an initial page load.
- SimulateOnFillPasswordForm(fill_data_);
+ SimulateOnShowInitialPasswordAccountSuggestions(fill_data_);
- CheckTextFieldsState(std::string("Carol"), false, std::string(), true);
+ CheckTextFieldsState(std::string("Carol"), false, std::string(), false);
}
TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyNoUsername) {
@@ -1621,10 +1634,11 @@ TEST_F(PasswordAutofillAgentTest, FillOnAccountSelectOnlyNoUsername) {
password_element_.setAutofilled(false);
// Simulate the browser sending back the login info for an initial page load.
- SimulateOnFillPasswordForm(fill_data_);
+ SimulateOnShowInitialPasswordAccountSuggestions(fill_data_);
EXPECT_TRUE(password_element_.suggestedValue().isEmpty());
- EXPECT_TRUE(password_element_.isAutofilled());
+ EXPECT_FALSE(password_element_.isAutofilled());
+ CheckSuggestions(std::string(), false);
}
TEST_F(PasswordAutofillAgentTest, ShowPopupOnEmptyPasswordField) {
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | components/autofill/content/common/autofill_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698