OLD | NEW |
---|---|
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" |
29 #include "components/infobars/core/confirm_infobar_delegate.h" | 30 #include "components/infobars/core/confirm_infobar_delegate.h" |
30 #include "components/infobars/core/infobar.h" | 31 #include "components/infobars/core/infobar.h" |
31 #include "components/infobars/core/infobar_manager.h" | 32 #include "components/infobars/core/infobar_manager.h" |
32 #include "components/password_manager/core/browser/test_password_store.h" | 33 #include "components/password_manager/core/browser/test_password_store.h" |
33 #include "components/password_manager/core/common/password_manager_switches.h" | 34 #include "components/password_manager/core/common/password_manager_switches.h" |
34 #include "content/public/browser/navigation_controller.h" | 35 #include "content/public/browser/navigation_controller.h" |
35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/render_frame_host.h" | 37 #include "content/public/browser/render_frame_host.h" |
37 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
38 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
39 #include "content/public/browser/web_contents_observer.h" | 40 #include "content/public/browser/web_contents_observer.h" |
41 #include "content/public/common/content_switches.h" | |
40 #include "content/public/test/browser_test_utils.h" | 42 #include "content/public/test/browser_test_utils.h" |
41 #include "content/public/test/test_utils.h" | 43 #include "content/public/test/test_utils.h" |
42 #include "net/test/embedded_test_server/embedded_test_server.h" | 44 #include "net/test/embedded_test_server/embedded_test_server.h" |
43 #include "net/test/embedded_test_server/http_request.h" | 45 #include "net/test/embedded_test_server/http_request.h" |
44 #include "net/test/embedded_test_server/http_response.h" | 46 #include "net/test/embedded_test_server/http_response.h" |
47 #include "net/test/spawned_test_server/spawned_test_server.h" | |
45 #include "net/url_request/test_url_fetcher_factory.h" | 48 #include "net/url_request/test_url_fetcher_factory.h" |
46 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
47 #include "third_party/WebKit/public/web/WebInputEvent.h" | 50 #include "third_party/WebKit/public/web/WebInputEvent.h" |
48 #include "ui/events/keycodes/keyboard_codes.h" | 51 #include "ui/events/keycodes/keyboard_codes.h" |
49 #include "ui/gfx/geometry/point.h" | 52 #include "ui/gfx/geometry/point.h" |
50 | 53 |
51 | 54 |
52 // NavigationObserver --------------------------------------------------------- | 55 // NavigationObserver --------------------------------------------------------- |
53 | 56 |
54 namespace { | 57 namespace { |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1112 std::string submit = | 1115 std::string submit = |
1113 "document.getElementById('username').value = 'overwrite_me';" | 1116 "document.getElementById('username').value = 'overwrite_me';" |
1114 "document.getElementById('password').value = 'random';" | 1117 "document.getElementById('password').value = 'random';" |
1115 "document.getElementById('non-form-button').click();"; | 1118 "document.getElementById('non-form-button').click();"; |
1116 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1119 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
1117 observer.Wait(); | 1120 observer.Wait(); |
1118 | 1121 |
1119 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1122 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
1120 } | 1123 } |
1121 | 1124 |
1125 // Test that if login fails and content server pushes a different login form | |
1126 // with action URL having different schemes. Heuristic shall be able | |
1127 // identify such cases and *shall not* prompt to save incorrect password. | |
1128 IN_PROC_BROWSER_TEST_F( | |
1129 PasswordManagerBrowserTest, | |
1130 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) { | |
1131 std::string path = | |
1132 "/password/separate_login_form_with_onload_submit_script.html"; | |
1133 GURL http_url(embedded_test_server()->GetURL(path)); | |
1134 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | |
1135 | |
1136 NavigationObserver observer(WebContents()); | |
1137 scoped_ptr<PromptObserver> prompt_observer( | |
1138 PromptObserver::Create(WebContents())); | |
1139 ui_test_utils::NavigateToURL(browser(), http_url); | |
1140 | |
1141 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | |
1142 observer.Wait(); | |
1143 | |
1144 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | |
1145 } | |
1146 | |
1147 IN_PROC_BROWSER_TEST_F( | |
1148 PasswordManagerBrowserTest, | |
1149 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) { | |
1150 CommandLine::ForCurrentProcess()->AppendSwitch( | |
1151 switches::kAllowRunningInsecureContent); | |
1152 CommandLine::ForCurrentProcess()->AppendSwitch( | |
1153 switches::kIgnoreCertificateErrors); | |
1154 const base::FilePath::CharType kDocRoot[] = | |
1155 FILE_PATH_LITERAL("chrome/test/data"); | |
1156 net::SpawnedTestServer https_test_server( | |
1157 net::SpawnedTestServer::TYPE_HTTPS, | |
1158 net::SpawnedTestServer::SSLOptions( | |
1159 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
1160 base::FilePath(kDocRoot)); | |
1161 ASSERT_TRUE(https_test_server.Start()); | |
1162 | |
1163 // This testcase is having provision to submit form on page load completion. | |
vabr (Chromium)
2014/09/01 08:39:39
optional nit: This comment sounds a little weird t
Pritam Nikam
2014/09/01 10:53:54
Done.
| |
1164 // It has been added to overcome the problem as for HTTPS test servers | |
1165 // content::ExecuteScript() API is failing to inject script on the fly. | |
1166 std::string path = | |
1167 "password/separate_login_form_with_onload_submit_script.html"; | |
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 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | |
1177 observer.Wait(); | |
1178 | |
1179 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | |
1180 } | |
OLD | NEW |