| 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..c598b756574250296bb308620d008aedeaab3fe4 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,30 @@ 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();
|
| +
|
| + 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 the Form Not Secure warning does not appear when the
|
| +// PasswordFormFillData does not indicate that it should show.
|
| +TEST_F(PasswordAutofillAgentTest, FormNotSecureWarningNotShownOnAutofill) {
|
| + SetHttpFormWarning();
|
| +
|
| + fill_data_.show_form_not_secure_warning_on_autofill = false;
|
| +
|
| + // Simulate the browser autofilling a password form.
|
| + SimulateOnFillPasswordForm(fill_data_);
|
| + EXPECT_FALSE(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,
|
|
|