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

Unified Diff: components/password_manager/core/browser/password_autofill_manager_unittest.cc

Issue 2604453003: Show Form-Not-Secure warning on page load (Closed)
Patch Set: meacer, jochen comments Created 3 years, 12 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: components/password_manager/core/browser/password_autofill_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_autofill_manager_unittest.cc b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
index 8ffb5817044653abd15d686d45bda99fc07fe64a..b6d94f2b4654107022c5c639f216da98ed5227f4 100644
--- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
@@ -587,6 +587,47 @@ TEST_F(PasswordAutofillManagerTest, PreviewAndFillEmptyUsernameSuggestion) {
testing::Mock::VerifyAndClearExpectations(client->mock_driver());
}
+// Tests that a standalone Form Not Secure warning shows up in the
+// autofill popup when PasswordAutofillManager::OnShowNotSecureWarning()
+// is called.
+TEST_F(PasswordAutofillManagerTest, ShowStandaloneNotSecureWarning) {
+ auto client = base::MakeUnique<TestPasswordManagerClient>();
+ auto autofill_client = base::MakeUnique<MockAutofillClient>();
+ InitializePasswordAutofillManager(client.get(), autofill_client.get());
+
+ gfx::RectF element_bounds;
+ autofill::PasswordFormFillData data;
+ data.username_field.value = test_username_;
+ data.password_field.value = test_password_;
+ data.origin = GURL("http://foo.test");
+
+ int dummy_key = 0;
+ password_autofill_manager_->OnAddPasswordFormMapping(dummy_key, data);
+
+ // String "Login not secure" shown as a warning messages if password form is
+ // on http sites.
+ const base::string16 warning_message =
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_LOGIN_HTTP_WARNING_MESSAGE);
+
+ SetHttpWarningEnabled();
+
+ auto elements = testing::ElementsAre(warning_message);
+
+ EXPECT_CALL(*autofill_client,
+ ShowAutofillPopup(element_bounds, _,
+ SuggestionVectorValuesAre(elements), _));
+ password_autofill_manager_->OnShowNotSecureWarning(base::i18n::RIGHT_TO_LEFT,
+ element_bounds);
+
+ // Accepting the warning message should trigger a call to open the url and
+ // hide the popup.
+ EXPECT_CALL(*autofill_client, ShowHttpNotSecureExplanation());
+ EXPECT_CALL(*autofill_client, HideAutofillPopup());
+ password_autofill_manager_->DidAcceptSuggestion(
+ base::string16(), autofill::POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE,
+ 0);
+}
+
TEST_F(PasswordAutofillManagerTest, NonSecurePasswordFieldHttpWarningMessage) {
auto client = base::MakeUnique<TestPasswordManagerClient>();
auto autofill_client = base::MakeUnique<MockAutofillClient>();

Powered by Google App Engine
This is Rietveld 408576698