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 "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 NavigationObserver observer(WebContents()); | 203 NavigationObserver observer(WebContents()); |
204 std::string fill_and_submit = | 204 std::string fill_and_submit = |
205 "document.getElementById('username_field').value = 'temp';" | 205 "document.getElementById('username_field').value = 'temp';" |
206 "document.getElementById('password_field').value = 'random';" | 206 "document.getElementById('password_field').value = 'random';" |
207 "document.getElementById('input_submit_button').click()"; | 207 "document.getElementById('input_submit_button').click()"; |
208 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 208 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
209 observer.Wait(); | 209 observer.Wait(); |
210 EXPECT_TRUE(observer.infobar_shown()); | 210 EXPECT_TRUE(observer.infobar_shown()); |
211 } | 211 } |
212 | 212 |
| 213 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
| 214 LoginSuccessWithUnrelatedForm) { |
| 215 // Log in, see a form on the landing page. That form is not related to the |
| 216 // login form (=has a different action), so we should offer saving the |
| 217 // password. |
| 218 NavigateToFile("/password/password_form.html"); |
| 219 |
| 220 NavigationObserver observer(WebContents()); |
| 221 std::string fill_and_submit = |
| 222 "document.getElementById('username_unrelated').value = 'temp';" |
| 223 "document.getElementById('password_unrelated').value = 'random';" |
| 224 "document.getElementById('submit_unrelated').click()"; |
| 225 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 226 observer.Wait(); |
| 227 EXPECT_TRUE(observer.infobar_shown()); |
| 228 } |
| 229 |
| 230 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, LoginFailed) { |
| 231 // Log in, see a form on the landing page. That form is not related to the |
| 232 // login form (=has a different action), so we should offer saving the |
| 233 // password. |
| 234 NavigateToFile("/password/password_form.html"); |
| 235 |
| 236 NavigationObserver observer(WebContents()); |
| 237 std::string fill_and_submit = |
| 238 "document.getElementById('username_failed').value = 'temp';" |
| 239 "document.getElementById('password_failed').value = 'random';" |
| 240 "document.getElementById('submit_failed').click()"; |
| 241 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 242 observer.Wait(); |
| 243 EXPECT_FALSE(observer.infobar_shown()); |
| 244 } |
| 245 |
213 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, Redirects) { | 246 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, Redirects) { |
214 NavigateToFile("/password/password_form.html"); | 247 NavigateToFile("/password/password_form.html"); |
215 | 248 |
216 // Fill a form and submit through a <input type="submit"> button. The form | 249 // Fill a form and submit through a <input type="submit"> button. The form |
217 // points to a redirection page. | 250 // points to a redirection page. |
218 NavigationObserver observer(WebContents()); | 251 NavigationObserver observer(WebContents()); |
219 std::string fill_and_submit = | 252 std::string fill_and_submit = |
220 "document.getElementById('username_redirect').value = 'temp';" | 253 "document.getElementById('username_redirect').value = 'temp';" |
221 "document.getElementById('password_redirect').value = 'random';" | 254 "document.getElementById('password_redirect').value = 'random';" |
222 "document.getElementById('submit_redirect').click()"; | 255 "document.getElementById('submit_redirect').click()"; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 "document.getElementById('username_field').value = 'temp';" | 553 "document.getElementById('username_field').value = 'temp';" |
521 "document.getElementById('password_field').value = 'random';" | 554 "document.getElementById('password_field').value = 'random';" |
522 "document.getElementById('input_submit_button').click();" | 555 "document.getElementById('input_submit_button').click();" |
523 "window.location.href = 'done.html';"; | 556 "window.location.href = 'done.html';"; |
524 | 557 |
525 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); | 558 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); |
526 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 559 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
527 observer.Wait(); | 560 observer.Wait(); |
528 // The only thing we check here is that there is no use-after-free reported. | 561 // The only thing we check here is that there is no use-after-free reported. |
529 } | 562 } |
OLD | NEW |