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" |
19 #include "net/base/cert_status_flags.h" | 20 #include "net/base/cert_status_flags.h" |
20 #include "net/test/test_server.h" | 21 #include "net/test/test_server.h" |
21 | 22 |
22 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 23 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
23 | 24 |
24 class SSLUITest : public InProcessBrowserTest { | 25 class SSLUITest : public InProcessBrowserTest { |
25 typedef net::TestServer::HTTPSOptions HTTPSOptions; | 26 typedef net::TestServer::HTTPSOptions HTTPSOptions; |
26 | 27 |
27 public: | 28 public: |
28 SSLUITest() | 29 SSLUITest() |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 110 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
110 tab->render_view_host(), std::wstring(), | 111 tab->render_view_host(), std::wstring(), |
111 L"window.domAutomationController.send(IsContentLoaded());", | 112 L"window.domAutomationController.send(IsContentLoaded());", |
112 &actuallyLoadedContent)); | 113 &actuallyLoadedContent)); |
113 EXPECT_EQ(expectLoaded, actuallyLoadedContent); | 114 EXPECT_EQ(expectLoaded, actuallyLoadedContent); |
114 } | 115 } |
115 | 116 |
116 void ProceedThroughInterstitial(TabContents* tab) { | 117 void ProceedThroughInterstitial(TabContents* tab) { |
117 InterstitialPage* interstitial_page = tab->interstitial_page(); | 118 InterstitialPage* interstitial_page = tab->interstitial_page(); |
118 ASSERT_TRUE(interstitial_page); | 119 ASSERT_TRUE(interstitial_page); |
| 120 ui_test_utils::WindowedNotificationObserver observer( |
| 121 content::NOTIFICATION_LOAD_STOP, |
| 122 Source<NavigationController>(&tab->controller())); |
119 interstitial_page->Proceed(); | 123 interstitial_page->Proceed(); |
120 // Wait for the navigation to be done. | 124 observer.Wait(); |
121 ui_test_utils::WaitForNavigation(&(tab->controller())); | |
122 } | 125 } |
123 | 126 |
124 static bool GetFilePathWithHostAndPortReplacement( | 127 static bool GetFilePathWithHostAndPortReplacement( |
125 const std::string& original_file_path, | 128 const std::string& original_file_path, |
126 const net::HostPortPair& host_port_pair, | 129 const net::HostPortPair& host_port_pair, |
127 std::string* replacement_path) { | 130 std::string* replacement_path) { |
128 std::vector<net::TestServer::StringPair> replacement_text; | 131 std::vector<net::TestServer::StringPair> replacement_text; |
129 replacement_text.push_back( | 132 replacement_text.push_back( |
130 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); | 133 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); |
131 return net::TestServer::GetFilePathWithReplacements( | 134 return net::TestServer::GetFilePathWithReplacements( |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 test_server()->GetURL("files/ssl/google.html")); | 400 test_server()->GetURL("files/ssl/google.html")); |
398 TabContents* tab = browser()->GetSelectedTabContents(); | 401 TabContents* tab = browser()->GetSelectedTabContents(); |
399 NavigationEntry* entry1 = tab->controller().GetActiveEntry(); | 402 NavigationEntry* entry1 = tab->controller().GetActiveEntry(); |
400 ASSERT_TRUE(entry1); | 403 ASSERT_TRUE(entry1); |
401 ui_test_utils::NavigateToURL(browser(), | 404 ui_test_utils::NavigateToURL(browser(), |
402 test_server()->GetURL("files/ssl/blank_page.html")); | 405 test_server()->GetURL("files/ssl/blank_page.html")); |
403 NavigationEntry* entry2 = tab->controller().GetActiveEntry(); | 406 NavigationEntry* entry2 = tab->controller().GetActiveEntry(); |
404 ASSERT_TRUE(entry2); | 407 ASSERT_TRUE(entry2); |
405 | 408 |
406 // Now go back so that a page is in the forward history. | 409 // Now go back so that a page is in the forward history. |
407 tab->controller().GoBack(); | 410 { |
408 ui_test_utils::WaitForNavigation(&(tab->controller())); | 411 ui_test_utils::WindowedNotificationObserver observer( |
| 412 content::NOTIFICATION_LOAD_STOP, |
| 413 Source<NavigationController>(&tab->controller())); |
| 414 tab->controller().GoBack(); |
| 415 observer.Wait(); |
| 416 } |
409 ASSERT_TRUE(tab->controller().CanGoForward()); | 417 ASSERT_TRUE(tab->controller().CanGoForward()); |
410 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); | 418 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); |
411 ASSERT_TRUE(entry1 == entry3); | 419 ASSERT_TRUE(entry1 == entry3); |
412 | 420 |
413 // Now go to a bad HTTPS page that shows an interstitial. | 421 // Now go to a bad HTTPS page that shows an interstitial. |
414 ui_test_utils::NavigateToURL(browser(), | 422 ui_test_utils::NavigateToURL(browser(), |
415 https_server_expired_.GetURL("files/ssl/google.html")); | 423 https_server_expired_.GetURL("files/ssl/google.html")); |
416 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 424 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
417 true); // Interstitial showing | 425 true); // Interstitial showing |
418 | 426 |
419 // Simulate user clicking and holding on forward button. | 427 // Simulate user clicking and holding on forward button. |
420 tab->controller().GoToOffset(1); | 428 { |
421 ui_test_utils::WaitForNavigation(&(tab->controller())); | 429 ui_test_utils::WindowedNotificationObserver observer( |
| 430 content::NOTIFICATION_LOAD_STOP, |
| 431 Source<NavigationController>(&tab->controller())); |
| 432 tab->controller().GoToOffset(1); |
| 433 observer.Wait(); |
| 434 } |
422 | 435 |
423 // We should be showing the second good page. | 436 // We should be showing the second good page. |
424 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); | 437 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); |
425 CheckUnauthenticatedState(tab); | 438 CheckUnauthenticatedState(tab); |
426 EXPECT_FALSE(tab->controller().CanGoForward()); | 439 EXPECT_FALSE(tab->controller().CanGoForward()); |
427 NavigationEntry* entry4 = tab->controller().GetActiveEntry(); | 440 NavigationEntry* entry4 = tab->controller().GetActiveEntry(); |
428 EXPECT_TRUE(entry2 == entry4); | 441 EXPECT_TRUE(entry2 == entry4); |
429 } | 442 } |
430 | 443 |
431 // Open a page with a HTTPS error in a tab with no prior navigation (through a | 444 // Open a page with a HTTPS error in a tab with no prior navigation (through a |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 588 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
576 "files/ssl/page_displays_insecure_content.html", | 589 "files/ssl/page_displays_insecure_content.html", |
577 test_server()->host_port_pair(), | 590 test_server()->host_port_pair(), |
578 &replacement_path)); | 591 &replacement_path)); |
579 | 592 |
580 GURL url = https_server_.GetURL(replacement_path); | 593 GURL url = https_server_.GetURL(replacement_path); |
581 browser::NavigateParams params(browser(), url, PageTransition::TYPED); | 594 browser::NavigateParams params(browser(), url, PageTransition::TYPED); |
582 params.disposition = NEW_FOREGROUND_TAB; | 595 params.disposition = NEW_FOREGROUND_TAB; |
583 params.tabstrip_index = 0; | 596 params.tabstrip_index = 0; |
584 params.source_contents = tab1; | 597 params.source_contents = tab1; |
| 598 ui_test_utils::WindowedNotificationObserver observer( |
| 599 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
585 browser::Navigate(¶ms); | 600 browser::Navigate(¶ms); |
586 TabContentsWrapper* tab2 = params.target_contents; | 601 TabContentsWrapper* tab2 = params.target_contents; |
587 ui_test_utils::WaitForNavigation(&(tab2->controller())); | 602 observer.Wait(); |
588 | 603 |
589 // The new tab has insecure content. | 604 // The new tab has insecure content. |
590 CheckAuthenticatedState(tab2->tab_contents(), true); | 605 CheckAuthenticatedState(tab2->tab_contents(), true); |
591 | 606 |
592 // The original tab should not be contaminated. | 607 // The original tab should not be contaminated. |
593 CheckAuthenticatedState(tab1->tab_contents(), false); | 608 CheckAuthenticatedState(tab1->tab_contents(), false); |
594 } | 609 } |
595 | 610 |
596 // 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 |
597 // 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... |
612 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 627 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( |
613 "files/ssl/page_runs_insecure_content.html", | 628 "files/ssl/page_runs_insecure_content.html", |
614 test_server()->host_port_pair(), | 629 test_server()->host_port_pair(), |
615 &replacement_path)); | 630 &replacement_path)); |
616 | 631 |
617 // Create a new tab. | 632 // Create a new tab. |
618 GURL url = https_server_.GetURL(replacement_path); | 633 GURL url = https_server_.GetURL(replacement_path); |
619 browser::NavigateParams params(browser(), url, PageTransition::TYPED); | 634 browser::NavigateParams params(browser(), url, PageTransition::TYPED); |
620 params.disposition = NEW_FOREGROUND_TAB; | 635 params.disposition = NEW_FOREGROUND_TAB; |
621 params.source_contents = tab1; | 636 params.source_contents = tab1; |
| 637 ui_test_utils::WindowedNotificationObserver observer( |
| 638 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
622 browser::Navigate(¶ms); | 639 browser::Navigate(¶ms); |
623 TabContentsWrapper* tab2 = params.target_contents; | 640 TabContentsWrapper* tab2 = params.target_contents; |
624 ui_test_utils::WaitForNavigation(&(tab2->controller())); | 641 observer.Wait(); |
625 | 642 |
626 // The new tab has insecure content. | 643 // The new tab has insecure content. |
627 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); | 644 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); |
628 | 645 |
629 // Which means the origin for the first tab has also been contaminated with | 646 // Which means the origin for the first tab has also been contaminated with |
630 // insecure content. | 647 // insecure content. |
631 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false); | 648 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false); |
632 } | 649 } |
633 | 650 |
634 // Visits a page with an image over http. Visits another page over https | 651 // 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... |
785 break; | 802 break; |
786 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 803 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
787 new MessageLoop::QuitTask(), 1000); | 804 new MessageLoop::QuitTask(), 1000); |
788 ui_test_utils::RunMessageLoop(); | 805 ui_test_utils::RunMessageLoop(); |
789 } | 806 } |
790 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); | 807 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); |
791 | 808 |
792 // Let's add another tab to make sure the browser does not exit when we close | 809 // Let's add another tab to make sure the browser does not exit when we close |
793 // the first tab. | 810 // the first tab. |
794 GURL url = test_server()->GetURL("files/ssl/google.html"); | 811 GURL url = test_server()->GetURL("files/ssl/google.html"); |
795 TabContentsWrapper* tab2 = | 812 ui_test_utils::WindowedNotificationObserver observer( |
796 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); | 813 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources()); |
797 ui_test_utils::WaitForNavigation(&(tab2->controller())); | 814 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); |
| 815 observer.Wait(); |
798 | 816 |
799 // Close the first tab. | 817 // Close the first tab. |
800 browser()->CloseTabContents(tab1); | 818 browser()->CloseTabContents(tab1); |
801 } | 819 } |
802 | 820 |
803 // Visit a page over bad https that is a redirect to a page with good https. | 821 // Visit a page over bad https that is a redirect to a page with good https. |
804 // Crashes: http://crbug.com/77374 | 822 // Crashes: http://crbug.com/77374 |
805 // Previously marked as flaky: http://crbug.com/40932 | 823 // Previously marked as flaky: http://crbug.com/40932 |
806 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestRedirectBadToGoodHTTPS) { | 824 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestRedirectBadToGoodHTTPS) { |
807 ASSERT_TRUE(https_server_.Start()); | 825 ASSERT_TRUE(https_server_.Start()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 &top_frame_path)); | 948 &top_frame_path)); |
931 | 949 |
932 TabContents* tab = browser()->GetSelectedTabContents(); | 950 TabContents* tab = browser()->GetSelectedTabContents(); |
933 ui_test_utils::NavigateToURL(browser(), | 951 ui_test_utils::NavigateToURL(browser(), |
934 https_server_.GetURL(top_frame_path)); | 952 https_server_.GetURL(top_frame_path)); |
935 | 953 |
936 CheckAuthenticatedState(tab, false); | 954 CheckAuthenticatedState(tab, false); |
937 | 955 |
938 bool success = false; | 956 bool success = false; |
939 // Now navigate inside the frame. | 957 // Now navigate inside the frame. |
940 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 958 { |
941 tab->render_view_host(), std::wstring(), | 959 ui_test_utils::WindowedNotificationObserver observer( |
942 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | 960 content::NOTIFICATION_LOAD_STOP, |
943 &success)); | 961 Source<NavigationController>(&tab->controller())); |
944 EXPECT_TRUE(success); | 962 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
945 ui_test_utils::WaitForNavigation(&tab->controller()); | 963 tab->render_view_host(), std::wstring(), |
| 964 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| 965 &success)); |
| 966 ASSERT_TRUE(success); |
| 967 observer.Wait(); |
| 968 } |
946 | 969 |
947 // We should still be fine. | 970 // We should still be fine. |
948 CheckAuthenticatedState(tab, false); | 971 CheckAuthenticatedState(tab, false); |
949 | 972 |
950 // Now let's hit a bad page. | 973 // Now let's hit a bad page. |
951 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 974 { |
952 tab->render_view_host(), std::wstring(), | 975 ui_test_utils::WindowedNotificationObserver observer( |
953 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", | 976 content::NOTIFICATION_LOAD_STOP, |
954 &success)); | 977 Source<NavigationController>(&tab->controller())); |
955 EXPECT_TRUE(success); | 978 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
956 ui_test_utils::WaitForNavigation(&tab->controller()); | 979 tab->render_view_host(), std::wstring(), |
| 980 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| 981 &success)); |
| 982 ASSERT_TRUE(success); |
| 983 observer.Wait(); |
| 984 } |
957 | 985 |
958 // The security style should still be secure. | 986 // The security style should still be secure. |
959 CheckAuthenticatedState(tab, false); | 987 CheckAuthenticatedState(tab, false); |
960 | 988 |
961 // And the frame should be blocked. | 989 // And the frame should be blocked. |
962 bool is_content_evil = true; | 990 bool is_content_evil = true; |
963 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); | 991 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); |
964 std::wstring is_evil_js(L"window.domAutomationController.send(" | 992 std::wstring is_evil_js(L"window.domAutomationController.send(" |
965 L"document.getElementById('evilDiv') != null);"); | 993 L"document.getElementById('evilDiv') != null);"); |
966 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 994 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
967 tab->render_view_host(), content_frame_xpath, is_evil_js, | 995 tab->render_view_host(), content_frame_xpath, is_evil_js, |
968 &is_content_evil)); | 996 &is_content_evil)); |
969 EXPECT_FALSE(is_content_evil); | 997 EXPECT_FALSE(is_content_evil); |
970 | 998 |
971 // Now go back, our state should still be OK. | 999 // Now go back, our state should still be OK. |
972 tab->controller().GoBack(); | 1000 { |
973 ui_test_utils::WaitForNavigation(&tab->controller()); | 1001 ui_test_utils::WindowedNotificationObserver observer( |
| 1002 content::NOTIFICATION_LOAD_STOP, |
| 1003 Source<NavigationController>(&tab->controller())); |
| 1004 tab->controller().GoBack(); |
| 1005 observer.Wait(); |
| 1006 } |
974 CheckAuthenticatedState(tab, false); | 1007 CheckAuthenticatedState(tab, false); |
975 | 1008 |
976 // Navigate to a page served over HTTP. | 1009 // Navigate to a page served over HTTP. |
977 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1010 { |
978 tab->render_view_host(), std::wstring(), | 1011 ui_test_utils::WindowedNotificationObserver observer( |
979 L"window.domAutomationController.send(clickLink('HTTPLink'));", | 1012 content::NOTIFICATION_LOAD_STOP, |
980 &success)); | 1013 Source<NavigationController>(&tab->controller())); |
981 EXPECT_TRUE(success); | 1014 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
982 ui_test_utils::WaitForNavigation(&tab->controller()); | 1015 tab->render_view_host(), std::wstring(), |
| 1016 L"window.domAutomationController.send(clickLink('HTTPLink'));", |
| 1017 &success)); |
| 1018 ASSERT_TRUE(success); |
| 1019 observer.Wait(); |
| 1020 } |
983 | 1021 |
984 // Our state should be insecure. | 1022 // Our state should be insecure. |
985 CheckAuthenticatedState(tab, true); | 1023 CheckAuthenticatedState(tab, true); |
986 | 1024 |
987 // Go back, our state should be unchanged. | 1025 // Go back, our state should be unchanged. |
988 tab->controller().GoBack(); | 1026 { |
989 ui_test_utils::WaitForNavigation(&tab->controller()); | 1027 ui_test_utils::WindowedNotificationObserver observer( |
| 1028 content::NOTIFICATION_LOAD_STOP, |
| 1029 Source<NavigationController>(&tab->controller())); |
| 1030 tab->controller().GoBack(); |
| 1031 observer.Wait(); |
| 1032 } |
990 CheckAuthenticatedState(tab, true); | 1033 CheckAuthenticatedState(tab, true); |
991 } | 1034 } |
992 | 1035 |
993 // From a bad HTTPS top frame: | 1036 // From a bad HTTPS top frame: |
994 // - navigate to an OK HTTPS frame (expected to be still authentication broken). | 1037 // - navigate to an OK HTTPS frame (expected to be still authentication broken). |
995 // Marked as flaky, see bug 40932. | 1038 // Marked as flaky, see bug 40932. |
996 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { | 1039 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { |
997 ASSERT_TRUE(https_server_.Start()); | 1040 ASSERT_TRUE(https_server_.Start()); |
998 ASSERT_TRUE(https_server_expired_.Start()); | 1041 ASSERT_TRUE(https_server_expired_.Start()); |
999 | 1042 |
1000 std::string top_frame_path; | 1043 std::string top_frame_path; |
1001 ASSERT_TRUE(GetTopFramePath(*test_server(), | 1044 ASSERT_TRUE(GetTopFramePath(*test_server(), |
1002 https_server_, | 1045 https_server_, |
1003 https_server_expired_, | 1046 https_server_expired_, |
1004 &top_frame_path)); | 1047 &top_frame_path)); |
1005 | 1048 |
1006 TabContents* tab = browser()->GetSelectedTabContents(); | 1049 TabContents* tab = browser()->GetSelectedTabContents(); |
1007 ui_test_utils::NavigateToURL(browser(), | 1050 ui_test_utils::NavigateToURL(browser(), |
1008 https_server_expired_.GetURL(top_frame_path)); | 1051 https_server_expired_.GetURL(top_frame_path)); |
1009 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 1052 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
1010 true); // Interstitial showing | 1053 true); // Interstitial showing |
1011 | 1054 |
1012 ProceedThroughInterstitial(tab); | 1055 ProceedThroughInterstitial(tab); |
1013 | 1056 |
1014 // Navigate to a good frame. | 1057 // Navigate to a good frame. |
1015 bool success = false; | 1058 bool success = false; |
| 1059 ui_test_utils::WindowedNotificationObserver observer( |
| 1060 content::NOTIFICATION_LOAD_STOP, |
| 1061 Source<NavigationController>(&tab->controller())); |
1016 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1062 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
1017 tab->render_view_host(), std::wstring(), | 1063 tab->render_view_host(), std::wstring(), |
1018 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | 1064 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
1019 &success)); | 1065 &success)); |
1020 EXPECT_TRUE(success); | 1066 ASSERT_TRUE(success); |
1021 ui_test_utils::WaitForNavigation(&tab->controller()); | 1067 observer.Wait(); |
1022 | 1068 |
1023 // We should still be authentication broken. | 1069 // We should still be authentication broken. |
1024 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, | 1070 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, |
1025 false); | 1071 false); |
1026 } | 1072 } |
1027 | 1073 |
1028 // From an HTTP top frame, navigate to good and bad HTTPS (security state should | 1074 // From an HTTP top frame, navigate to good and bad HTTPS (security state should |
1029 // stay unauthenticated). | 1075 // stay unauthenticated). |
1030 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. | 1076 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. |
1031 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { | 1077 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { |
1032 ASSERT_TRUE(test_server()->Start()); | 1078 ASSERT_TRUE(test_server()->Start()); |
1033 ASSERT_TRUE(https_server_.Start()); | 1079 ASSERT_TRUE(https_server_.Start()); |
1034 ASSERT_TRUE(https_server_expired_.Start()); | 1080 ASSERT_TRUE(https_server_expired_.Start()); |
1035 | 1081 |
1036 std::string top_frame_path; | 1082 std::string top_frame_path; |
1037 ASSERT_TRUE(GetTopFramePath(*test_server(), | 1083 ASSERT_TRUE(GetTopFramePath(*test_server(), |
1038 https_server_, | 1084 https_server_, |
1039 https_server_expired_, | 1085 https_server_expired_, |
1040 &top_frame_path)); | 1086 &top_frame_path)); |
1041 | 1087 |
1042 TabContents* tab = browser()->GetSelectedTabContents(); | 1088 TabContents* tab = browser()->GetSelectedTabContents(); |
1043 ui_test_utils::NavigateToURL(browser(), | 1089 ui_test_utils::NavigateToURL(browser(), |
1044 test_server()->GetURL(top_frame_path)); | 1090 test_server()->GetURL(top_frame_path)); |
1045 CheckUnauthenticatedState(tab); | 1091 CheckUnauthenticatedState(tab); |
1046 | 1092 |
1047 // Now navigate inside the frame to a secure HTTPS frame. | 1093 // Now navigate inside the frame to a secure HTTPS frame. |
1048 bool success = false; | 1094 { |
1049 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1095 bool success = false; |
1050 tab->render_view_host(), std::wstring(), | 1096 ui_test_utils::WindowedNotificationObserver observer( |
1051 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", | 1097 content::NOTIFICATION_LOAD_STOP, |
1052 &success)); | 1098 Source<NavigationController>(&tab->controller())); |
1053 EXPECT_TRUE(success); | 1099 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
1054 ui_test_utils::WaitForNavigation(&tab->controller()); | 1100 tab->render_view_host(), std::wstring(), |
| 1101 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", |
| 1102 &success)); |
| 1103 ASSERT_TRUE(success); |
| 1104 observer.Wait(); |
| 1105 } |
1055 | 1106 |
1056 // We should still be unauthenticated. | 1107 // We should still be unauthenticated. |
1057 CheckUnauthenticatedState(tab); | 1108 CheckUnauthenticatedState(tab); |
1058 | 1109 |
1059 // Now navigate to a bad HTTPS frame. | 1110 // Now navigate to a bad HTTPS frame. |
1060 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1111 { |
1061 tab->render_view_host(), std::wstring(), | 1112 bool success = false; |
1062 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", | 1113 ui_test_utils::WindowedNotificationObserver observer( |
1063 &success)); | 1114 content::NOTIFICATION_LOAD_STOP, |
1064 EXPECT_TRUE(success); | 1115 Source<NavigationController>(&tab->controller())); |
1065 ui_test_utils::WaitForNavigation(&tab->controller()); | 1116 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 1117 tab->render_view_host(), std::wstring(), |
| 1118 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", |
| 1119 &success)); |
| 1120 ASSERT_TRUE(success); |
| 1121 observer.Wait(); |
| 1122 } |
1066 | 1123 |
1067 // State should not have changed. | 1124 // State should not have changed. |
1068 CheckUnauthenticatedState(tab); | 1125 CheckUnauthenticatedState(tab); |
1069 | 1126 |
1070 // And the frame should have been blocked (see bug #2316). | 1127 // And the frame should have been blocked (see bug #2316). |
1071 bool is_content_evil = true; | 1128 bool is_content_evil = true; |
1072 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); | 1129 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); |
1073 std::wstring is_evil_js(L"window.domAutomationController.send(" | 1130 std::wstring is_evil_js(L"window.domAutomationController.send(" |
1074 L"document.getElementById('evilDiv') != null);"); | 1131 L"document.getElementById('evilDiv') != null);"); |
1075 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 1132 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 | 1225 |
1169 // Visit a page over https that contains a frame with a redirect. | 1226 // Visit a page over https that contains a frame with a redirect. |
1170 | 1227 |
1171 // XMLHttpRequest insecure content in synchronous mode. | 1228 // XMLHttpRequest insecure content in synchronous mode. |
1172 | 1229 |
1173 // XMLHttpRequest insecure content in asynchronous mode. | 1230 // XMLHttpRequest insecure content in asynchronous mode. |
1174 | 1231 |
1175 // XMLHttpRequest over bad ssl in synchronous mode. | 1232 // XMLHttpRequest over bad ssl in synchronous mode. |
1176 | 1233 |
1177 // XMLHttpRequest over OK ssl in synchronous mode. | 1234 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |