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

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

Issue 8983012: Get rid of content::NavigationController in cc file and use "using" instead. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 11 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/constrained_window_tab_helper.h" 11 #include "chrome/browser/ui/constrained_window_tab_helper.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/tab_contents/interstitial_page.h" 18 #include "content/browser/tab_contents/interstitial_page.h"
19 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/ssl_status.h" 22 #include "content/public/browser/ssl_status.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/common/security_style.h" 24 #include "content/public/common/security_style.h"
25 #include "net/base/cert_status_flags.h" 25 #include "net/base/cert_status_flags.h"
26 #include "net/test/test_server.h" 26 #include "net/test/test_server.h"
27 27
28 using content::NavigationController;
28 using content::NavigationEntry; 29 using content::NavigationEntry;
29 using content::SSLStatus; 30 using content::SSLStatus;
30 using content::WebContents; 31 using content::WebContents;
31 32
32 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 33 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
33 34
34 class SSLUITest : public InProcessBrowserTest { 35 class SSLUITest : public InProcessBrowserTest {
35 typedef net::TestServer::HTTPSOptions HTTPSOptions; 36 typedef net::TestServer::HTTPSOptions HTTPSOptions;
36 37
37 public: 38 public:
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 L"window.domAutomationController.send(IsContentLoaded());", 135 L"window.domAutomationController.send(IsContentLoaded());",
135 &actuallyLoadedContent)); 136 &actuallyLoadedContent));
136 EXPECT_EQ(expectLoaded, actuallyLoadedContent); 137 EXPECT_EQ(expectLoaded, actuallyLoadedContent);
137 } 138 }
138 139
139 void ProceedThroughInterstitial(content::WebContents* tab) { 140 void ProceedThroughInterstitial(content::WebContents* tab) {
140 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 141 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
141 ASSERT_TRUE(interstitial_page); 142 ASSERT_TRUE(interstitial_page);
142 ui_test_utils::WindowedNotificationObserver observer( 143 ui_test_utils::WindowedNotificationObserver observer(
143 content::NOTIFICATION_LOAD_STOP, 144 content::NOTIFICATION_LOAD_STOP,
144 content::Source<content::NavigationController>(&tab->GetController())); 145 content::Source<NavigationController>(&tab->GetController()));
145 interstitial_page->Proceed(); 146 interstitial_page->Proceed();
146 observer.Wait(); 147 observer.Wait();
147 } 148 }
148 149
149 int GetConstrainedWindowCount() const { 150 int GetConstrainedWindowCount() const {
150 return static_cast<int>( 151 return static_cast<int>(
151 browser()->GetSelectedTabContentsWrapper()-> 152 browser()->GetSelectedTabContentsWrapper()->
152 constrained_window_tab_helper()->constrained_window_count()); 153 constrained_window_tab_helper()->constrained_window_count());
153 } 154 }
154 155
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 ASSERT_TRUE(entry1); 444 ASSERT_TRUE(entry1);
444 ui_test_utils::NavigateToURL(browser(), 445 ui_test_utils::NavigateToURL(browser(),
445 test_server()->GetURL("files/ssl/blank_page.html")); 446 test_server()->GetURL("files/ssl/blank_page.html"));
446 NavigationEntry* entry2 = tab->GetController().GetActiveEntry(); 447 NavigationEntry* entry2 = tab->GetController().GetActiveEntry();
447 ASSERT_TRUE(entry2); 448 ASSERT_TRUE(entry2);
448 449
449 // Now go back so that a page is in the forward history. 450 // Now go back so that a page is in the forward history.
450 { 451 {
451 ui_test_utils::WindowedNotificationObserver observer( 452 ui_test_utils::WindowedNotificationObserver observer(
452 content::NOTIFICATION_LOAD_STOP, 453 content::NOTIFICATION_LOAD_STOP,
453 content::Source<content::NavigationController>(&tab->GetController())); 454 content::Source<NavigationController>(&tab->GetController()));
454 tab->GetController().GoBack(); 455 tab->GetController().GoBack();
455 observer.Wait(); 456 observer.Wait();
456 } 457 }
457 ASSERT_TRUE(tab->GetController().CanGoForward()); 458 ASSERT_TRUE(tab->GetController().CanGoForward());
458 NavigationEntry* entry3 = tab->GetController().GetActiveEntry(); 459 NavigationEntry* entry3 = tab->GetController().GetActiveEntry();
459 ASSERT_TRUE(entry1 == entry3); 460 ASSERT_TRUE(entry1 == entry3);
460 461
461 // Now go to a bad HTTPS page that shows an interstitial. 462 // Now go to a bad HTTPS page that shows an interstitial.
462 ui_test_utils::NavigateToURL(browser(), 463 ui_test_utils::NavigateToURL(browser(),
463 https_server_expired_.GetURL("files/ssl/google.html")); 464 https_server_expired_.GetURL("files/ssl/google.html"));
464 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 465 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
465 true); // Interstitial showing 466 true); // Interstitial showing
466 467
467 // Simulate user clicking and holding on forward button. 468 // Simulate user clicking and holding on forward button.
468 { 469 {
469 ui_test_utils::WindowedNotificationObserver observer( 470 ui_test_utils::WindowedNotificationObserver observer(
470 content::NOTIFICATION_LOAD_STOP, 471 content::NOTIFICATION_LOAD_STOP,
471 content::Source<content::NavigationController>(&tab->GetController())); 472 content::Source<NavigationController>(&tab->GetController()));
472 tab->GetController().GoToOffset(1); 473 tab->GetController().GoToOffset(1);
473 observer.Wait(); 474 observer.Wait();
474 } 475 }
475 476
476 // We should be showing the second good page. 477 // We should be showing the second good page.
477 EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage()); 478 EXPECT_FALSE(browser()->GetSelectedWebContents()->GetInterstitialPage());
478 CheckUnauthenticatedState(tab); 479 CheckUnauthenticatedState(tab);
479 EXPECT_FALSE(tab->GetController().CanGoForward()); 480 EXPECT_FALSE(tab->GetController().CanGoForward());
480 NavigationEntry* entry4 = tab->GetController().GetActiveEntry(); 481 NavigationEntry* entry4 = tab->GetController().GetActiveEntry();
481 EXPECT_TRUE(entry2 == entry4); 482 EXPECT_TRUE(entry2 == entry4);
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 ui_test_utils::NavigateToURL(browser(), 1046 ui_test_utils::NavigateToURL(browser(),
1046 https_server_.GetURL(top_frame_path)); 1047 https_server_.GetURL(top_frame_path));
1047 1048
1048 CheckAuthenticatedState(tab, false); 1049 CheckAuthenticatedState(tab, false);
1049 1050
1050 bool success = false; 1051 bool success = false;
1051 // Now navigate inside the frame. 1052 // Now navigate inside the frame.
1052 { 1053 {
1053 ui_test_utils::WindowedNotificationObserver observer( 1054 ui_test_utils::WindowedNotificationObserver observer(
1054 content::NOTIFICATION_LOAD_STOP, 1055 content::NOTIFICATION_LOAD_STOP,
1055 content::Source<content::NavigationController>(&tab->GetController())); 1056 content::Source<NavigationController>(&tab->GetController()));
1056 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1057 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1057 tab->GetRenderViewHost(), std::wstring(), 1058 tab->GetRenderViewHost(), std::wstring(),
1058 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 1059 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
1059 &success)); 1060 &success));
1060 ASSERT_TRUE(success); 1061 ASSERT_TRUE(success);
1061 observer.Wait(); 1062 observer.Wait();
1062 } 1063 }
1063 1064
1064 // We should still be fine. 1065 // We should still be fine.
1065 CheckAuthenticatedState(tab, false); 1066 CheckAuthenticatedState(tab, false);
1066 1067
1067 // Now let's hit a bad page. 1068 // Now let's hit a bad page.
1068 { 1069 {
1069 ui_test_utils::WindowedNotificationObserver observer( 1070 ui_test_utils::WindowedNotificationObserver observer(
1070 content::NOTIFICATION_LOAD_STOP, 1071 content::NOTIFICATION_LOAD_STOP,
1071 content::Source<content::NavigationController>(&tab->GetController())); 1072 content::Source<NavigationController>(&tab->GetController()));
1072 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1073 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1073 tab->GetRenderViewHost(), std::wstring(), 1074 tab->GetRenderViewHost(), std::wstring(),
1074 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", 1075 L"window.domAutomationController.send(clickLink('badHTTPSLink'));",
1075 &success)); 1076 &success));
1076 ASSERT_TRUE(success); 1077 ASSERT_TRUE(success);
1077 observer.Wait(); 1078 observer.Wait();
1078 } 1079 }
1079 1080
1080 // The security style should still be secure. 1081 // The security style should still be secure.
1081 CheckAuthenticatedState(tab, false); 1082 CheckAuthenticatedState(tab, false);
1082 1083
1083 // And the frame should be blocked. 1084 // And the frame should be blocked.
1084 bool is_content_evil = true; 1085 bool is_content_evil = true;
1085 std::wstring content_frame_xpath(L"html/frameset/frame[2]"); 1086 std::wstring content_frame_xpath(L"html/frameset/frame[2]");
1086 std::wstring is_evil_js(L"window.domAutomationController.send(" 1087 std::wstring is_evil_js(L"window.domAutomationController.send("
1087 L"document.getElementById('evilDiv') != null);"); 1088 L"document.getElementById('evilDiv') != null);");
1088 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1089 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1089 tab->GetRenderViewHost(), content_frame_xpath, is_evil_js, 1090 tab->GetRenderViewHost(), content_frame_xpath, is_evil_js,
1090 &is_content_evil)); 1091 &is_content_evil));
1091 EXPECT_FALSE(is_content_evil); 1092 EXPECT_FALSE(is_content_evil);
1092 1093
1093 // Now go back, our state should still be OK. 1094 // Now go back, our state should still be OK.
1094 { 1095 {
1095 ui_test_utils::WindowedNotificationObserver observer( 1096 ui_test_utils::WindowedNotificationObserver observer(
1096 content::NOTIFICATION_LOAD_STOP, 1097 content::NOTIFICATION_LOAD_STOP,
1097 content::Source<content::NavigationController>(&tab->GetController())); 1098 content::Source<NavigationController>(&tab->GetController()));
1098 tab->GetController().GoBack(); 1099 tab->GetController().GoBack();
1099 observer.Wait(); 1100 observer.Wait();
1100 } 1101 }
1101 CheckAuthenticatedState(tab, false); 1102 CheckAuthenticatedState(tab, false);
1102 1103
1103 // Navigate to a page served over HTTP. 1104 // Navigate to a page served over HTTP.
1104 { 1105 {
1105 ui_test_utils::WindowedNotificationObserver observer( 1106 ui_test_utils::WindowedNotificationObserver observer(
1106 content::NOTIFICATION_LOAD_STOP, 1107 content::NOTIFICATION_LOAD_STOP,
1107 content::Source<content::NavigationController>(&tab->GetController())); 1108 content::Source<NavigationController>(&tab->GetController()));
1108 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1109 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1109 tab->GetRenderViewHost(), std::wstring(), 1110 tab->GetRenderViewHost(), std::wstring(),
1110 L"window.domAutomationController.send(clickLink('HTTPLink'));", 1111 L"window.domAutomationController.send(clickLink('HTTPLink'));",
1111 &success)); 1112 &success));
1112 ASSERT_TRUE(success); 1113 ASSERT_TRUE(success);
1113 observer.Wait(); 1114 observer.Wait();
1114 } 1115 }
1115 1116
1116 // Our state should be insecure. 1117 // Our state should be insecure.
1117 CheckAuthenticatedState(tab, true); 1118 CheckAuthenticatedState(tab, true);
1118 1119
1119 // Go back, our state should be unchanged. 1120 // Go back, our state should be unchanged.
1120 { 1121 {
1121 ui_test_utils::WindowedNotificationObserver observer( 1122 ui_test_utils::WindowedNotificationObserver observer(
1122 content::NOTIFICATION_LOAD_STOP, 1123 content::NOTIFICATION_LOAD_STOP,
1123 content::Source<content::NavigationController>(&tab->GetController())); 1124 content::Source<NavigationController>(&tab->GetController()));
1124 tab->GetController().GoBack(); 1125 tab->GetController().GoBack();
1125 observer.Wait(); 1126 observer.Wait();
1126 } 1127 }
1127 CheckAuthenticatedState(tab, true); 1128 CheckAuthenticatedState(tab, true);
1128 } 1129 }
1129 1130
1130 // From a bad HTTPS top frame: 1131 // From a bad HTTPS top frame:
1131 // - navigate to an OK HTTPS frame (expected to be still authentication broken). 1132 // - navigate to an OK HTTPS frame (expected to be still authentication broken).
1132 // Marked as flaky, see bug 40932. 1133 // Marked as flaky, see bug 40932.
1133 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) { 1134 IN_PROC_BROWSER_TEST_F(SSLUITest, FLAKY_TestBadFrameNavigation) {
(...skipping 11 matching lines...) Expand all
1145 https_server_expired_.GetURL(top_frame_path)); 1146 https_server_expired_.GetURL(top_frame_path));
1146 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1147 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1147 true); // Interstitial showing 1148 true); // Interstitial showing
1148 1149
1149 ProceedThroughInterstitial(tab); 1150 ProceedThroughInterstitial(tab);
1150 1151
1151 // Navigate to a good frame. 1152 // Navigate to a good frame.
1152 bool success = false; 1153 bool success = false;
1153 ui_test_utils::WindowedNotificationObserver observer( 1154 ui_test_utils::WindowedNotificationObserver observer(
1154 content::NOTIFICATION_LOAD_STOP, 1155 content::NOTIFICATION_LOAD_STOP,
1155 content::Source<content::NavigationController>(&tab->GetController())); 1156 content::Source<NavigationController>(&tab->GetController()));
1156 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1157 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1157 tab->GetRenderViewHost(), std::wstring(), 1158 tab->GetRenderViewHost(), std::wstring(),
1158 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 1159 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
1159 &success)); 1160 &success));
1160 ASSERT_TRUE(success); 1161 ASSERT_TRUE(success);
1161 observer.Wait(); 1162 observer.Wait();
1162 1163
1163 // We should still be authentication broken. 1164 // We should still be authentication broken.
1164 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false, 1165 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID, false,
1165 false); 1166 false);
(...skipping 16 matching lines...) Expand all
1182 WebContents* tab = browser()->GetSelectedWebContents(); 1183 WebContents* tab = browser()->GetSelectedWebContents();
1183 ui_test_utils::NavigateToURL(browser(), 1184 ui_test_utils::NavigateToURL(browser(),
1184 test_server()->GetURL(top_frame_path)); 1185 test_server()->GetURL(top_frame_path));
1185 CheckUnauthenticatedState(tab); 1186 CheckUnauthenticatedState(tab);
1186 1187
1187 // Now navigate inside the frame to a secure HTTPS frame. 1188 // Now navigate inside the frame to a secure HTTPS frame.
1188 { 1189 {
1189 bool success = false; 1190 bool success = false;
1190 ui_test_utils::WindowedNotificationObserver observer( 1191 ui_test_utils::WindowedNotificationObserver observer(
1191 content::NOTIFICATION_LOAD_STOP, 1192 content::NOTIFICATION_LOAD_STOP,
1192 content::Source<content::NavigationController>(&tab->GetController())); 1193 content::Source<NavigationController>(&tab->GetController()));
1193 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1194 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1194 tab->GetRenderViewHost(), std::wstring(), 1195 tab->GetRenderViewHost(), std::wstring(),
1195 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));", 1196 L"window.domAutomationController.send(clickLink('goodHTTPSLink'));",
1196 &success)); 1197 &success));
1197 ASSERT_TRUE(success); 1198 ASSERT_TRUE(success);
1198 observer.Wait(); 1199 observer.Wait();
1199 } 1200 }
1200 1201
1201 // We should still be unauthenticated. 1202 // We should still be unauthenticated.
1202 CheckUnauthenticatedState(tab); 1203 CheckUnauthenticatedState(tab);
1203 1204
1204 // Now navigate to a bad HTTPS frame. 1205 // Now navigate to a bad HTTPS frame.
1205 { 1206 {
1206 bool success = false; 1207 bool success = false;
1207 ui_test_utils::WindowedNotificationObserver observer( 1208 ui_test_utils::WindowedNotificationObserver observer(
1208 content::NOTIFICATION_LOAD_STOP, 1209 content::NOTIFICATION_LOAD_STOP,
1209 content::Source<content::NavigationController>(&tab->GetController())); 1210 content::Source<NavigationController>(&tab->GetController()));
1210 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1211 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1211 tab->GetRenderViewHost(), std::wstring(), 1212 tab->GetRenderViewHost(), std::wstring(),
1212 L"window.domAutomationController.send(clickLink('badHTTPSLink'));", 1213 L"window.domAutomationController.send(clickLink('badHTTPSLink'));",
1213 &success)); 1214 &success));
1214 ASSERT_TRUE(success); 1215 ASSERT_TRUE(success);
1215 observer.Wait(); 1216 observer.Wait();
1216 } 1217 }
1217 1218
1218 // State should not have changed. 1219 // State should not have changed.
1219 CheckUnauthenticatedState(tab); 1220 CheckUnauthenticatedState(tab);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 1340
1340 // Visit a page over https that contains a frame with a redirect. 1341 // Visit a page over https that contains a frame with a redirect.
1341 1342
1342 // XMLHttpRequest insecure content in synchronous mode. 1343 // XMLHttpRequest insecure content in synchronous mode.
1343 1344
1344 // XMLHttpRequest insecure content in asynchronous mode. 1345 // XMLHttpRequest insecure content in asynchronous mode.
1345 1346
1346 // XMLHttpRequest over bad ssl in synchronous mode. 1347 // XMLHttpRequest over bad ssl in synchronous mode.
1347 1348
1348 // XMLHttpRequest over OK ssl in synchronous mode. 1349 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.cc ('k') | chrome/browser/sync/glue/session_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698