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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 "frame_doc.getElementById('username_field').value = 'temp';" | 369 "frame_doc.getElementById('username_field').value = 'temp';" |
370 "frame_doc.getElementById('password_field').value = 'random';" | 370 "frame_doc.getElementById('password_field').value = 'random';" |
371 "frame_doc.getElementById('input_submit_button').click();"; | 371 "frame_doc.getElementById('input_submit_button').click();"; |
372 | 372 |
373 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 373 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
374 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 374 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
375 observer.Wait(); | 375 observer.Wait(); |
376 EXPECT_TRUE(observer.infobar_shown()); | 376 EXPECT_TRUE(observer.infobar_shown()); |
377 } | 377 } |
378 | 378 |
| 379 IN_PROC_BROWSER_TEST_F( |
| 380 PasswordManagerBrowserTest, |
| 381 NoPromptForFailedLoginFromMainFrameWithMultiFramesInPage) { |
| 382 NavigateToFile("/password/multi_frames.html"); |
| 383 |
| 384 // Make sure that we don't prompt to save the password for a failed login |
| 385 // from the main frame with multiple frames in the same page. |
| 386 NavigationObserver observer(WebContents()); |
| 387 std::string fill_and_submit = |
| 388 "document.getElementById('username_failed').value = 'temp';" |
| 389 "document.getElementById('password_failed').value = 'random';" |
| 390 "document.getElementById('submit_failed').click();"; |
| 391 |
| 392 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 393 observer.Wait(); |
| 394 EXPECT_FALSE(observer.infobar_shown()); |
| 395 } |
| 396 |
| 397 IN_PROC_BROWSER_TEST_F( |
| 398 PasswordManagerBrowserTest, |
| 399 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) { |
| 400 NavigateToFile("/password/multi_frames.html"); |
| 401 |
| 402 // Make sure that we don't prompt to save the password for a failed login |
| 403 // from a sub-frame with multiple frames in the same page. |
| 404 NavigationObserver observer(WebContents()); |
| 405 std::string fill_and_submit = |
| 406 "var first_frame = document.getElementById('first_frame');" |
| 407 "var frame_doc = first_frame.contentDocument;" |
| 408 "frame_doc.getElementById('username_failed').value = 'temp';" |
| 409 "frame_doc.getElementById('password_failed').value = 'random';" |
| 410 "frame_doc.getElementById('submit_failed').click();" |
| 411 "window.parent.location.href = 'multi_frames.html';"; |
| 412 |
| 413 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 414 observer.Wait(); |
| 415 EXPECT_FALSE(observer.infobar_shown()); |
| 416 } |
| 417 |
379 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, | 418 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, |
380 PromptForXHRSubmit) { | 419 PromptForXHRSubmit) { |
381 #if defined(OS_WIN) && defined(USE_ASH) | 420 #if defined(OS_WIN) && defined(USE_ASH) |
382 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 421 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
383 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 422 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
384 return; | 423 return; |
385 #endif | 424 #endif |
386 NavigateToFile("/password/password_xhr_submit.html"); | 425 NavigateToFile("/password/password_xhr_submit.html"); |
387 | 426 |
388 // Verify that we show the save password prompt if a form returns false | 427 // Verify that we show the save password prompt if a form returns false |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); | 786 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); |
748 | 787 |
749 NavigationObserver observer(WebContents()); | 788 NavigationObserver observer(WebContents()); |
750 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); | 789 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); |
751 chrome::NavigateParams params(browser(), url, | 790 chrome::NavigateParams params(browser(), url, |
752 content::PAGE_TRANSITION_RELOAD); | 791 content::PAGE_TRANSITION_RELOAD); |
753 ui_test_utils::NavigateToURL(¶ms); | 792 ui_test_utils::NavigateToURL(¶ms); |
754 observer.Wait(); | 793 observer.Wait(); |
755 EXPECT_FALSE(observer.infobar_shown()); | 794 EXPECT_FALSE(observer.infobar_shown()); |
756 } | 795 } |
OLD | NEW |