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

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

Issue 2833193002: Trigger Password Protection ping on username/password field on focus (Closed)
Patch Set: nit Created 3 years, 8 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 4b618b0be2427062996015f68d2dca5737469b68..5b666d88c1c0ffd379b2faccb970fe43e51e4fec 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -2712,4 +2712,32 @@ TEST_F(PasswordAutofillAgentTest, InPageNavigationSubmissionUsernameIsEmpty) {
fake_driver_.password_form_inpage_navigation()->password_value);
}
+#if defined(SAFE_BROWSING_DB_LOCAL)
+// Verify CheckSafeBrowsingReputation() is called when user starts filling
+// username or password field, and that this function is only called once.
+TEST_F(PasswordAutofillAgentTest,
+ CheckSafeBrowsingReputationWhenUserStartsFillingUsernamePassword) {
+ ASSERT_EQ(0, fake_driver_.called_check_safe_browsing_reputation_cnt());
+ // Simulate a click on password field to set its on focus,
+ // CheckSafeBrowsingReputation() should be called.
+ SimulateElementClick(kPasswordName);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(1, fake_driver_.called_check_safe_browsing_reputation_cnt());
+
+ // Subsequent editing will not trigger CheckSafeBrowsingReputation.
+ SimulatePasswordChange("modify");
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(1, fake_driver_.called_check_safe_browsing_reputation_cnt());
+ SimulateElementClick(kUsernameName);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(1, fake_driver_.called_check_safe_browsing_reputation_cnt());
+
+ // Navigate to another page and click on username field,
+ // CheckSafeBrowsingReputation() should be triggered again.
+ LoadHTML(kFormHTML);
+ SimulateElementClick(kUsernameName);
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(2, fake_driver_.called_check_safe_browsing_reputation_cnt());
+}
+#endif
} // namespace autofill
« no previous file with comments | « chrome/renderer/autofill/fake_content_password_manager_driver.cc ('k') | components/autofill/content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698