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

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

Powered by Google App Engine
This is Rietveld 408576698