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

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

Issue 580133002: Update entry page type to include error pages when appropriate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address suggestions. Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool waiting_; 92 bool waiting_;
93 bool seen_; 93 bool seen_;
94 }; 94 };
95 95
96 namespace AuthState { 96 namespace AuthState {
97 97
98 enum AuthStateFlags { 98 enum AuthStateFlags {
99 NONE = 0, 99 NONE = 0,
100 DISPLAYED_INSECURE_CONTENT = 1 << 0, 100 DISPLAYED_INSECURE_CONTENT = 1 << 0,
101 RAN_INSECURE_CONTENT = 1 << 1, 101 RAN_INSECURE_CONTENT = 1 << 1,
102 SHOWING_INTERSTITIAL = 1 << 2 102 SHOWING_INTERSTITIAL = 1 << 2,
103 SHOWING_ERROR = 1 << 3
103 }; 104 };
104 105
105 void Check(const NavigationEntry& entry, int expected_authentication_state) { 106 void Check(const NavigationEntry& entry, int expected_authentication_state) {
106 EXPECT_EQ(!!(expected_authentication_state & AuthState::SHOWING_INTERSTITIAL) 107 if (expected_authentication_state == AuthState::SHOWING_ERROR) {
107 ? content::PAGE_TYPE_INTERSTITIAL 108 EXPECT_EQ(content::PAGE_TYPE_ERROR, entry.GetPageType());
108 : content::PAGE_TYPE_NORMAL, 109 } else {
109 entry.GetPageType()); 110 EXPECT_EQ(
111 !!(expected_authentication_state & AuthState::SHOWING_INTERSTITIAL)
112 ? content::PAGE_TYPE_INTERSTITIAL
113 : content::PAGE_TYPE_NORMAL,
114 entry.GetPageType());
115 }
110 116
111 bool displayed_insecure_content = 117 bool displayed_insecure_content =
112 !!(entry.GetSSL().content_status & SSLStatus::DISPLAYED_INSECURE_CONTENT); 118 !!(entry.GetSSL().content_status & SSLStatus::DISPLAYED_INSECURE_CONTENT);
113 EXPECT_EQ( 119 EXPECT_EQ(
114 !!(expected_authentication_state & AuthState::DISPLAYED_INSECURE_CONTENT), 120 !!(expected_authentication_state & AuthState::DISPLAYED_INSECURE_CONTENT),
115 displayed_insecure_content); 121 displayed_insecure_content);
116 122
117 bool ran_insecure_content = 123 bool ran_insecure_content =
118 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT); 124 !!(entry.GetSSL().content_status & SSLStatus::RAN_INSECURE_CONTENT);
119 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT), 125 EXPECT_EQ(!!(expected_authentication_state & AuthState::RAN_INSECURE_CONTENT),
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 196 }
191 197
192 void CheckAuthenticatedState(WebContents* tab, 198 void CheckAuthenticatedState(WebContents* tab,
193 int expected_authentication_state) { 199 int expected_authentication_state) {
194 CheckSecurityState(tab, 200 CheckSecurityState(tab,
195 CertError::NONE, 201 CertError::NONE,
196 content::SECURITY_STYLE_AUTHENTICATED, 202 content::SECURITY_STYLE_AUTHENTICATED,
197 expected_authentication_state); 203 expected_authentication_state);
198 } 204 }
199 205
200 void CheckUnauthenticatedState(WebContents* tab) { 206 void CheckUnauthenticatedState(WebContents* tab,
207 int expected_authentication_state) {
201 CheckSecurityState(tab, 208 CheckSecurityState(tab,
202 CertError::NONE, 209 CertError::NONE,
203 content::SECURITY_STYLE_UNAUTHENTICATED, 210 content::SECURITY_STYLE_UNAUTHENTICATED,
204 AuthState::NONE); 211 expected_authentication_state);
205 } 212 }
206 213
207 void CheckAuthenticationBrokenState(WebContents* tab, 214 void CheckAuthenticationBrokenState(WebContents* tab,
208 net::CertStatus error, 215 net::CertStatus error,
209 int expected_authentication_state) { 216 int expected_authentication_state) {
210 CheckSecurityState(tab, 217 CheckSecurityState(tab,
211 error, 218 error,
212 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, 219 content::SECURITY_STYLE_AUTHENTICATION_BROKEN,
213 expected_authentication_state); 220 expected_authentication_state);
214 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security style 221 // CERT_STATUS_UNABLE_TO_CHECK_REVOCATION doesn't lower the security style
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 }; 381 };
375 382
376 // Visits a regular page over http. 383 // Visits a regular page over http.
377 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { 384 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) {
378 ASSERT_TRUE(test_server()->Start()); 385 ASSERT_TRUE(test_server()->Start());
379 386
380 ui_test_utils::NavigateToURL(browser(), 387 ui_test_utils::NavigateToURL(browser(),
381 test_server()->GetURL("files/ssl/google.html")); 388 test_server()->GetURL("files/ssl/google.html"));
382 389
383 CheckUnauthenticatedState( 390 CheckUnauthenticatedState(
384 browser()->tab_strip_model()->GetActiveWebContents()); 391 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE);
385 } 392 }
386 393
387 // Visits a page over http which includes broken https resources (status should 394 // Visits a page over http which includes broken https resources (status should
388 // be OK). 395 // be OK).
389 // TODO(jcampan): test that bad HTTPS content is blocked (otherwise we'll give 396 // TODO(jcampan): test that bad HTTPS content is blocked (otherwise we'll give
390 // the secure cookies away!). 397 // the secure cookies away!).
391 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) { 398 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) {
392 ASSERT_TRUE(test_server()->Start()); 399 ASSERT_TRUE(test_server()->Start());
393 ASSERT_TRUE(https_server_expired_.Start()); 400 ASSERT_TRUE(https_server_expired_.Start());
394 401
395 std::string replacement_path; 402 std::string replacement_path;
396 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 403 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
397 "files/ssl/page_with_unsafe_contents.html", 404 "files/ssl/page_with_unsafe_contents.html",
398 https_server_expired_.host_port_pair(), 405 https_server_expired_.host_port_pair(),
399 &replacement_path)); 406 &replacement_path));
400 407
401 ui_test_utils::NavigateToURL( 408 ui_test_utils::NavigateToURL(
402 browser(), test_server()->GetURL(replacement_path)); 409 browser(), test_server()->GetURL(replacement_path));
403 410
404 CheckUnauthenticatedState( 411 CheckUnauthenticatedState(
405 browser()->tab_strip_model()->GetActiveWebContents()); 412 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE);
406 } 413 }
407 414
408 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSWithInsecureContent) { 415 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSWithInsecureContent) {
409 ASSERT_TRUE(test_server()->Start()); 416 ASSERT_TRUE(test_server()->Start());
410 ASSERT_TRUE(https_server_expired_.Start()); 417 ASSERT_TRUE(https_server_expired_.Start());
411 418
412 std::string replacement_path; 419 std::string replacement_path;
413 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 420 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
414 "files/ssl/page_displays_insecure_content.html", 421 "files/ssl/page_displays_insecure_content.html",
415 test_server()->host_port_pair(), 422 test_server()->host_port_pair(),
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 524 InterstitialPage* interstitial_page = tab->GetInterstitialPage();
518 ASSERT_TRUE(interstitial_page); 525 ASSERT_TRUE(interstitial_page);
519 interstitial_page->DontProceed(); 526 interstitial_page->DontProceed();
520 527
521 // We should be back to the original good page. 528 // We should be back to the original good page.
522 CheckAuthenticatedState(tab, AuthState::NONE); 529 CheckAuthenticatedState(tab, AuthState::NONE);
523 530
524 // Try to navigate to a new page. (to make sure bug 5800 is fixed). 531 // Try to navigate to a new page. (to make sure bug 5800 is fixed).
525 ui_test_utils::NavigateToURL(browser(), 532 ui_test_utils::NavigateToURL(browser(),
526 test_server()->GetURL("files/ssl/google.html")); 533 test_server()->GetURL("files/ssl/google.html"));
527 CheckUnauthenticatedState(tab); 534 CheckUnauthenticatedState(tab, AuthState::NONE);
528 } 535 }
529 536
530 // Visits a page with https error and then goes back using Browser::GoBack. 537 // Visits a page with https error and then goes back using Browser::GoBack.
531 IN_PROC_BROWSER_TEST_F(SSLUITest, 538 IN_PROC_BROWSER_TEST_F(SSLUITest,
532 TestHTTPSExpiredCertAndGoBackViaButton) { 539 TestHTTPSExpiredCertAndGoBackViaButton) {
533 ASSERT_TRUE(test_server()->Start()); 540 ASSERT_TRUE(test_server()->Start());
534 ASSERT_TRUE(https_server_expired_.Start()); 541 ASSERT_TRUE(https_server_expired_.Start());
535 542
536 // First navigate to an HTTP page. 543 // First navigate to an HTTP page.
537 ui_test_utils::NavigateToURL(browser(), 544 ui_test_utils::NavigateToURL(browser(),
(...skipping 15 matching lines...) Expand all
553 560
554 // Wait until we hear the load failure, and make sure we haven't swapped out 561 // Wait until we hear the load failure, and make sure we haven't swapped out
555 // the previous page. Prevents regression of http://crbug.com/82667. 562 // the previous page. Prevents regression of http://crbug.com/82667.
556 load_failed_observer.Wait(); 563 load_failed_observer.Wait();
557 EXPECT_FALSE(content::RenderViewHostTester::IsRenderViewHostSwappedOut( 564 EXPECT_FALSE(content::RenderViewHostTester::IsRenderViewHostSwappedOut(
558 tab->GetRenderViewHost())); 565 tab->GetRenderViewHost()));
559 566
560 // We should be back at the original good page. 567 // We should be back at the original good page.
561 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> 568 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()->
562 GetInterstitialPage()); 569 GetInterstitialPage());
563 CheckUnauthenticatedState(tab); 570 CheckUnauthenticatedState(tab, AuthState::NONE);
564 } 571 }
565 572
566 // Visits a page with https error and then goes back using GoToOffset. 573 // Visits a page with https error and then goes back using GoToOffset.
567 // Disabled because its flaky: http://crbug.com/40932, http://crbug.com/43575. 574 // Disabled because its flaky: http://crbug.com/40932, http://crbug.com/43575.
568 IN_PROC_BROWSER_TEST_F(SSLUITest, 575 IN_PROC_BROWSER_TEST_F(SSLUITest,
569 TestHTTPSExpiredCertAndGoBackViaMenu) { 576 TestHTTPSExpiredCertAndGoBackViaMenu) {
570 ASSERT_TRUE(test_server()->Start()); 577 ASSERT_TRUE(test_server()->Start());
571 ASSERT_TRUE(https_server_expired_.Start()); 578 ASSERT_TRUE(https_server_expired_.Start());
572 579
573 // First navigate to an HTTP page. 580 // First navigate to an HTTP page.
574 ui_test_utils::NavigateToURL(browser(), 581 ui_test_utils::NavigateToURL(browser(),
575 test_server()->GetURL("files/ssl/google.html")); 582 test_server()->GetURL("files/ssl/google.html"));
576 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 583 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
577 NavigationEntry* entry = tab->GetController().GetActiveEntry(); 584 NavigationEntry* entry = tab->GetController().GetActiveEntry();
578 ASSERT_TRUE(entry); 585 ASSERT_TRUE(entry);
579 586
580 // Now go to a bad HTTPS page that shows an interstitial. 587 // Now go to a bad HTTPS page that shows an interstitial.
581 ui_test_utils::NavigateToURL(browser(), 588 ui_test_utils::NavigateToURL(browser(),
582 https_server_expired_.GetURL("files/ssl/google.html")); 589 https_server_expired_.GetURL("files/ssl/google.html"));
583 CheckAuthenticationBrokenState( 590 CheckAuthenticationBrokenState(
584 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); 591 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL);
585 592
586 // Simulate user clicking and holding on back button (crbug.com/37215). 593 // Simulate user clicking and holding on back button (crbug.com/37215).
587 tab->GetController().GoToOffset(-1); 594 tab->GetController().GoToOffset(-1);
588 595
589 // We should be back at the original good page. 596 // We should be back at the original good page.
590 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> 597 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()->
591 GetInterstitialPage()); 598 GetInterstitialPage());
592 CheckUnauthenticatedState(tab); 599 CheckUnauthenticatedState(tab, AuthState::NONE);
593 } 600 }
594 601
595 // Visits a page with https error and then goes forward using GoToOffset. 602 // Visits a page with https error and then goes forward using GoToOffset.
596 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) { 603 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) {
597 ASSERT_TRUE(test_server()->Start()); 604 ASSERT_TRUE(test_server()->Start());
598 ASSERT_TRUE(https_server_expired_.Start()); 605 ASSERT_TRUE(https_server_expired_.Start());
599 606
600 // First navigate to two HTTP pages. 607 // First navigate to two HTTP pages.
601 ui_test_utils::NavigateToURL(browser(), 608 ui_test_utils::NavigateToURL(browser(),
602 test_server()->GetURL("files/ssl/google.html")); 609 test_server()->GetURL("files/ssl/google.html"));
(...skipping 28 matching lines...) Expand all
631 content::WindowedNotificationObserver observer( 638 content::WindowedNotificationObserver observer(
632 content::NOTIFICATION_LOAD_STOP, 639 content::NOTIFICATION_LOAD_STOP,
633 content::Source<NavigationController>(&tab->GetController())); 640 content::Source<NavigationController>(&tab->GetController()));
634 tab->GetController().GoToOffset(1); 641 tab->GetController().GoToOffset(1);
635 observer.Wait(); 642 observer.Wait();
636 } 643 }
637 644
638 // We should be showing the second good page. 645 // We should be showing the second good page.
639 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> 646 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()->
640 GetInterstitialPage()); 647 GetInterstitialPage());
641 CheckUnauthenticatedState(tab); 648 CheckUnauthenticatedState(tab, AuthState::NONE);
642 EXPECT_FALSE(tab->GetController().CanGoForward()); 649 EXPECT_FALSE(tab->GetController().CanGoForward());
643 NavigationEntry* entry4 = tab->GetController().GetActiveEntry(); 650 NavigationEntry* entry4 = tab->GetController().GetActiveEntry();
644 EXPECT_TRUE(entry2 == entry4); 651 EXPECT_TRUE(entry2 == entry4);
645 } 652 }
646 653
647 // Visit a HTTP page which request WSS connection to a server providing invalid 654 // Visit a HTTP page which request WSS connection to a server providing invalid
648 // certificate. Close the page while WSS connection waits for SSLManager's 655 // certificate. Close the page while WSS connection waits for SSLManager's
649 // response from UI thread. 656 // response from UI thread.
650 // Disabled on Windows because it was flaking on XP Tests (1). crbug.com/165258 657 // Disabled on Windows because it was flaking on XP Tests (1). crbug.com/165258
651 #if defined(OS_WIN) 658 #if defined(OS_WIN)
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 std::string replacement_path; 1139 std::string replacement_path;
1133 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 1140 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
1134 "files/ssl/page_displays_insecure_content.html", 1141 "files/ssl/page_displays_insecure_content.html",
1135 test_server()->host_port_pair(), 1142 test_server()->host_port_pair(),
1136 &replacement_path)); 1143 &replacement_path));
1137 1144
1138 // Load original page over HTTP. 1145 // Load original page over HTTP.
1139 const GURL url_http = test_server()->GetURL(replacement_path); 1146 const GURL url_http = test_server()->GetURL(replacement_path);
1140 ui_test_utils::NavigateToURL(browser(), url_http); 1147 ui_test_utils::NavigateToURL(browser(), url_http);
1141 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1148 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1142 CheckUnauthenticatedState(tab); 1149 CheckUnauthenticatedState(tab, AuthState::NONE);
1143 1150
1144 // Load again but over SSL. It should be marked as displaying insecure 1151 // Load again but over SSL. It should be marked as displaying insecure
1145 // content (even though the image comes from the WebCore memory cache). 1152 // content (even though the image comes from the WebCore memory cache).
1146 const GURL url_https = https_server_.GetURL(replacement_path); 1153 const GURL url_https = https_server_.GetURL(replacement_path);
1147 ui_test_utils::NavigateToURL(browser(), url_https); 1154 ui_test_utils::NavigateToURL(browser(), url_https);
1148 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 1155 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT);
1149 } 1156 }
1150 1157
1151 // http://crbug.com/84729 1158 // http://crbug.com/84729
1152 #if defined(OS_CHROMEOS) 1159 #if defined(OS_CHROMEOS)
(...skipping 13 matching lines...) Expand all
1166 std::string replacement_path; 1173 std::string replacement_path;
1167 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( 1174 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
1168 "files/ssl/page_runs_insecure_content.html", 1175 "files/ssl/page_runs_insecure_content.html",
1169 test_server()->host_port_pair(), 1176 test_server()->host_port_pair(),
1170 &replacement_path)); 1177 &replacement_path));
1171 1178
1172 // Load original page over HTTP. 1179 // Load original page over HTTP.
1173 const GURL url_http = test_server()->GetURL(replacement_path); 1180 const GURL url_http = test_server()->GetURL(replacement_path);
1174 ui_test_utils::NavigateToURL(browser(), url_http); 1181 ui_test_utils::NavigateToURL(browser(), url_http);
1175 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1182 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1176 CheckUnauthenticatedState(tab); 1183 CheckUnauthenticatedState(tab, AuthState::NONE);
1177 1184
1178 // Load again but over SSL. It should be marked as displaying insecure 1185 // Load again but over SSL. It should be marked as displaying insecure
1179 // content (even though the image comes from the WebCore memory cache). 1186 // content (even though the image comes from the WebCore memory cache).
1180 const GURL url_https = https_server_.GetURL(replacement_path); 1187 const GURL url_https = https_server_.GetURL(replacement_path);
1181 ui_test_utils::NavigateToURL(browser(), url_https); 1188 ui_test_utils::NavigateToURL(browser(), url_https);
1182 CheckAuthenticationBrokenState( 1189 CheckAuthenticationBrokenState(
1183 tab, 1190 tab,
1184 CertError::NONE, 1191 CertError::NONE,
1185 AuthState::DISPLAYED_INSECURE_CONTENT | AuthState::RAN_INSECURE_CONTENT); 1192 AuthState::DISPLAYED_INSECURE_CONTENT | AuthState::RAN_INSECURE_CONTENT);
1186 } 1193 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) { 1402 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) {
1396 ASSERT_TRUE(test_server()->Start()); 1403 ASSERT_TRUE(test_server()->Start());
1397 ASSERT_TRUE(https_server_.Start()); 1404 ASSERT_TRUE(https_server_.Start());
1398 1405
1399 GURL https_url = https_server_.GetURL("server-redirect?"); 1406 GURL https_url = https_server_.GetURL("server-redirect?");
1400 GURL http_url = test_server()->GetURL("files/ssl/google.html"); 1407 GURL http_url = test_server()->GetURL("files/ssl/google.html");
1401 1408
1402 ui_test_utils::NavigateToURL(browser(), 1409 ui_test_utils::NavigateToURL(browser(),
1403 GURL(https_url.spec() + http_url.spec())); 1410 GURL(https_url.spec() + http_url.spec()));
1404 CheckUnauthenticatedState( 1411 CheckUnauthenticatedState(
1405 browser()->tab_strip_model()->GetActiveWebContents()); 1412 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE);
1406 } 1413 }
1407 1414
1408 // Visits a page to which we could not connect (bad port) over http and https 1415 // Visits a page to which we could not connect (bad port) over http and https
1409 // and make sure the security style is correct. 1416 // and make sure the security style is correct.
1410 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { 1417 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) {
1411 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17")); 1418 ui_test_utils::NavigateToURL(browser(), GURL("http://localhost:17"));
1412 CheckUnauthenticatedState( 1419 CheckUnauthenticatedState(
1413 browser()->tab_strip_model()->GetActiveWebContents()); 1420 browser()->tab_strip_model()->GetActiveWebContents(),
1421 AuthState::SHOWING_ERROR);
1414 1422
1415 // Same thing over HTTPS. 1423 // Same thing over HTTPS.
1416 ui_test_utils::NavigateToURL(browser(), GURL("https://localhost:17")); 1424 ui_test_utils::NavigateToURL(browser(), GURL("https://localhost:17"));
1417 CheckUnauthenticatedState( 1425 CheckUnauthenticatedState(
1418 browser()->tab_strip_model()->GetActiveWebContents()); 1426 browser()->tab_strip_model()->GetActiveWebContents(),
1427 AuthState::SHOWING_ERROR);
1419 } 1428 }
1420 1429
1421 // 1430 //
1422 // Frame navigation 1431 // Frame navigation
1423 // 1432 //
1424 1433
1425 // From a good HTTPS top frame: 1434 // From a good HTTPS top frame:
1426 // - navigate to an OK HTTPS frame 1435 // - navigate to an OK HTTPS frame
1427 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then 1436 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then
1428 // back 1437 // back
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 1588
1580 std::string top_frame_path; 1589 std::string top_frame_path;
1581 ASSERT_TRUE(GetTopFramePath(*test_server(), 1590 ASSERT_TRUE(GetTopFramePath(*test_server(),
1582 https_server_, 1591 https_server_,
1583 https_server_expired_, 1592 https_server_expired_,
1584 &top_frame_path)); 1593 &top_frame_path));
1585 1594
1586 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 1595 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
1587 ui_test_utils::NavigateToURL(browser(), 1596 ui_test_utils::NavigateToURL(browser(),
1588 test_server()->GetURL(top_frame_path)); 1597 test_server()->GetURL(top_frame_path));
1589 CheckUnauthenticatedState(tab); 1598 CheckUnauthenticatedState(tab, AuthState::NONE);
1590 1599
1591 // Now navigate inside the frame to a secure HTTPS frame. 1600 // Now navigate inside the frame to a secure HTTPS frame.
1592 { 1601 {
1593 bool success = false; 1602 bool success = false;
1594 content::WindowedNotificationObserver observer( 1603 content::WindowedNotificationObserver observer(
1595 content::NOTIFICATION_LOAD_STOP, 1604 content::NOTIFICATION_LOAD_STOP,
1596 content::Source<NavigationController>(&tab->GetController())); 1605 content::Source<NavigationController>(&tab->GetController()));
1597 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 1606 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1598 tab, 1607 tab,
1599 "window.domAutomationController.send(clickLink('goodHTTPSLink'));", 1608 "window.domAutomationController.send(clickLink('goodHTTPSLink'));",
1600 &success)); 1609 &success));
1601 ASSERT_TRUE(success); 1610 ASSERT_TRUE(success);
1602 observer.Wait(); 1611 observer.Wait();
1603 } 1612 }
1604 1613
1605 // We should still be unauthenticated. 1614 // We should still be unauthenticated.
1606 CheckUnauthenticatedState(tab); 1615 CheckUnauthenticatedState(tab, AuthState::NONE);
1607 1616
1608 // Now navigate to a bad HTTPS frame. 1617 // Now navigate to a bad HTTPS frame.
1609 { 1618 {
1610 bool success = false; 1619 bool success = false;
1611 content::WindowedNotificationObserver observer( 1620 content::WindowedNotificationObserver observer(
1612 content::NOTIFICATION_LOAD_STOP, 1621 content::NOTIFICATION_LOAD_STOP,
1613 content::Source<NavigationController>(&tab->GetController())); 1622 content::Source<NavigationController>(&tab->GetController()));
1614 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 1623 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
1615 tab, 1624 tab,
1616 "window.domAutomationController.send(clickLink('badHTTPSLink'));", 1625 "window.domAutomationController.send(clickLink('badHTTPSLink'));",
1617 &success)); 1626 &success));
1618 ASSERT_TRUE(success); 1627 ASSERT_TRUE(success);
1619 observer.Wait(); 1628 observer.Wait();
1620 } 1629 }
1621 1630
1622 // State should not have changed. 1631 // State should not have changed.
1623 CheckUnauthenticatedState(tab); 1632 CheckUnauthenticatedState(tab, AuthState::NONE);
1624 1633
1625 // And the frame should have been blocked (see bug #2316). 1634 // And the frame should have been blocked (see bug #2316).
1626 bool is_content_evil = true; 1635 bool is_content_evil = true;
1627 content::RenderFrameHost* content_frame = content::FrameMatchingPredicate( 1636 content::RenderFrameHost* content_frame = content::FrameMatchingPredicate(
1628 tab, base::Bind(&content::FrameMatchesName, "contentFrame")); 1637 tab, base::Bind(&content::FrameMatchesName, "contentFrame"));
1629 std::string is_evil_js("window.domAutomationController.send(" 1638 std::string is_evil_js("window.domAutomationController.send("
1630 "document.getElementById('evilDiv') != null);"); 1639 "document.getElementById('evilDiv') != null);");
1631 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(content_frame, 1640 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(content_frame,
1632 is_evil_js, 1641 is_evil_js,
1633 &is_content_evil)); 1642 &is_content_evil));
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 1878
1870 // Visit a page over https that contains a frame with a redirect. 1879 // Visit a page over https that contains a frame with a redirect.
1871 1880
1872 // XMLHttpRequest insecure content in synchronous mode. 1881 // XMLHttpRequest insecure content in synchronous mode.
1873 1882
1874 // XMLHttpRequest insecure content in asynchronous mode. 1883 // XMLHttpRequest insecure content in asynchronous mode.
1875 1884
1876 // XMLHttpRequest over bad ssl in synchronous mode. 1885 // XMLHttpRequest over bad ssl in synchronous mode.
1877 1886
1878 // XMLHttpRequest over OK ssl in synchronous mode. 1887 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs_test.cc ('k') | chrome/browser/ui/zoom/zoom_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698