| 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_;
|
| 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
|
| +// username or password field, and 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 is 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
|
|
|