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

Side by Side 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, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/password_autofill_agent.h" 5 #include "components/autofill/content/renderer/password_autofill_agent.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 2694 matching lines...) Expand 10 before | Expand all | Expand 10 after
2705 base::RunLoop().RunUntilIdle(); 2705 base::RunLoop().RunUntilIdle();
2706 2706
2707 // Chect that the form was submitted with in-page navigation. 2707 // Chect that the form was submitted with in-page navigation.
2708 EXPECT_TRUE(fake_driver_.called_inpage_navigation()); 2708 EXPECT_TRUE(fake_driver_.called_inpage_navigation());
2709 EXPECT_EQ(base::string16(), 2709 EXPECT_EQ(base::string16(),
2710 fake_driver_.password_form_inpage_navigation()->username_value); 2710 fake_driver_.password_form_inpage_navigation()->username_value);
2711 EXPECT_EQ(ASCIIToUTF16("random"), 2711 EXPECT_EQ(ASCIIToUTF16("random"),
2712 fake_driver_.password_form_inpage_navigation()->password_value); 2712 fake_driver_.password_form_inpage_navigation()->password_value);
2713 } 2713 }
2714 2714
2715 #if defined(SAFE_BROWSING_DB_LOCAL)
2716 // Verify CheckSafeBrowsingReputation() is called when user starts filling
2717 // username or password field, and that this function is only called once.
2718 TEST_F(PasswordAutofillAgentTest,
2719 CheckSafeBrowsingReputationWhenUserStartsFillingUsernamePassword) {
2720 ASSERT_EQ(0, fake_driver_.called_check_safe_browsing_reputation_cnt());
2721 // Simulate a click on password field to set its on focus,
2722 // CheckSafeBrowsingReputation() should be called.
2723 SimulateElementClick(kPasswordName);
2724 base::RunLoop().RunUntilIdle();
2725 EXPECT_EQ(1, fake_driver_.called_check_safe_browsing_reputation_cnt());
2726
2727 // Subsequent editing will not trigger CheckSafeBrowsingReputation.
2728 SimulatePasswordChange("modify");
2729 base::RunLoop().RunUntilIdle();
2730 EXPECT_EQ(1, fake_driver_.called_check_safe_browsing_reputation_cnt());
2731 SimulateElementClick(kUsernameName);
2732 base::RunLoop().RunUntilIdle();
2733 EXPECT_EQ(1, fake_driver_.called_check_safe_browsing_reputation_cnt());
2734
2735 // Navigate to another page and click on username field,
2736 // CheckSafeBrowsingReputation() should be triggered again.
2737 LoadHTML(kFormHTML);
2738 SimulateElementClick(kUsernameName);
2739 base::RunLoop().RunUntilIdle();
2740 EXPECT_EQ(2, fake_driver_.called_check_safe_browsing_reputation_cnt());
2741 }
2742 #endif
2715 } // namespace autofill 2743 } // namespace autofill
OLDNEW
« 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