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

Unified Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 2682473002: Show Login Not Secure on username field even without Autocomplete attribute (Closed)
Patch Set: Show Login Not Secure warning only on password and username field Created 3 years, 10 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
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/password_manager_browsertest.cc
diff --git a/chrome/browser/password_manager/password_manager_browsertest.cc b/chrome/browser/password_manager/password_manager_browsertest.cc
index 9d46ce976fcaa797e96a124a2f5d7ad128df2952..795a6a5df6f54d3eb29f850e00197f245c56e093 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -15,6 +15,7 @@
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_notification_types.h"
@@ -1816,6 +1817,57 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
}
IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
+ ShowFormNotSecureOnUsernameField) {
+ password_manager::ContentPasswordManagerDriverFactory* driver_factory =
+ password_manager::ContentPasswordManagerDriverFactory::FromWebContents(
+ WebContents());
+ ObservingAutofillClient::CreateForWebContents(WebContents());
+ ObservingAutofillClient* observing_autofill_client =
+ ObservingAutofillClient::FromWebContents(WebContents());
+ password_manager::ContentPasswordManagerDriver* driver =
+ driver_factory->GetDriverForFrame(RenderViewHost()->GetMainFrame());
+ DCHECK(driver);
+ driver->GetPasswordAutofillManager()->set_autofill_client(
+ observing_autofill_client);
+
+ // We need to serve from a non-localhost context for the form to be treated as
+ // Not Secure.
+ host_resolver()->AddRule("example.com", "127.0.0.1");
+ NavigationObserver observer(WebContents());
+ ui_test_utils::NavigateToURL(
+ browser(), embedded_test_server()->GetURL(
+ "example.com", "/password/password_form.html"));
+ observer.Wait();
+
+ ASSERT_TRUE(content::ExecuteScript(
+ RenderViewHost(),
+ "var inputRect = document.getElementById('username_field_no_name')"
+ ".getBoundingClientRect();"));
+
+ // Click on the username field to verify the warning is shown.
+ int top;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
+ RenderViewHost(), "window.domAutomationController.send(inputRect.top);",
+ &top));
+ int left;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractInt(
+ RenderViewHost(), "window.domAutomationController.send(inputRect.left);",
+ &left));
+
+ const char kHistogram[] =
+ "PasswordManager.ShowedFormNotSecureWarningOnCurrentNavigation";
+ base::HistogramTester histograms;
+
+ content::SimulateMouseClickAt(WebContents(), 0,
+ blink::WebMouseEvent::Button::Left,
+ gfx::Point(left + 1, top + 1));
+ // Ensure the warning would be shown.
+ observing_autofill_client->Wait();
+ // Ensure the histogram was updated.
+ histograms.ExpectUniqueSample(kHistogram, true, 1);
+}
sebsg 2017/02/13 18:53:55 Can you add a test for when a user clicks on anoth
+
+IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
ChangePwdFormBubbleShown) {
NavigateToFile("/password/password_form.html");
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698