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

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

Issue 488083002: [Password Manager] Fix to recognise failed login attempt for sites where content server pushes new … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@branch_autofill_todo_20140813
Patch Set: Incorporatd review comments and added unit-tests Created 6 years, 4 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: 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 ff2fdce0752d755b429a627bf7849d5eefca5d20..cdb908d8d441de275b5de5912f595f3a81a75ca2 100644
--- a/chrome/browser/password_manager/password_manager_browsertest.cc
+++ b/chrome/browser/password_manager/password_manager_browsertest.cc
@@ -21,11 +21,13 @@
#include "chrome/browser/ui/login/login_prompt_test_utils.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
+#include "components/content_settings/core/common/content_settings_types.h"
vabr (Chromium) 2014/08/26 09:42:58 What do you need this header for? (If you don't, p
Pritam Nikam 2014/08/26 12:41:32 Done.
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_manager.h"
@@ -37,11 +39,13 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
+#include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
@@ -1119,3 +1123,62 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
EXPECT_TRUE(prompt_observer->IsShowingPrompt());
}
+// Test that if login fails and content server pushes a different login form
+// with action URL having different schemes. Heuristic shall be able
+// identify such cases and *shall not* prompt to save incorrect password.
+IN_PROC_BROWSER_TEST_F(
+ PasswordManagerBrowserTest,
+ NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) {
+ std::string path = "/password/separate_login_form.html";
+ GURL http_url(embedded_test_server()->GetURL(path));
+ ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme));
+ ui_test_utils::NavigateToURL(browser(), http_url);
+
+ NavigationObserver observer(WebContents());
+ scoped_ptr<PromptObserver> prompt_observer(
+ PromptObserver::Create(WebContents()));
+ std::string submit =
+ "document.getElementById('username_separate').value = 'user';"
+ "document.getElementById('password_separate').value = 'password';"
+ "document.getElementById('submit_separate').click();";
+ ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
+ observer.Wait();
+
+ EXPECT_FALSE(prompt_observer->IsShowingPrompt());
+}
+
+IN_PROC_BROWSER_TEST_F(
+ PasswordManagerBrowserTest,
+ NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAllowRunningInsecureContent);
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kIgnoreCertificateErrors);
+ const base::FilePath::CharType kDocRoot[] =
+ FILE_PATH_LITERAL("chrome/test/data");
+ net::SpawnedTestServer https_test_server(
+ net::SpawnedTestServer::TYPE_HTTPS,
+ net::SpawnedTestServer::SSLOptions(
+ net::SpawnedTestServer::SSLOptions::CERT_OK),
+ base::FilePath(kDocRoot));
+ ASSERT_TRUE(https_test_server.Start());
+
+ std::string path =
+ "password/separate_login_form_with_onload_submit_script.html";
vabr (Chromium) 2014/08/26 09:42:58 Why do you need the onload submit script here? Cou
Pritam Nikam 2014/08/26 12:41:33 std::string submit = "document.getElementById(
+ GURL https_url(https_test_server.GetURL(path));
+ ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme));
+
+ NavigationObserver observer(WebContents());
+ scoped_ptr<PromptObserver> prompt_observer(
+ PromptObserver::Create(WebContents()));
+ ui_test_utils::NavigateToURL(browser(), https_url);
+
+ // Waits for navigation complete.
+ observer.Wait();
+
+ // Waits for form submission by onload javascript.
+ observer.Wait();
vabr (Chromium) 2014/08/26 09:42:58 I'm afraid this will be a source of flakiness. Sup
Pritam Nikam 2014/08/26 12:41:33 As explained in previous comments, content::Execut
+
+ // Verify that browser doest not prompt save password popup.
vabr (Chromium) 2014/08/26 09:42:58 nit: You can drop this comment, the code below is
Pritam Nikam 2014/08/26 12:41:33 Done.
+ EXPECT_FALSE(prompt_observer->IsShowingPrompt());
+}

Powered by Google App Engine
This is Rietveld 408576698