Chromium Code Reviews| 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 106aab9a4f09da8d331198e91d100c7c2352da9b..d21c05961c94e991a40ae99d70a776cff5c7807f 100644 |
| --- a/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| +++ b/chrome/renderer/autofill/password_autofill_agent_browsertest.cc |
| @@ -23,6 +23,7 @@ |
| #include "components/autofill/core/common/password_form.h" |
| #include "components/autofill/core/common/password_form_field_prediction_map.h" |
| #include "components/password_manager/core/common/password_manager_features.h" |
| +#include "components/security_state/core/security_state.h" |
| #include "content/public/common/associated_interface_provider.h" |
| #include "content/public/renderer/render_frame.h" |
| #include "content/public/renderer/render_view.h" |
| @@ -351,6 +352,11 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
| password_manager::features::kFillOnAccountSelect); |
| } |
| + void SetHttpFormWarning() { |
| + scoped_feature_list_.InitAndEnableFeature( |
| + security_state::kHttpFormWarningFeature); |
| + } |
| + |
| void UpdateOriginForHTML(const std::string& html) { |
| std::string origin = "data:text/html;charset=utf-8," + html; |
| fill_data_.origin = GURL(origin); |
| @@ -483,6 +489,11 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest { |
| return fake_driver_.called_show_pw_suggestions(); |
| } |
| + bool GetCalledShowNotSecureWarning() { |
| + base::RunLoop().RunUntilIdle(); |
| + return fake_driver_.called_show_not_secure_warning(); |
| + } |
| + |
| void ExpectFormSubmittedWithUsernameAndPasswords( |
| const std::string& username_value, |
| const std::string& password_value, |
| @@ -1356,6 +1367,18 @@ TEST_F(PasswordAutofillAgentTest, CredentialsOnClick) { |
| ClearUsernameAndPasswordFields(); |
| } |
| +// Tests that the Form Not Secure warning appears when a password form |
| +// is autofilled when the Form Not Secure feature is enabled. |
| +TEST_F(PasswordAutofillAgentTest, FormNotSecureWarningOnAutofill) { |
| + SetHttpFormWarning(); |
|
vabr (Chromium)
2017/01/02 10:15:04
optional: It might be a good idea to also test tha
estark
2017/01/03 16:08:36
Done. Added some additional tests too.
Thanks!
|
| + |
| + fill_data_.show_form_not_secure_warning_on_autofill = true; |
| + |
| + // Simulate the browser autofilling a password form. |
| + SimulateOnFillPasswordForm(fill_data_); |
| + EXPECT_TRUE(GetCalledShowNotSecureWarning()); |
| +} |
| + |
| // Tests that there is an autosuggestion from the password manager when the |
| // user clicks on the password field when FillOnAccountSelect is enabled. |
| TEST_F(PasswordAutofillAgentTest, |