| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/time.h" | 6 #include "base/time.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/tabs/tab_strip_model.h" | 8 #include "chrome/browser/tabs/tab_strip_model.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/browser/renderer_host/render_view_host.h" | 15 #include "content/browser/renderer_host/render_view_host.h" |
| 16 #include "content/browser/tab_contents/interstitial_page.h" | 16 #include "content/browser/tab_contents/interstitial_page.h" |
| 17 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/common/notification_service.h" | |
| 20 #include "net/base/cert_status_flags.h" | 19 #include "net/base/cert_status_flags.h" |
| 21 #include "net/test/test_server.h" | 20 #include "net/test/test_server.h" |
| 22 | 21 |
| 23 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 22 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
| 24 | 23 |
| 25 class SSLUITest : public InProcessBrowserTest { | 24 class SSLUITest : public InProcessBrowserTest { |
| 26 typedef net::TestServer::HTTPSOptions HTTPSOptions; | 25 typedef net::TestServer::HTTPSOptions HTTPSOptions; |
| 27 | 26 |
| 28 public: | 27 public: |
| 29 SSLUITest() | 28 SSLUITest() |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 109 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 111 tab->render_view_host(), std::wstring(), | 110 tab->render_view_host(), std::wstring(), |
| 112 L"window.domAutomationController.send(IsContentLoaded());", | 111 L"window.domAutomationController.send(IsContentLoaded());", |
| 113 &actuallyLoadedContent)); | 112 &actuallyLoadedContent)); |
| 114 EXPECT_EQ(expectLoaded, actuallyLoadedContent); | 113 EXPECT_EQ(expectLoaded, actuallyLoadedContent); |
| 115 } | 114 } |
| 116 | 115 |
| 117 void ProceedThroughInterstitial(TabContents* tab) { | 116 void ProceedThroughInterstitial(TabContents* tab) { |
| 118 InterstitialPage* interstitial_page = tab->interstitial_page(); | 117 InterstitialPage* interstitial_page = tab->interstitial_page(); |
| 119 ASSERT_TRUE(interstitial_page); | 118 ASSERT_TRUE(interstitial_page); |
| 120 ui_test_utils::WindowedNotificationObserver observer( | |
| 121 content::NOTIFICATION_LOAD_STOP, | |
| 122 Source<NavigationController>(&tab->controller())); | |
| 123 interstitial_page->Proceed(); | 119 interstitial_page->Proceed(); |
| 124 observer.Wait(); | 120 // Wait for the navigation to be done. |
| 121 ui_test_utils::WaitForNavigation(&(tab->controller())); |
| 125 } | 122 } |
| 126 | 123 |
| 127 static bool GetFilePathWithHostAndPortReplacement( | 124 static bool GetFilePathWithHostAndPortReplacement( |
| 128 const std::string& original_file_path, | 125 const std::string& original_file_path, |
| 129 const net::HostPortPair& host_port_pair, | 126 const net::HostPortPair& host_port_pair, |
| 130 std::string* replacement_path) { | 127 std::string* replacement_path) { |
| 131 std::vector<net::TestServer::StringPair> replacement_text; | 128 std::vector<net::TestServer::StringPair> replacement_text; |
| 132 replacement_text.push_back( | 129 replacement_text.push_back( |
| 133 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); | 130 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); |
| 134 return net::TestServer::GetFilePathWithReplacements( | 131 return net::TestServer::GetFilePathWithReplacements( |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 test_server()->GetURL("files/ssl/google.html")); | 404 test_server()->GetURL("files/ssl/google.html")); |
| 408 TabContents* tab = browser()->GetSelectedTabContents(); | 405 TabContents* tab = browser()->GetSelectedTabContents(); |
| 409 NavigationEntry* entry1 = tab->controller().GetActiveEntry(); | 406 NavigationEntry* entry1 = tab->controller().GetActiveEntry(); |
| 410 ASSERT_TRUE(entry1); | 407 ASSERT_TRUE(entry1); |
| 411 ui_test_utils::NavigateToURL(browser(), | 408 ui_test_utils::NavigateToURL(browser(), |
| 412 test_server()->GetURL("files/ssl/blank_page.html")); | 409 test_server()->GetURL("files/ssl/blank_page.html")); |
| 413 NavigationEntry* entry2 = tab->controller().GetActiveEntry(); | 410 NavigationEntry* entry2 = tab->controller().GetActiveEntry(); |
| 414 ASSERT_TRUE(entry2); | 411 ASSERT_TRUE(entry2); |
| 415 | 412 |
| 416 // Now go back so that a page is in the forward history. | 413 // Now go back so that a page is in the forward history. |
| 417 { | 414 tab->controller().GoBack(); |
| 418 ui_test_utils::WindowedNotificationObserver observer( | 415 ui_test_utils::WaitForNavigation(&(tab->controller())); |
| 419 content::NOTIFICATION_LOAD_STOP, | |
| 420 Source<NavigationController>(&tab->controller())); | |
| 421 tab->controller().GoBack(); | |
| 422 observer.Wait(); | |
| 423 } | |
| 424 ASSERT_TRUE(tab->controller().CanGoForward()); | 416 ASSERT_TRUE(tab->controller().CanGoForward()); |
| 425 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); | 417 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); |
| 426 ASSERT_TRUE(entry1 == entry3); | 418 ASSERT_TRUE(entry1 == entry3); |
| 427 | 419 |
| 428 // Now go to a bad HTTPS page that shows an interstitial. | 420 // Now go to a bad HTTPS page that shows an interstitial. |
| 429 ui_test_utils::NavigateToURL(browser(), | 421 ui_test_utils::NavigateToURL(browser(), |
| 430 https_server_expired_.GetURL("files/ssl/google.html")); | 422 https_server_expired_.GetURL("files/ssl/google.html")); |
| 431 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 423 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
| 432 true); // Interstitial showing | 424 true); // Interstitial showing |
| 433 | 425 |
| 434 // Simulate user clicking and holding on forward button. | 426 // Simulate user clicking and holding on forward button. |
| 435 { | 427 tab->controller().GoToOffset(1); |
| 436 ui_test_utils::WindowedNotificationObserver observer( | 428 ui_test_utils::WaitForNavigation(&(tab->controller())); |
| 437 content::NOTIFICATION_LOAD_STOP, | |
| 438 Source<NavigationController>(&tab->controller())); | |
| 439 tab->controller().GoToOffset(1); | |
| 440 observer.Wait(); | |
| 441 } | |
| 442 | 429 |
| 443 // We should be showing the second good page. | 430 // We should be showing the second good page. |
| 444 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); | 431 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
| 445 CheckUnauthenticatedState(tab); | 432 CheckUnauthenticatedState(tab); |
| 446 EXPECT_FALSE(tab->controller().CanGoForward()); | 433 EXPECT_FALSE(tab->controller().CanGoForward()); |
| 447 NavigationEntry* entry4 = tab->controller().GetActiveEntry(); | 434 NavigationEntry* entry4 = tab->controller().GetActiveEntry(); |
| 448 EXPECT_TRUE(entry2 == entry4); | 435 EXPECT_TRUE(entry2 == entry4); |
| 449 } | 436 } |
| 450 | 437 |
| 451 // Flaky on CrOS http://crbug.com/92292 | 438 // Flaky on CrOS http://crbug.com/92292 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 590 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
| 604 "files/ssl/page_displays_insecure_content.html", | 591 "files/ssl/page_displays_insecure_content.html", |
| 605 test_server()->host_port_pair(), | 592 test_server()->host_port_pair(), |
| 606 &replacement_path)); | 593 &replacement_path)); |
| 607 | 594 |
| 608 GURL url = https_server_.GetURL(replacement_path); | 595 GURL url = https_server_.GetURL(replacement_path); |
| 609 browser::NavigateParams params(browser(), url, PageTransition::TYPED); | 596 browser::NavigateParams params(browser(), url, PageTransition::TYPED); |
| 610 params.disposition = NEW_FOREGROUND_TAB; | 597 params.disposition = NEW_FOREGROUND_TAB; |
| 611 params.tabstrip_index = 0; | 598 params.tabstrip_index = 0; |
| 612 params.source_contents = tab1; | 599 params.source_contents = tab1; |
| 613 ui_test_utils::WindowedNotificationObserver observer( | |
| 614 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | |
| 615 browser::Navigate(¶ms); | 600 browser::Navigate(¶ms); |
| 616 TabContentsWrapper* tab2 = params.target_contents; | 601 TabContentsWrapper* tab2 = params.target_contents; |
| 617 observer.Wait(); | 602 ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| 618 | 603 |
| 619 // The new tab has insecure content. | 604 // The new tab has insecure content. |
| 620 CheckAuthenticatedState(tab2->tab_contents(), true); | 605 CheckAuthenticatedState(tab2->tab_contents(), true); |
| 621 | 606 |
| 622 // The original tab should not be contaminated. | 607 // The original tab should not be contaminated. |
| 623 CheckAuthenticatedState(tab1->tab_contents(), false); | 608 CheckAuthenticatedState(tab1->tab_contents(), false); |
| 624 } | 609 } |
| 625 | 610 |
| 626 // Visits two pages from the same origin: one that runs insecure content and one | 611 // Visits two pages from the same origin: one that runs insecure content and one |
| 627 // that doesn't. The test checks that we propagate the insecure content state | 612 // that doesn't. The test checks that we propagate the insecure content state |
| (...skipping 14 matching lines...) Expand all Loading... |
| 642 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 627 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
| 643 "files/ssl/page_runs_insecure_content.html", | 628 "files/ssl/page_runs_insecure_content.html", |
| 644 test_server()->host_port_pair(), | 629 test_server()->host_port_pair(), |
| 645 &replacement_path)); | 630 &replacement_path)); |
| 646 | 631 |
| 647 // Create a new tab. | 632 // Create a new tab. |
| 648 GURL url = https_server_.GetURL(replacement_path); | 633 GURL url = https_server_.GetURL(replacement_path); |
| 649 browser::NavigateParams params(browser(), url, PageTransition::TYPED); | 634 browser::NavigateParams params(browser(), url, PageTransition::TYPED); |
| 650 params.disposition = NEW_FOREGROUND_TAB; | 635 params.disposition = NEW_FOREGROUND_TAB; |
| 651 params.source_contents = tab1; | 636 params.source_contents = tab1; |
| 652 ui_test_utils::WindowedNotificationObserver observer( | |
| 653 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | |
| 654 browser::Navigate(¶ms); | 637 browser::Navigate(¶ms); |
| 655 TabContentsWrapper* tab2 = params.target_contents; | 638 TabContentsWrapper* tab2 = params.target_contents; |
| 656 observer.Wait(); | 639 ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| 657 | 640 |
| 658 // The new tab has insecure content. | 641 // The new tab has insecure content. |
| 659 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); | 642 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); |
| 660 | 643 |
| 661 // Which means the origin for the first tab has also been contaminated with | 644 // Which means the origin for the first tab has also been contaminated with |
| 662 // insecure content. | 645 // insecure content. |
| 663 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false); | 646 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false); |
| 664 } | 647 } |
| 665 | 648 |
| 666 // Visits a page with an image over http. Visits another page over https | 649 // Visits a page with an image over http. Visits another page over https |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 break; | 800 break; |
| 818 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 801 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 819 new MessageLoop::QuitTask(), 1000); | 802 new MessageLoop::QuitTask(), 1000); |
| 820 ui_test_utils::RunMessageLoop(); | 803 ui_test_utils::RunMessageLoop(); |
| 821 } | 804 } |
| 822 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); | 805 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); |
| 823 | 806 |
| 824 // Let's add another tab to make sure the browser does not exit when we close | 807 // Let's add another tab to make sure the browser does not exit when we close |
| 825 // the first tab. | 808 // the first tab. |
| 826 GURL url = test_server()->GetURL("files/ssl/google.html"); | 809 GURL url = test_server()->GetURL("files/ssl/google.html"); |
| 827 ui_test_utils::WindowedNotificationObserver observer( | 810 TabContentsWrapper* tab2 = |
| 828 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); | 811 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
| 829 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); | 812 ui_test_utils::WaitForNavigation(&(tab2->controller())); |
| 830 observer.Wait(); | |
| 831 | 813 |
| 832 // Close the first tab. | 814 // Close the first tab. |
| 833 browser()->CloseTabContents(tab1); | 815 browser()->CloseTabContents(tab1); |
| 834 } | 816 } |
| 835 | 817 |
| 836 // Visit a page over bad https that is a redirect to a page with good https. | 818 // Visit a page over bad https that is a redirect to a page with good https. |
| 837 // Crashes: http://crbug.com/77374 | 819 // Crashes: http://crbug.com/77374 |
| 838 // Previously marked as flaky: http://crbug.com/40932 | 820 // Previously marked as flaky: http://crbug.com/40932 |
| 839 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestRedirectBadToGoodHTTPS) { | 821 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestRedirectBadToGoodHTTPS) { |
| 840 ASSERT_TRUE(https_server_.Start()); | 822 ASSERT_TRUE(https_server_.Start()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 &top_frame_path)); | 945 &top_frame_path)); |
| 964 | 946 |
| 965 TabContents* tab = browser()->GetSelectedTabContents(); | 947 TabContents* tab = browser()->GetSelectedTabContents(); |
| 966 ui_test_utils::NavigateToURL(browser(), | 948 ui_test_utils::NavigateToURL(browser(), |
| 967 https_server_.GetURL(top_frame_path)); | 949 https_server_.GetURL(top_frame_path)); |
| 968 | 950 |
| 969 CheckAuthenticatedState(tab, false); | 951 CheckAuthenticatedState(tab, false); |
| 970 | 952 |
| 971 bool success = false; | 953 bool success = false; |
| 972 // Now navigate inside the frame. | 954 // Now navigate inside the frame. |
| 973 { | 955 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 974 ui_test_utils::WindowedNotificationObserver observer( | 956 tab->render_view_host(), std::wstring(), |
| 975 content::NOTIFICATION_LOAD_STOP, | 957 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| 976 Source<NavigationController>(&tab->controller())); | 958 &success)); |
| 977 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 959 EXPECT_TRUE(success); |
| 978 tab->render_view_host(), std::wstring(), | 960 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 979 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | |
| 980 &success)); | |
| 981 ASSERT_TRUE(success); | |
| 982 observer.Wait(); | |
| 983 } | |
| 984 | 961 |
| 985 // We should still be fine. | 962 // We should still be fine. |
| 986 CheckAuthenticatedState(tab, false); | 963 CheckAuthenticatedState(tab, false); |
| 987 | 964 |
| 988 // Now let's hit a bad page. | 965 // Now let's hit a bad page. |
| 989 { | 966 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 990 ui_test_utils::WindowedNotificationObserver observer( | 967 tab->render_view_host(), std::wstring(), |
| 991 content::NOTIFICATION_LOAD_STOP, | 968 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| 992 Source<NavigationController>(&tab->controller())); | 969 &success)); |
| 993 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 970 EXPECT_TRUE(success); |
| 994 tab->render_view_host(), std::wstring(), | 971 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 995 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", | |
| 996 &success)); | |
| 997 ASSERT_TRUE(success); | |
| 998 observer.Wait(); | |
| 999 } | |
| 1000 | 972 |
| 1001 // The security style should still be secure. | 973 // The security style should still be secure. |
| 1002 CheckAuthenticatedState(tab, false); | 974 CheckAuthenticatedState(tab, false); |
| 1003 | 975 |
| 1004 // And the frame should be blocked. | 976 // And the frame should be blocked. |
| 1005 bool is_content_evil = true; | 977 bool is_content_evil = true; |
| 1006 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); | 978 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); |
| 1007 std::wstring is_evil_js(L"window.domAutomationController.send(" | 979 std::wstring is_evil_js(L"window.domAutomationController.send(" |
| 1008 L"document.getElementById('evilDiv') != null);"); | 980 L"document.getElementById('evilDiv') != null);"); |
| 1009 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 981 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1010 tab->render_view_host(), content_frame_xpath, is_evil_js, | 982 tab->render_view_host(), content_frame_xpath, is_evil_js, |
| 1011 &is_content_evil)); | 983 &is_content_evil)); |
| 1012 EXPECT_FALSE(is_content_evil); | 984 EXPECT_FALSE(is_content_evil); |
| 1013 | 985 |
| 1014 // Now go back, our state should still be OK. | 986 // Now go back, our state should still be OK. |
| 1015 { | 987 tab->controller().GoBack(); |
| 1016 ui_test_utils::WindowedNotificationObserver observer( | 988 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 1017 content::NOTIFICATION_LOAD_STOP, | |
| 1018 Source<NavigationController>(&tab->controller())); | |
| 1019 tab->controller().GoBack(); | |
| 1020 observer.Wait(); | |
| 1021 } | |
| 1022 CheckAuthenticatedState(tab, false); | 989 CheckAuthenticatedState(tab, false); |
| 1023 | 990 |
| 1024 // Navigate to a page served over HTTP. | 991 // Navigate to a page served over HTTP. |
| 1025 { | 992 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1026 ui_test_utils::WindowedNotificationObserver observer( | 993 tab->render_view_host(), std::wstring(), |
| 1027 content::NOTIFICATION_LOAD_STOP, | 994 L"window.domAutomationController.send(clickLink('HTTPLink'));", |
| 1028 Source<NavigationController>(&tab->controller())); | 995 &success)); |
| 1029 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 996 EXPECT_TRUE(success); |
| 1030 tab->render_view_host(), std::wstring(), | 997 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 1031 L"window.domAutomationController.send(clickLink('HTTPLink'));", | |
| 1032 &success)); | |
| 1033 ASSERT_TRUE(success); | |
| 1034 observer.Wait(); | |
| 1035 } | |
| 1036 | 998 |
| 1037 // Our state should be insecure. | 999 // Our state should be insecure. |
| 1038 CheckAuthenticatedState(tab, true); | 1000 CheckAuthenticatedState(tab, true); |
| 1039 | 1001 |
| 1040 // Go back, our state should be unchanged. | 1002 // Go back, our state should be unchanged. |
| 1041 { | 1003 tab->controller().GoBack(); |
| 1042 ui_test_utils::WindowedNotificationObserver observer( | 1004 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 1043 content::NOTIFICATION_LOAD_STOP, | |
| 1044 Source<NavigationController>(&tab->controller())); | |
| 1045 tab->controller().GoBack(); | |
| 1046 observer.Wait(); | |
| 1047 } | |
| 1048 CheckAuthenticatedState(tab, true); | 1005 CheckAuthenticatedState(tab, true); |
| 1049 } | 1006 } |
| 1050 | 1007 |
| 1051 // From a bad HTTPS top frame: | 1008 // From a bad HTTPS top frame: |
| 1052 // - navigate to an OK HTTPS frame (expected to be still authentication broken). | 1009 // - navigate to an OK HTTPS frame (expected to be still authentication broken). |
| 1053 // Marked as flaky, see bug 40932. | 1010 // Marked as flaky, see bug 40932. |
| 1054 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { | 1011 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { |
| 1055 ASSERT_TRUE(https_server_.Start()); | 1012 ASSERT_TRUE(https_server_.Start()); |
| 1056 ASSERT_TRUE(https_server_expired_.Start()); | 1013 ASSERT_TRUE(https_server_expired_.Start()); |
| 1057 | 1014 |
| 1058 std::string top_frame_path; | 1015 std::string top_frame_path; |
| 1059 ASSERT_TRUE(GetTopFramePath(*test_server(), | 1016 ASSERT_TRUE(GetTopFramePath(*test_server(), |
| 1060 https_server_, | 1017 https_server_, |
| 1061 https_server_expired_, | 1018 https_server_expired_, |
| 1062 &top_frame_path)); | 1019 &top_frame_path)); |
| 1063 | 1020 |
| 1064 TabContents* tab = browser()->GetSelectedTabContents(); | 1021 TabContents* tab = browser()->GetSelectedTabContents(); |
| 1065 ui_test_utils::NavigateToURL(browser(), | 1022 ui_test_utils::NavigateToURL(browser(), |
| 1066 https_server_expired_.GetURL(top_frame_path)); | 1023 https_server_expired_.GetURL(top_frame_path)); |
| 1067 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 1024 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
| 1068 true); // Interstitial showing | 1025 true); // Interstitial showing |
| 1069 | 1026 |
| 1070 ProceedThroughInterstitial(tab); | 1027 ProceedThroughInterstitial(tab); |
| 1071 | 1028 |
| 1072 // Navigate to a good frame. | 1029 // Navigate to a good frame. |
| 1073 bool success = false; | 1030 bool success = false; |
| 1074 ui_test_utils::WindowedNotificationObserver observer( | |
| 1075 content::NOTIFICATION_LOAD_STOP, | |
| 1076 Source<NavigationController>(&tab->controller())); | |
| 1077 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1031 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1078 tab->render_view_host(), std::wstring(), | 1032 tab->render_view_host(), std::wstring(), |
| 1079 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | 1033 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| 1080 &success)); | 1034 &success)); |
| 1081 ASSERT_TRUE(success); | 1035 EXPECT_TRUE(success); |
| 1082 observer.Wait(); | 1036 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 1083 | 1037 |
| 1084 // We should still be authentication broken. | 1038 // We should still be authentication broken. |
| 1085 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 1039 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
| 1086 false); | 1040 false); |
| 1087 } | 1041 } |
| 1088 | 1042 |
| 1089 // From an HTTP top frame, navigate to good and bad HTTPS (security state should | 1043 // From an HTTP top frame, navigate to good and bad HTTPS (security state should |
| 1090 // stay unauthenticated). | 1044 // stay unauthenticated). |
| 1091 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. | 1045 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. |
| 1092 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { | 1046 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { |
| 1093 ASSERT_TRUE(test_server()->Start()); | 1047 ASSERT_TRUE(test_server()->Start()); |
| 1094 ASSERT_TRUE(https_server_.Start()); | 1048 ASSERT_TRUE(https_server_.Start()); |
| 1095 ASSERT_TRUE(https_server_expired_.Start()); | 1049 ASSERT_TRUE(https_server_expired_.Start()); |
| 1096 | 1050 |
| 1097 std::string top_frame_path; | 1051 std::string top_frame_path; |
| 1098 ASSERT_TRUE(GetTopFramePath(*test_server(), | 1052 ASSERT_TRUE(GetTopFramePath(*test_server(), |
| 1099 https_server_, | 1053 https_server_, |
| 1100 https_server_expired_, | 1054 https_server_expired_, |
| 1101 &top_frame_path)); | 1055 &top_frame_path)); |
| 1102 | 1056 |
| 1103 TabContents* tab = browser()->GetSelectedTabContents(); | 1057 TabContents* tab = browser()->GetSelectedTabContents(); |
| 1104 ui_test_utils::NavigateToURL(browser(), | 1058 ui_test_utils::NavigateToURL(browser(), |
| 1105 test_server()->GetURL(top_frame_path)); | 1059 test_server()->GetURL(top_frame_path)); |
| 1106 CheckUnauthenticatedState(tab); | 1060 CheckUnauthenticatedState(tab); |
| 1107 | 1061 |
| 1108 // Now navigate inside the frame to a secure HTTPS frame. | 1062 // Now navigate inside the frame to a secure HTTPS frame. |
| 1109 { | 1063 bool success = false; |
| 1110 bool success = false; | 1064 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1111 ui_test_utils::WindowedNotificationObserver observer( | 1065 tab->render_view_host(), std::wstring(), |
| 1112 content::NOTIFICATION_LOAD_STOP, | 1066 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| 1113 Source<NavigationController>(&tab->controller())); | 1067 &success)); |
| 1114 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1068 EXPECT_TRUE(success); |
| 1115 tab->render_view_host(), std::wstring(), | 1069 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 1116 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | |
| 1117 &success)); | |
| 1118 ASSERT_TRUE(success); | |
| 1119 observer.Wait(); | |
| 1120 } | |
| 1121 | 1070 |
| 1122 // We should still be unauthenticated. | 1071 // We should still be unauthenticated. |
| 1123 CheckUnauthenticatedState(tab); | 1072 CheckUnauthenticatedState(tab); |
| 1124 | 1073 |
| 1125 // Now navigate to a bad HTTPS frame. | 1074 // Now navigate to a bad HTTPS frame. |
| 1126 { | 1075 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1127 bool success = false; | 1076 tab->render_view_host(), std::wstring(), |
| 1128 ui_test_utils::WindowedNotificationObserver observer( | 1077 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| 1129 content::NOTIFICATION_LOAD_STOP, | 1078 &success)); |
| 1130 Source<NavigationController>(&tab->controller())); | 1079 EXPECT_TRUE(success); |
| 1131 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1080 ui_test_utils::WaitForNavigation(&tab->controller()); |
| 1132 tab->render_view_host(), std::wstring(), | |
| 1133 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", | |
| 1134 &success)); | |
| 1135 ASSERT_TRUE(success); | |
| 1136 observer.Wait(); | |
| 1137 } | |
| 1138 | 1081 |
| 1139 // State should not have changed. | 1082 // State should not have changed. |
| 1140 CheckUnauthenticatedState(tab); | 1083 CheckUnauthenticatedState(tab); |
| 1141 | 1084 |
| 1142 // And the frame should have been blocked (see bug #2316). | 1085 // And the frame should have been blocked (see bug #2316). |
| 1143 bool is_content_evil = true; | 1086 bool is_content_evil = true; |
| 1144 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); | 1087 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); |
| 1145 std::wstring is_evil_js(L"window.domAutomationController.send(" | 1088 std::wstring is_evil_js(L"window.domAutomationController.send(" |
| 1146 L"document.getElementById('evilDiv') != null);"); | 1089 L"document.getElementById('evilDiv') != null);"); |
| 1147 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1090 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 | 1183 |
| 1241 // Visit a page over https that contains a frame with a redirect. | 1184 // Visit a page over https that contains a frame with a redirect. |
| 1242 | 1185 |
| 1243 // XMLHttpRequest insecure content in synchronous mode. | 1186 // XMLHttpRequest insecure content in synchronous mode. |
| 1244 | 1187 |
| 1245 // XMLHttpRequest insecure content in asynchronous mode. | 1188 // XMLHttpRequest insecure content in asynchronous mode. |
| 1246 | 1189 |
| 1247 // XMLHttpRequest over bad ssl in synchronous mode. | 1190 // XMLHttpRequest over bad ssl in synchronous mode. |
| 1248 | 1191 |
| 1249 // XMLHttpRequest over OK ssl in synchronous mode. | 1192 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |