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

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: fix build 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..a9b789a8163e3ae4f041a9e098f5f6ad15db3361 100644
--- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
+++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc
@@ -329,6 +329,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
void TearDown() override {
username_element_.Reset();
password_element_.Reset();
+ dummy_element_.Reset();
ChromeRenderViewTest::TearDown();
}
@@ -377,6 +378,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
element = document.GetElementById(WebString::FromUTF8(kPasswordName));
ASSERT_FALSE(element.IsNull());
password_element_ = element.To<blink::WebInputElement>();
+ dummy_element_ = element.To<blink::WebInputElement>();
}
blink::WebInputElement GetInputElementByID(const std::string& id) {
@@ -391,6 +393,8 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
username_element_.SetAutofilled(false);
password_element_.SetValue("");
password_element_.SetAutofilled(false);
+ dummy_element_.SetValue("");
+ dummy_element_.SetAutofilled(false);
}
void SimulateSuggestionChoice(WebInputElement& username_input) {
@@ -595,6 +599,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {
WebInputElement username_element_;
WebInputElement password_element_;
+ WebInputElement dummy_element_;
Mathieu 2017/05/01 13:40:00 Could you comment why this is needed? I don't see
Jialiu Lin 2017/05/01 18:59:09 Oops, sorry. Forgot to remove this one.
base::test::ScopedFeatureList scoped_feature_list_;
private:
@@ -2712,4 +2717,33 @@ TEST_F(PasswordAutofillAgentTest, InPageNavigationSubmissionUsernameIsEmpty) {
fake_driver_.password_form_inpage_navigation()->password_value);
}
+#if defined(SAFE_BROWSING_DB_LOCAL)
+// Verify CheckSafeBrowsingReputation() is called when user start filling
Mathieu 2017/05/01 13:40:00 *starts
Jialiu Lin 2017/05/01 18:59:09 Done
+// username or password field, and this function is only called once.
Mathieu 2017/05/01 13:40:00 *and that this function
Jialiu Lin 2017/05/01 18:59:09 Done
+TEST_F(PasswordAutofillAgentTest,
+ CheckSafeBrowsingReputationWhenUserStartsFillingUsernamePassword) {
+ ASSERT_EQ(0, fake_driver_.called_check_safe_browsing_reputation_cnt());
+ // Simulate a click on password field to set is on focus,
Mathieu 2017/05/01 13:40:00 *to set its focus
Jialiu Lin 2017/05/01 18:59:09 Done
+ // 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());
+}
+
Mathieu 2017/05/01 13:40:00 nit: remove extra line
Jialiu Lin 2017/05/01 18:59:09 Done.
+#endif
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698