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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/infobars/infobar_service.h" 15 #include "chrome/browser/infobars/infobar_service.h"
16 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 16 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
17 #include "chrome/browser/password_manager/password_store_factory.h" 17 #include "chrome/browser/password_manager/password_store_factory.h"
18 #include "chrome/browser/password_manager/test_password_store_service.h" 18 #include "chrome/browser/password_manager/test_password_store_service.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/login/login_prompt.h" 20 #include "chrome/browser/ui/login/login_prompt.h"
21 #include "chrome/browser/ui/login/login_prompt_test_utils.h" 21 #include "chrome/browser/ui/login/login_prompt_test_utils.h"
22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/chrome_version_info.h" 25 #include "chrome/common/chrome_version_info.h"
25 #include "chrome/test/base/in_process_browser_test.h" 26 #include "chrome/test/base/in_process_browser_test.h"
26 #include "chrome/test/base/test_switches.h" 27 #include "chrome/test/base/test_switches.h"
27 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
28 #include "components/autofill/core/browser/autofill_test_utils.h" 29 #include "components/autofill/core/browser/autofill_test_utils.h"
30 #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.
29 #include "components/infobars/core/confirm_infobar_delegate.h" 31 #include "components/infobars/core/confirm_infobar_delegate.h"
30 #include "components/infobars/core/infobar.h" 32 #include "components/infobars/core/infobar.h"
31 #include "components/infobars/core/infobar_manager.h" 33 #include "components/infobars/core/infobar_manager.h"
32 #include "components/password_manager/core/browser/test_password_store.h" 34 #include "components/password_manager/core/browser/test_password_store.h"
33 #include "components/password_manager/core/common/password_manager_switches.h" 35 #include "components/password_manager/core/common/password_manager_switches.h"
34 #include "content/public/browser/navigation_controller.h" 36 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/render_frame_host.h" 38 #include "content/public/browser/render_frame_host.h"
37 #include "content/public/browser/render_view_host.h" 39 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/web_contents.h" 40 #include "content/public/browser/web_contents.h"
39 #include "content/public/browser/web_contents_observer.h" 41 #include "content/public/browser/web_contents_observer.h"
42 #include "content/public/common/content_switches.h"
40 #include "content/public/test/browser_test_utils.h" 43 #include "content/public/test/browser_test_utils.h"
41 #include "content/public/test/test_utils.h" 44 #include "content/public/test/test_utils.h"
42 #include "net/test/embedded_test_server/embedded_test_server.h" 45 #include "net/test/embedded_test_server/embedded_test_server.h"
43 #include "net/test/embedded_test_server/http_request.h" 46 #include "net/test/embedded_test_server/http_request.h"
44 #include "net/test/embedded_test_server/http_response.h" 47 #include "net/test/embedded_test_server/http_response.h"
48 #include "net/test/spawned_test_server/spawned_test_server.h"
45 #include "net/url_request/test_url_fetcher_factory.h" 49 #include "net/url_request/test_url_fetcher_factory.h"
46 #include "testing/gmock/include/gmock/gmock.h" 50 #include "testing/gmock/include/gmock/gmock.h"
47 #include "third_party/WebKit/public/web/WebInputEvent.h" 51 #include "third_party/WebKit/public/web/WebInputEvent.h"
48 #include "ui/events/keycodes/keyboard_codes.h" 52 #include "ui/events/keycodes/keyboard_codes.h"
49 #include "ui/gfx/geometry/point.h" 53 #include "ui/gfx/geometry/point.h"
50 54
51 55
52 // NavigationObserver --------------------------------------------------------- 56 // NavigationObserver ---------------------------------------------------------
53 57
54 namespace { 58 namespace {
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 std::string submit = 1116 std::string submit =
1113 "document.getElementById('username').value = 'overwrite_me';" 1117 "document.getElementById('username').value = 'overwrite_me';"
1114 "document.getElementById('password').value = 'random';" 1118 "document.getElementById('password').value = 'random';"
1115 "document.getElementById('non-form-button').click();"; 1119 "document.getElementById('non-form-button').click();";
1116 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); 1120 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1117 observer.Wait(); 1121 observer.Wait();
1118 1122
1119 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1123 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1120 } 1124 }
1121 1125
1126 // Test that if login fails and content server pushes a different login form
1127 // with action URL having different schemes. Heuristic shall be able
1128 // identify such cases and *shall not* prompt to save incorrect password.
1129 IN_PROC_BROWSER_TEST_F(
1130 PasswordManagerBrowserTest,
1131 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) {
1132 std::string path = "/password/separate_login_form.html";
1133 GURL http_url(embedded_test_server()->GetURL(path));
1134 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme));
1135 ui_test_utils::NavigateToURL(browser(), http_url);
1136
1137 NavigationObserver observer(WebContents());
1138 scoped_ptr<PromptObserver> prompt_observer(
1139 PromptObserver::Create(WebContents()));
1140 std::string submit =
1141 "document.getElementById('username_separate').value = 'user';"
1142 "document.getElementById('password_separate').value = 'password';"
1143 "document.getElementById('submit_separate').click();";
1144 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1145 observer.Wait();
1146
1147 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
1148 }
1149
1150 IN_PROC_BROWSER_TEST_F(
1151 PasswordManagerBrowserTest,
1152 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) {
1153 CommandLine::ForCurrentProcess()->AppendSwitch(
1154 switches::kAllowRunningInsecureContent);
1155 CommandLine::ForCurrentProcess()->AppendSwitch(
1156 switches::kIgnoreCertificateErrors);
1157 const base::FilePath::CharType kDocRoot[] =
1158 FILE_PATH_LITERAL("chrome/test/data");
1159 net::SpawnedTestServer https_test_server(
1160 net::SpawnedTestServer::TYPE_HTTPS,
1161 net::SpawnedTestServer::SSLOptions(
1162 net::SpawnedTestServer::SSLOptions::CERT_OK),
1163 base::FilePath(kDocRoot));
1164 ASSERT_TRUE(https_test_server.Start());
1165
1166 std::string path =
1167 "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(
1168 GURL https_url(https_test_server.GetURL(path));
1169 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme));
1170
1171 NavigationObserver observer(WebContents());
1172 scoped_ptr<PromptObserver> prompt_observer(
1173 PromptObserver::Create(WebContents()));
1174 ui_test_utils::NavigateToURL(browser(), https_url);
1175
1176 // Waits for navigation complete.
1177 observer.Wait();
1178
1179 // Waits for form submission by onload javascript.
1180 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
1181
1182 // 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.
1183 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
1184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698