Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 7489019: Fix up various browser tests not to use WaitForNavigation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix nits Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 test_server()->GetURL("files/ssl/google.html")); 407 test_server()->GetURL("files/ssl/google.html"));
405 TabContents* tab = browser()->GetSelectedTabContents(); 408 TabContents* tab = browser()->GetSelectedTabContents();
406 NavigationEntry* entry1 = tab->controller().GetActiveEntry(); 409 NavigationEntry* entry1 = tab->controller().GetActiveEntry();
407 ASSERT_TRUE(entry1); 410 ASSERT_TRUE(entry1);
408 ui_test_utils::NavigateToURL(browser(), 411 ui_test_utils::NavigateToURL(browser(),
409 test_server()->GetURL("files/ssl/blank_page.html")); 412 test_server()->GetURL("files/ssl/blank_page.html"));
410 NavigationEntry* entry2 = tab->controller().GetActiveEntry(); 413 NavigationEntry* entry2 = tab->controller().GetActiveEntry();
411 ASSERT_TRUE(entry2); 414 ASSERT_TRUE(entry2);
412 415
413 // Now go back so that a page is in the forward history. 416 // Now go back so that a page is in the forward history.
414 tab->controller().GoBack(); 417 {
415 ui_test_utils::WaitForNavigation(&(tab->controller())); 418 ui_test_utils::WindowedNotificationObserver observer(
419 content::NOTIFICATION_LOAD_STOP,
420 Source<NavigationController>(&tab->controller()));
421 tab->controller().GoBack();
422 observer.Wait();
423 }
416 ASSERT_TRUE(tab->controller().CanGoForward()); 424 ASSERT_TRUE(tab->controller().CanGoForward());
417 NavigationEntry* entry3 = tab->controller().GetActiveEntry(); 425 NavigationEntry* entry3 = tab->controller().GetActiveEntry();
418 ASSERT_TRUE(entry1 == entry3); 426 ASSERT_TRUE(entry1 == entry3);
419 427
420 // Now go to a bad HTTPS page that shows an interstitial. 428 // Now go to a bad HTTPS page that shows an interstitial.
421 ui_test_utils::NavigateToURL(browser(), 429 ui_test_utils::NavigateToURL(browser(),
422 https_server_expired_.GetURL("files/ssl/google.html")); 430 https_server_expired_.GetURL("files/ssl/google.html"));
423 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 431 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
424 true); // Interstitial showing 432 true); // Interstitial showing
425 433
426 // Simulate user clicking and holding on forward button. 434 // Simulate user clicking and holding on forward button.
427 tab->controller().GoToOffset(1); 435 {
428 ui_test_utils::WaitForNavigation(&(tab->controller())); 436 ui_test_utils::WindowedNotificationObserver observer(
437 content::NOTIFICATION_LOAD_STOP,
438 Source<NavigationController>(&tab->controller()));
439 tab->controller().GoToOffset(1);
440 observer.Wait();
441 }
429 442
430 // We should be showing the second good page. 443 // We should be showing the second good page.
431 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page()); 444 EXPECT_FALSE(browser()->GetSelectedTabContents()->interstitial_page());
432 CheckUnauthenticatedState(tab); 445 CheckUnauthenticatedState(tab);
433 EXPECT_FALSE(tab->controller().CanGoForward()); 446 EXPECT_FALSE(tab->controller().CanGoForward());
434 NavigationEntry* entry4 = tab->controller().GetActiveEntry(); 447 NavigationEntry* entry4 = tab->controller().GetActiveEntry();
435 EXPECT_TRUE(entry2 == entry4); 448 EXPECT_TRUE(entry2 == entry4);
436 } 449 }
437 450
438 // Flaky on CrOS http://crbug.com/92292 451 // Flaky on CrOS http://crbug.com/92292
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 603 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
591 "files/ssl/page_displays_insecure_content.html", 604 "files/ssl/page_displays_insecure_content.html",
592 test_server()->host_port_pair(), 605 test_server()->host_port_pair(),
593 &replacement_path)); 606 &replacement_path));
594 607
595 GURL url = https_server_.GetURL(replacement_path); 608 GURL url = https_server_.GetURL(replacement_path);
596 browser::NavigateParams params(browser(), url, PageTransition::TYPED); 609 browser::NavigateParams params(browser(), url, PageTransition::TYPED);
597 params.disposition = NEW_FOREGROUND_TAB; 610 params.disposition = NEW_FOREGROUND_TAB;
598 params.tabstrip_index = 0; 611 params.tabstrip_index = 0;
599 params.source_contents = tab1; 612 params.source_contents = tab1;
613 ui_test_utils::WindowedNotificationObserver observer(
614 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
600 browser::Navigate(&params); 615 browser::Navigate(&params);
601 TabContentsWrapper* tab2 = params.target_contents; 616 TabContentsWrapper* tab2 = params.target_contents;
602 ui_test_utils::WaitForNavigation(&(tab2->controller())); 617 observer.Wait();
603 618
604 // The new tab has insecure content. 619 // The new tab has insecure content.
605 CheckAuthenticatedState(tab2->tab_contents(), true); 620 CheckAuthenticatedState(tab2->tab_contents(), true);
606 621
607 // The original tab should not be contaminated. 622 // The original tab should not be contaminated.
608 CheckAuthenticatedState(tab1->tab_contents(), false); 623 CheckAuthenticatedState(tab1->tab_contents(), false);
609 } 624 }
610 625
611 // Visits two pages from the same origin: one that runs insecure content and one 626 // Visits two pages from the same origin: one that runs insecure content and one
612 // that doesn't. The test checks that we propagate the insecure content state 627 // that doesn't. The test checks that we propagate the insecure content state
(...skipping 14 matching lines...) Expand all
627 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 642 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
628 "files/ssl/page_runs_insecure_content.html", 643 "files/ssl/page_runs_insecure_content.html",
629 test_server()->host_port_pair(), 644 test_server()->host_port_pair(),
630 &replacement_path)); 645 &replacement_path));
631 646
632 // Create a new tab. 647 // Create a new tab.
633 GURL url = https_server_.GetURL(replacement_path); 648 GURL url = https_server_.GetURL(replacement_path);
634 browser::NavigateParams params(browser(), url, PageTransition::TYPED); 649 browser::NavigateParams params(browser(), url, PageTransition::TYPED);
635 params.disposition = NEW_FOREGROUND_TAB; 650 params.disposition = NEW_FOREGROUND_TAB;
636 params.source_contents = tab1; 651 params.source_contents = tab1;
652 ui_test_utils::WindowedNotificationObserver observer(
653 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
637 browser::Navigate(&params); 654 browser::Navigate(&params);
638 TabContentsWrapper* tab2 = params.target_contents; 655 TabContentsWrapper* tab2 = params.target_contents;
639 ui_test_utils::WaitForNavigation(&(tab2->controller())); 656 observer.Wait();
640 657
641 // The new tab has insecure content. 658 // The new tab has insecure content.
642 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false); 659 CheckAuthenticationBrokenState(tab2->tab_contents(), 0, true, false);
643 660
644 // Which means the origin for the first tab has also been contaminated with 661 // Which means the origin for the first tab has also been contaminated with
645 // insecure content. 662 // insecure content.
646 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false); 663 CheckAuthenticationBrokenState(tab1->tab_contents(), 0, true, false);
647 } 664 }
648 665
649 // Visits a page with an image over http. Visits another page over https 666 // 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
800 break; 817 break;
801 MessageLoop::current()->PostDelayedTask(FROM_HERE, 818 MessageLoop::current()->PostDelayedTask(FROM_HERE,
802 new MessageLoop::QuitTask(), 1000); 819 new MessageLoop::QuitTask(), 1000);
803 ui_test_utils::RunMessageLoop(); 820 ui_test_utils::RunMessageLoop();
804 } 821 }
805 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count())); 822 ASSERT_EQ(1, static_cast<int>(tab1->constrained_window_count()));
806 823
807 // Let's add another tab to make sure the browser does not exit when we close 824 // Let's add another tab to make sure the browser does not exit when we close
808 // the first tab. 825 // the first tab.
809 GURL url = test_server()->GetURL("files/ssl/google.html"); 826 GURL url = test_server()->GetURL("files/ssl/google.html");
810 TabContentsWrapper* tab2 = 827 ui_test_utils::WindowedNotificationObserver observer(
811 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); 828 content::NOTIFICATION_LOAD_STOP, NotificationService::AllSources());
812 ui_test_utils::WaitForNavigation(&(tab2->controller())); 829 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED);
830 observer.Wait();
813 831
814 // Close the first tab. 832 // Close the first tab.
815 browser()->CloseTabContents(tab1); 833 browser()->CloseTabContents(tab1);
816 } 834 }
817 835
818 // Visit a page over bad https that is a redirect to a page with good https. 836 // Visit a page over bad https that is a redirect to a page with good https.
819 // Crashes: http://crbug.com/77374 837 // Crashes: http://crbug.com/77374
820 // Previously marked as flaky: http://crbug.com/40932 838 // Previously marked as flaky: http://crbug.com/40932
821 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestRedirectBadToGoodHTTPS) { 839 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestRedirectBadToGoodHTTPS) {
822 ASSERT_TRUE(https_server_.Start()); 840 ASSERT_TRUE(https_server_.Start());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 &top_frame_path)); 963 &top_frame_path));
946 964
947 TabContents* tab = browser()->GetSelectedTabContents(); 965 TabContents* tab = browser()->GetSelectedTabContents();
948 ui_test_utils::NavigateToURL(browser(), 966 ui_test_utils::NavigateToURL(browser(),
949 https_server_.GetURL(top_frame_path)); 967 https_server_.GetURL(top_frame_path));
950 968
951 CheckAuthenticatedState(tab, false); 969 CheckAuthenticatedState(tab, false);
952 970
953 bool success = false; 971 bool success = false;
954 // Now navigate inside the frame. 972 // Now navigate inside the frame.
955 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 973 {
956 tab->render_view_host(), std::wstring(), 974 ui_test_utils::WindowedNotificationObserver observer(
957 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 975 content::NOTIFICATION_LOAD_STOP,
958 &success)); 976 Source<NavigationController>(&tab->controller()));
959 EXPECT_TRUE(success); 977 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
960 ui_test_utils::WaitForNavigation(&tab->controller()); 978 tab->render_view_host(), std::wstring(),
979 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
980 &success));
981 ASSERT_TRUE(success);
982 observer.Wait();
983 }
961 984
962 // We should still be fine. 985 // We should still be fine.
963 CheckAuthenticatedState(tab, false); 986 CheckAuthenticatedState(tab, false);
964 987
965 // Now let's hit a bad page. 988 // Now let's hit a bad page.
966 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 989 {
967 tab->render_view_host(), std::wstring(), 990 ui_test_utils::WindowedNotificationObserver observer(
968 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", 991 content::NOTIFICATION_LOAD_STOP,
969 &success)); 992 Source<NavigationController>(&tab->controller()));
970 EXPECT_TRUE(success); 993 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
971 ui_test_utils::WaitForNavigation(&tab->controller()); 994 tab->render_view_host(), std::wstring(),
995 L"window.domAutomationController.send(clickLink('badHTTPSLink'));",
996 &success));
997 ASSERT_TRUE(success);
998 observer.Wait();
999 }
972 1000
973 // The security style should still be secure. 1001 // The security style should still be secure.
974 CheckAuthenticatedState(tab, false); 1002 CheckAuthenticatedState(tab, false);
975 1003
976 // And the frame should be blocked. 1004 // And the frame should be blocked.
977 bool is_content_evil = true; 1005 bool is_content_evil = true;
978 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); 1006 std::wstring content_frame_xpath(L"html/frameset/frame[2]");
979 std::wstring is_evil_js(L"window.domAutomationController.send(" 1007 std::wstring is_evil_js(L"window.domAutomationController.send("
980 L"document.getElementById('evilDiv') != null);"); 1008 L"document.getElementById('evilDiv') != null);");
981 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1009 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
982 tab->render_view_host(), content_frame_xpath, is_evil_js, 1010 tab->render_view_host(), content_frame_xpath, is_evil_js,
983 &is_content_evil)); 1011 &is_content_evil));
984 EXPECT_FALSE(is_content_evil); 1012 EXPECT_FALSE(is_content_evil);
985 1013
986 // Now go back, our state should still be OK. 1014 // Now go back, our state should still be OK.
987 tab->controller().GoBack(); 1015 {
988 ui_test_utils::WaitForNavigation(&tab->controller()); 1016 ui_test_utils::WindowedNotificationObserver observer(
1017 content::NOTIFICATION_LOAD_STOP,
1018 Source<NavigationController>(&tab->controller()));
1019 tab->controller().GoBack();
1020 observer.Wait();
1021 }
989 CheckAuthenticatedState(tab, false); 1022 CheckAuthenticatedState(tab, false);
990 1023
991 // Navigate to a page served over HTTP. 1024 // Navigate to a page served over HTTP.
992 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1025 {
993 tab->render_view_host(), std::wstring(), 1026 ui_test_utils::WindowedNotificationObserver observer(
994 L"window.domAutomationController.send(clickLink('HTTPLink'));", 1027 content::NOTIFICATION_LOAD_STOP,
995 &success)); 1028 Source<NavigationController>(&tab->controller()));
996 EXPECT_TRUE(success); 1029 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
997 ui_test_utils::WaitForNavigation(&tab->controller()); 1030 tab->render_view_host(), std::wstring(),
1031 L"window.domAutomationController.send(clickLink('HTTPLink'));",
1032 &success));
1033 ASSERT_TRUE(success);
1034 observer.Wait();
1035 }
998 1036
999 // Our state should be insecure. 1037 // Our state should be insecure.
1000 CheckAuthenticatedState(tab, true); 1038 CheckAuthenticatedState(tab, true);
1001 1039
1002 // Go back, our state should be unchanged. 1040 // Go back, our state should be unchanged.
1003 tab->controller().GoBack(); 1041 {
1004 ui_test_utils::WaitForNavigation(&tab->controller()); 1042 ui_test_utils::WindowedNotificationObserver observer(
1043 content::NOTIFICATION_LOAD_STOP,
1044 Source<NavigationController>(&tab->controller()));
1045 tab->controller().GoBack();
1046 observer.Wait();
1047 }
1005 CheckAuthenticatedState(tab, true); 1048 CheckAuthenticatedState(tab, true);
1006 } 1049 }
1007 1050
1008 // From a bad HTTPS top frame: 1051 // From a bad HTTPS top frame:
1009 // - navigate to an OK HTTPS frame (expected to be still authentication broken). 1052 // - navigate to an OK HTTPS frame (expected to be still authentication broken).
1010 // Marked as flaky, see bug 40932. 1053 // Marked as flaky, see bug 40932.
1011 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { 1054 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) {
1012 ASSERT_TRUE(https_server_.Start()); 1055 ASSERT_TRUE(https_server_.Start());
1013 ASSERT_TRUE(https_server_expired_.Start()); 1056 ASSERT_TRUE(https_server_expired_.Start());
1014 1057
1015 std::string top_frame_path; 1058 std::string top_frame_path;
1016 ASSERT_TRUE(GetTopFramePath(*test_server(), 1059 ASSERT_TRUE(GetTopFramePath(*test_server(),
1017 https_server_, 1060 https_server_,
1018 https_server_expired_, 1061 https_server_expired_,
1019 &top_frame_path)); 1062 &top_frame_path));
1020 1063
1021 TabContents* tab = browser()->GetSelectedTabContents(); 1064 TabContents* tab = browser()->GetSelectedTabContents();
1022 ui_test_utils::NavigateToURL(browser(), 1065 ui_test_utils::NavigateToURL(browser(),
1023 https_server_expired_.GetURL(top_frame_path)); 1066 https_server_expired_.GetURL(top_frame_path));
1024 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1067 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1025 true); // Interstitial showing 1068 true); // Interstitial showing
1026 1069
1027 ProceedThroughInterstitial(tab); 1070 ProceedThroughInterstitial(tab);
1028 1071
1029 // Navigate to a good frame. 1072 // Navigate to a good frame.
1030 bool success = false; 1073 bool success = false;
1074 ui_test_utils::WindowedNotificationObserver observer(
1075 content::NOTIFICATION_LOAD_STOP,
1076 Source<NavigationController>(&tab->controller()));
1031 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1077 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1032 tab->render_view_host(), std::wstring(), 1078 tab->render_view_host(), std::wstring(),
1033 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 1079 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
1034 &success)); 1080 &success));
1035 EXPECT_TRUE(success); 1081 ASSERT_TRUE(success);
1036 ui_test_utils::WaitForNavigation(&tab->controller()); 1082 observer.Wait();
1037 1083
1038 // We should still be authentication broken. 1084 // We should still be authentication broken.
1039 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1085 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1040 false); 1086 false);
1041 } 1087 }
1042 1088
1043 // From an HTTP top frame, navigate to good and bad HTTPS (security state should 1089 // From an HTTP top frame, navigate to good and bad HTTPS (security state should
1044 // stay unauthenticated). 1090 // stay unauthenticated).
1045 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. 1091 // Disabled, flakily exceeds test timeout, http://crbug.com/43437.
1046 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { 1092 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) {
1047 ASSERT_TRUE(test_server()->Start()); 1093 ASSERT_TRUE(test_server()->Start());
1048 ASSERT_TRUE(https_server_.Start()); 1094 ASSERT_TRUE(https_server_.Start());
1049 ASSERT_TRUE(https_server_expired_.Start()); 1095 ASSERT_TRUE(https_server_expired_.Start());
1050 1096
1051 std::string top_frame_path; 1097 std::string top_frame_path;
1052 ASSERT_TRUE(GetTopFramePath(*test_server(), 1098 ASSERT_TRUE(GetTopFramePath(*test_server(),
1053 https_server_, 1099 https_server_,
1054 https_server_expired_, 1100 https_server_expired_,
1055 &top_frame_path)); 1101 &top_frame_path));
1056 1102
1057 TabContents* tab = browser()->GetSelectedTabContents(); 1103 TabContents* tab = browser()->GetSelectedTabContents();
1058 ui_test_utils::NavigateToURL(browser(), 1104 ui_test_utils::NavigateToURL(browser(),
1059 test_server()->GetURL(top_frame_path)); 1105 test_server()->GetURL(top_frame_path));
1060 CheckUnauthenticatedState(tab); 1106 CheckUnauthenticatedState(tab);
1061 1107
1062 // Now navigate inside the frame to a secure HTTPS frame. 1108 // Now navigate inside the frame to a secure HTTPS frame.
1063 bool success = false; 1109 {
1064 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1110 bool success = false;
1065 tab->render_view_host(), std::wstring(), 1111 ui_test_utils::WindowedNotificationObserver observer(
1066 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 1112 content::NOTIFICATION_LOAD_STOP,
1067 &success)); 1113 Source<NavigationController>(&tab->controller()));
1068 EXPECT_TRUE(success); 1114 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1069 ui_test_utils::WaitForNavigation(&tab->controller()); 1115 tab->render_view_host(), std::wstring(),
1116 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
1117 &success));
1118 ASSERT_TRUE(success);
1119 observer.Wait();
1120 }
1070 1121
1071 // We should still be unauthenticated. 1122 // We should still be unauthenticated.
1072 CheckUnauthenticatedState(tab); 1123 CheckUnauthenticatedState(tab);
1073 1124
1074 // Now navigate to a bad HTTPS frame. 1125 // Now navigate to a bad HTTPS frame.
1075 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1126 {
1076 tab->render_view_host(), std::wstring(), 1127 bool success = false;
1077 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", 1128 ui_test_utils::WindowedNotificationObserver observer(
1078 &success)); 1129 content::NOTIFICATION_LOAD_STOP,
1079 EXPECT_TRUE(success); 1130 Source<NavigationController>(&tab->controller()));
1080 ui_test_utils::WaitForNavigation(&tab->controller()); 1131 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1132 tab->render_view_host(), std::wstring(),
1133 L"window.domAutomationController.send(clickLink('badHTTPSLink'));",
1134 &success));
1135 ASSERT_TRUE(success);
1136 observer.Wait();
1137 }
1081 1138
1082 // State should not have changed. 1139 // State should not have changed.
1083 CheckUnauthenticatedState(tab); 1140 CheckUnauthenticatedState(tab);
1084 1141
1085 // And the frame should have been blocked (see bug #2316). 1142 // And the frame should have been blocked (see bug #2316).
1086 bool is_content_evil = true; 1143 bool is_content_evil = true;
1087 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); 1144 std::wstring content_frame_xpath(L"html/frameset/frame[2]");
1088 std::wstring is_evil_js(L"window.domAutomationController.send(" 1145 std::wstring is_evil_js(L"window.domAutomationController.send("
1089 L"document.getElementById('evilDiv') != null);"); 1146 L"document.getElementById('evilDiv') != null);");
1090 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1147 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1240
1184 // Visit a page over https that contains a frame with a redirect. 1241 // Visit a page over https that contains a frame with a redirect.
1185 1242
1186 // XMLHttpRequest insecure content in synchronous mode. 1243 // XMLHttpRequest insecure content in synchronous mode.
1187 1244
1188 // XMLHttpRequest insecure content in asynchronous mode. 1245 // XMLHttpRequest insecure content in asynchronous mode.
1189 1246
1190 // XMLHttpRequest over bad ssl in synchronous mode. 1247 // XMLHttpRequest over bad ssl in synchronous mode.
1191 1248
1192 // XMLHttpRequest over OK ssl in synchronous mode. 1249 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/sidebar/sidebar_browsertest.cc ('k') | chrome/browser/ui/find_bar/find_bar_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698