| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/time.h" | 5 #include "base/time.h" |
| 6 #include "chrome/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
| 7 #include "chrome/browser/pref_service.h" | 7 #include "chrome/browser/pref_service.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/tab_contents/interstitial_page.h" | 9 #include "chrome/browser/tab_contents/interstitial_page.h" |
| 10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 // Simulate user clicking on back button (crbug.com/39248). | 243 // Simulate user clicking on back button (crbug.com/39248). |
| 244 browser()->GoBack(CURRENT_TAB); | 244 browser()->GoBack(CURRENT_TAB); |
| 245 | 245 |
| 246 // We should be back at the original good page. | 246 // We should be back at the original good page. |
| 247 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); | 247 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
| 248 CheckUnauthenticatedState(tab); | 248 CheckUnauthenticatedState(tab); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Visits a page with https error and then goes back using GoToOffset. | 251 // Visits a page with https error and then goes back using GoToOffset. |
| 252 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoBackViaMenu) { | 252 // Marked as flaky, see bug 40932. |
| 253 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestHTTPSExpiredCertAndGoBackViaMenu) { |
| 253 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 254 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
| 254 ASSERT_TRUE(http_server.get() != NULL); | 255 ASSERT_TRUE(http_server.get() != NULL); |
| 255 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 256 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
| 256 ASSERT_TRUE(bad_https_server.get() != NULL); | 257 ASSERT_TRUE(bad_https_server.get() != NULL); |
| 257 | 258 |
| 258 // First navigate to an HTTP page. | 259 // First navigate to an HTTP page. |
| 259 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW( | 260 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW( |
| 260 L"files/ssl/google.html")); | 261 L"files/ssl/google.html")); |
| 261 TabContents* tab = browser()->GetSelectedTabContents(); | 262 TabContents* tab = browser()->GetSelectedTabContents(); |
| 262 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 263 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPageW( | 395 ui_test_utils::NavigateToURL(browser(), https_server->TestServerPageW( |
| 395 L"files/ssl/page_with_http_script.html")); | 396 L"files/ssl/page_with_http_script.html")); |
| 396 | 397 |
| 397 CheckAuthenticatedState(browser()->GetSelectedTabContents(), | 398 CheckAuthenticatedState(browser()->GetSelectedTabContents(), |
| 398 true /* mixed-content */, false); | 399 true /* mixed-content */, false); |
| 399 } | 400 } |
| 400 | 401 |
| 401 // Visits a page with unsafe content and make sure that: | 402 // Visits a page with unsafe content and make sure that: |
| 402 // - frames content is replaced with warning | 403 // - frames content is replaced with warning |
| 403 // - images and scripts are filtered out entirely | 404 // - images and scripts are filtered out entirely |
| 404 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContents) { | 405 // Marked as flaky, see bug 40932. |
| 406 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContents) { |
| 405 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 407 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
| 406 ASSERT_TRUE(good_https_server.get() != NULL); | 408 ASSERT_TRUE(good_https_server.get() != NULL); |
| 407 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 409 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
| 408 ASSERT_TRUE(bad_https_server.get() != NULL); | 410 ASSERT_TRUE(bad_https_server.get() != NULL); |
| 409 | 411 |
| 410 ui_test_utils::NavigateToURL(browser(), good_https_server->TestServerPageW( | 412 ui_test_utils::NavigateToURL(browser(), good_https_server->TestServerPageW( |
| 411 L"files/ssl/page_with_unsafe_contents.html")); | 413 L"files/ssl/page_with_unsafe_contents.html")); |
| 412 | 414 |
| 413 TabContents* tab = browser()->GetSelectedTabContents(); | 415 TabContents* tab = browser()->GetSelectedTabContents(); |
| 414 // When the bad content is filtered, the state is expected to be | 416 // When the bad content is filtered, the state is expected to be |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 648 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, |
| 647 true); // Interstitial showing. | 649 true); // Interstitial showing. |
| 648 | 650 |
| 649 ProceedThroughInterstitial(tab); | 651 ProceedThroughInterstitial(tab); |
| 650 | 652 |
| 651 // We have been redirected to the good page. | 653 // We have been redirected to the good page. |
| 652 CheckAuthenticatedState(tab, false, false); // No mixed/unsafe content. | 654 CheckAuthenticatedState(tab, false, false); // No mixed/unsafe content. |
| 653 } | 655 } |
| 654 | 656 |
| 655 // Visit a page over good https that is a redirect to a page with bad https. | 657 // Visit a page over good https that is a redirect to a page with bad https. |
| 656 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectGoodToBadHTTPS) { | 658 // Marked as flaky, see bug 40932. |
| 659 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectGoodToBadHTTPS) { |
| 657 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 660 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
| 658 ASSERT_TRUE(good_https_server.get() != NULL); | 661 ASSERT_TRUE(good_https_server.get() != NULL); |
| 659 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 662 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
| 660 ASSERT_TRUE(bad_https_server.get() != NULL); | 663 ASSERT_TRUE(bad_https_server.get() != NULL); |
| 661 | 664 |
| 662 GURL url1 = good_https_server->TestServerPageW(L"server-redirect?"); | 665 GURL url1 = good_https_server->TestServerPageW(L"server-redirect?"); |
| 663 GURL url2 = bad_https_server->TestServerPageW(L"files/ssl/google.html"); | 666 GURL url2 = bad_https_server->TestServerPageW(L"files/ssl/google.html"); |
| 664 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); | 667 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); |
| 665 | 668 |
| 666 TabContents* tab = browser()->GetSelectedTabContents(); | 669 TabContents* tab = browser()->GetSelectedTabContents(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 true); // Interstitial showing. | 713 true); // Interstitial showing. |
| 711 | 714 |
| 712 ProceedThroughInterstitial(tab); | 715 ProceedThroughInterstitial(tab); |
| 713 | 716 |
| 714 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 717 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, |
| 715 false); // No interstitial showing. | 718 false); // No interstitial showing. |
| 716 } | 719 } |
| 717 | 720 |
| 718 // Visit a page over https that is a redirect to a page with http (to make sure | 721 // Visit a page over https that is a redirect to a page with http (to make sure |
| 719 // we don't keep the secure state). | 722 // we don't keep the secure state). |
| 720 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) { | 723 // Marked as flaky, see bug 40932. |
| 724 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestRedirectHTTPSToHTTP) { |
| 721 scoped_refptr<HTTPTestServer> http_server = PlainServer(); | 725 scoped_refptr<HTTPTestServer> http_server = PlainServer(); |
| 722 ASSERT_TRUE(http_server.get() != NULL); | 726 ASSERT_TRUE(http_server.get() != NULL); |
| 723 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); | 727 scoped_refptr<HTTPSTestServer> https_server = GoodCertServer(); |
| 724 ASSERT_TRUE(https_server.get() != NULL); | 728 ASSERT_TRUE(https_server.get() != NULL); |
| 725 | 729 |
| 726 GURL https_url = https_server->TestServerPageW(L"server-redirect?"); | 730 GURL https_url = https_server->TestServerPageW(L"server-redirect?"); |
| 727 GURL http_url = http_server->TestServerPageW(L"files/ssl/google.html"); | 731 GURL http_url = http_server->TestServerPageW(L"files/ssl/google.html"); |
| 728 | 732 |
| 729 ui_test_utils::NavigateToURL(browser(), | 733 ui_test_utils::NavigateToURL(browser(), |
| 730 GURL(https_url.spec() + http_url.spec())); | 734 GURL(https_url.spec() + http_url.spec())); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 CheckAuthenticatedState(tab, true, false); | 824 CheckAuthenticatedState(tab, true, false); |
| 821 | 825 |
| 822 // Go back, our state should be unchanged. | 826 // Go back, our state should be unchanged. |
| 823 tab->controller().GoBack(); | 827 tab->controller().GoBack(); |
| 824 ui_test_utils::WaitForNavigation(&tab->controller()); | 828 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 825 CheckAuthenticatedState(tab, true, false); | 829 CheckAuthenticatedState(tab, true, false); |
| 826 } | 830 } |
| 827 | 831 |
| 828 // From a bad HTTPS top frame: | 832 // From a bad HTTPS top frame: |
| 829 // - navigate to an OK HTTPS frame (expected to be still authentication broken). | 833 // - navigate to an OK HTTPS frame (expected to be still authentication broken). |
| 830 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadFrameNavigation) { | 834 // Marked as flaky, see bug 40932. |
| 835 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { |
| 831 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 836 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
| 832 ASSERT_TRUE(good_https_server.get() != NULL); | 837 ASSERT_TRUE(good_https_server.get() != NULL); |
| 833 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 838 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
| 834 ASSERT_TRUE(bad_https_server.get() != NULL); | 839 ASSERT_TRUE(bad_https_server.get() != NULL); |
| 835 | 840 |
| 836 TabContents* tab = browser()->GetSelectedTabContents(); | 841 TabContents* tab = browser()->GetSelectedTabContents(); |
| 837 ui_test_utils::NavigateToURL( | 842 ui_test_utils::NavigateToURL( |
| 838 browser(), | 843 browser(), |
| 839 bad_https_server->TestServerPageW(L"files/ssl/top_frame.html")); | 844 bad_https_server->TestServerPageW(L"files/ssl/top_frame.html")); |
| 840 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, | 845 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); | 906 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); |
| 902 std::wstring is_frame_evil_js( | 907 std::wstring is_frame_evil_js( |
| 903 L"window.domAutomationController" | 908 L"window.domAutomationController" |
| 904 L".send(document.getElementById('evilDiv') != null);"); | 909 L".send(document.getElementById('evilDiv') != null);"); |
| 905 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 910 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 906 tab->render_view_host(), content_frame_xpath, is_frame_evil_js, | 911 tab->render_view_host(), content_frame_xpath, is_frame_evil_js, |
| 907 &is_content_evil)); | 912 &is_content_evil)); |
| 908 EXPECT_FALSE(is_content_evil); | 913 EXPECT_FALSE(is_content_evil); |
| 909 } | 914 } |
| 910 | 915 |
| 911 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerFiltered) { | 916 // Marked as flaky, see bug 40932. |
| 917 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestUnsafeContentsInWorkerFiltered) { |
| 912 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); | 918 scoped_refptr<HTTPSTestServer> good_https_server = GoodCertServer(); |
| 913 ASSERT_TRUE(good_https_server.get() != NULL); | 919 ASSERT_TRUE(good_https_server.get() != NULL); |
| 914 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); | 920 scoped_refptr<HTTPSTestServer> bad_https_server = BadCertServer(); |
| 915 ASSERT_TRUE(bad_https_server.get() != NULL); | 921 ASSERT_TRUE(bad_https_server.get() != NULL); |
| 916 | 922 |
| 917 // This page will spawn a Worker which will try to load content from | 923 // This page will spawn a Worker which will try to load content from |
| 918 // BadCertServer. | 924 // BadCertServer. |
| 919 ui_test_utils::NavigateToURL(browser(), good_https_server->TestServerPage( | 925 ui_test_utils::NavigateToURL(browser(), good_https_server->TestServerPage( |
| 920 "files/ssl/page_with_unsafe_worker.html")); | 926 "files/ssl/page_with_unsafe_worker.html")); |
| 921 TabContents* tab = browser()->GetSelectedTabContents(); | 927 TabContents* tab = browser()->GetSelectedTabContents(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 | 960 |
| 955 // Visit a page over https that contains a frame with a redirect. | 961 // Visit a page over https that contains a frame with a redirect. |
| 956 | 962 |
| 957 // XMLHttpRequest mixed in synchronous mode. | 963 // XMLHttpRequest mixed in synchronous mode. |
| 958 | 964 |
| 959 // XMLHttpRequest mixed in asynchronous mode. | 965 // XMLHttpRequest mixed in asynchronous mode. |
| 960 | 966 |
| 961 // XMLHttpRequest over bad ssl in synchronous mode. | 967 // XMLHttpRequest over bad ssl in synchronous mode. |
| 962 | 968 |
| 963 // XMLHttpRequest over OK ssl in synchronous mode. | 969 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |