OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/download/download_test_observer.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
12 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
14 #include "chrome/browser/ui/browser_navigator.h" | 16 #include "chrome/browser/ui/browser_navigator.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 17 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 18 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
23 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
26 #include "content/public/browser/browser_context.h" | |
24 #include "content/public/browser/interstitial_page.h" | 27 #include "content/public/browser/interstitial_page.h" |
25 #include "content/public/browser/navigation_controller.h" | 28 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
27 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
29 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
30 #include "content/public/browser/web_contents_observer.h" | 33 #include "content/public/browser/web_contents_observer.h" |
31 #include "content/public/common/security_style.h" | 34 #include "content/public/common/security_style.h" |
32 #include "content/public/common/ssl_status.h" | 35 #include "content/public/common/ssl_status.h" |
33 #include "content/public/test/browser_test_utils.h" | 36 #include "content/public/test/browser_test_utils.h" |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 browser(), url, content::PAGE_TRANSITION_TYPED); | 631 browser(), url, content::PAGE_TRANSITION_TYPED); |
629 content::WaitForLoadStop(tab2->web_contents()); | 632 content::WaitForLoadStop(tab2->web_contents()); |
630 | 633 |
631 // Verify our assumption that there was no prior navigation. | 634 // Verify our assumption that there was no prior navigation. |
632 EXPECT_FALSE(chrome::CanGoBack(browser())); | 635 EXPECT_FALSE(chrome::CanGoBack(browser())); |
633 | 636 |
634 // We should have an interstitial page showing. | 637 // We should have an interstitial page showing. |
635 ASSERT_TRUE(tab2->web_contents()->GetInterstitialPage()); | 638 ASSERT_TRUE(tab2->web_contents()->GetInterstitialPage()); |
636 } | 639 } |
637 | 640 |
638 // Disabled due to crash in downloads code that this triggers. | 641 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadHTTPSDownload) { |
639 // http://crbug.com/95331 | |
640 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestBadHTTPSDownload) { | |
641 ASSERT_TRUE(test_server()->Start()); | 642 ASSERT_TRUE(test_server()->Start()); |
642 ASSERT_TRUE(https_server_expired_.Start()); | 643 ASSERT_TRUE(https_server_expired_.Start()); |
643 GURL url_non_dangerous = test_server()->GetURL(""); | 644 GURL url_non_dangerous = test_server()->GetURL(""); |
644 GURL url_dangerous = https_server_expired_.GetURL( | 645 GURL url_dangerous = https_server_expired_.GetURL( |
645 "files/downloads/dangerous/dangerous.exe"); | 646 "files/downloads/dangerous/dangerous.exe"); |
646 | 647 |
647 // Visit a non-dangerous page. | 648 // Visit a non-dangerous page. |
648 ui_test_utils::NavigateToURL(browser(), url_non_dangerous); | 649 ui_test_utils::NavigateToURL(browser(), url_non_dangerous); |
649 | 650 |
650 // Now, start a transition to dangerous download. | 651 // Now, start a transition to dangerous download. |
651 { | 652 { |
652 content::WindowedNotificationObserver observer( | 653 content::WindowedNotificationObserver observer( |
653 content::NOTIFICATION_LOAD_STOP, | 654 content::NOTIFICATION_LOAD_STOP, |
654 content::NotificationService::AllSources()); | 655 content::NotificationService::AllSources()); |
655 chrome::NavigateParams navigate_params(browser(), url_dangerous, | 656 chrome::NavigateParams navigate_params(browser(), url_dangerous, |
656 content::PAGE_TRANSITION_TYPED); | 657 content::PAGE_TRANSITION_TYPED); |
657 chrome::Navigate(&navigate_params); | 658 chrome::Navigate(&navigate_params); |
658 observer.Wait(); | 659 observer.Wait(); |
659 } | 660 } |
660 | 661 |
661 // Proceed through the SSL interstitial. This doesn't use | 662 // Proceed through the SSL interstitial. This doesn't use |
662 // |ProceedThroughInterstitial| since no page load will commit. | 663 // |ProceedThroughInterstitial| since no page load will commit. |
663 WebContents* tab = chrome::GetActiveWebContents(browser()); | 664 WebContents* tab = chrome::GetActiveWebContents(browser()); |
664 ASSERT_TRUE(tab != NULL); | 665 ASSERT_TRUE(tab != NULL); |
665 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); | 666 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); |
666 { | 667 { |
667 content::WindowedNotificationObserver observer( | 668 content::WindowedNotificationObserver observer( |
668 chrome::NOTIFICATION_DOWNLOAD_INITIATED, | 669 chrome::NOTIFICATION_DOWNLOAD_INITIATED, |
669 content::NotificationService::AllSources()); | 670 content::NotificationService::AllSources()); |
670 tab->GetInterstitialPage()->Proceed(); | 671 tab->GetInterstitialPage()->Proceed(); |
Randy Smith (Not in Mondays)
2012/08/15 19:01:16
I believe this is the line at which the download w
mmenke
2012/08/15 19:59:22
Sorry, meant to response earlier, but got distract
| |
671 observer.Wait(); | 672 observer.Wait(); |
672 } | 673 } |
673 | 674 |
674 // There should still be an interstitial at this point. Press the | 675 // There should still be an interstitial at this point. Press the |
675 // back button on the browser. Note that this doesn't wait for a | 676 // back button on the browser. Note that this doesn't wait for a |
676 // NAV_ENTRY_COMMITTED notification because going back with an | 677 // NAV_ENTRY_COMMITTED notification because going back with an |
677 // active interstitial simply hides the interstitial. | 678 // active interstitial simply hides the interstitial. |
678 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); | 679 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); |
679 EXPECT_TRUE(chrome::CanGoBack(browser())); | 680 EXPECT_TRUE(chrome::CanGoBack(browser())); |
680 chrome::GoBack(browser(), CURRENT_TAB); | 681 { |
682 // To exit the browser cleanly we need to complete the download. | |
683 DownloadTestObserverTerminal observer( | |
684 content::BrowserContext::GetDownloadManager(browser()->profile()), | |
685 1, | |
686 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT); | |
687 chrome::GoBack(browser(), CURRENT_TAB); | |
688 observer.WaitForFinished(); | |
689 } | |
681 } | 690 } |
682 | 691 |
683 // | 692 // |
684 // Insecure content | 693 // Insecure content |
685 // | 694 // |
686 | 695 |
687 // Visits a page that displays insecure content. | 696 // Visits a page that displays insecure content. |
688 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContent) { | 697 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContent) { |
689 ASSERT_TRUE(test_server()->Start()); | 698 ASSERT_TRUE(test_server()->Start()); |
690 ASSERT_TRUE(https_server_.Start()); | 699 ASSERT_TRUE(https_server_.Start()); |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1496 | 1505 |
1497 // Visit a page over https that contains a frame with a redirect. | 1506 // Visit a page over https that contains a frame with a redirect. |
1498 | 1507 |
1499 // XMLHttpRequest insecure content in synchronous mode. | 1508 // XMLHttpRequest insecure content in synchronous mode. |
1500 | 1509 |
1501 // XMLHttpRequest insecure content in asynchronous mode. | 1510 // XMLHttpRequest insecure content in asynchronous mode. |
1502 | 1511 |
1503 // XMLHttpRequest over bad ssl in synchronous mode. | 1512 // XMLHttpRequest over bad ssl in synchronous mode. |
1504 | 1513 |
1505 // XMLHttpRequest over OK ssl in synchronous mode. | 1514 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |