OLD | NEW |
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/base_switches.h" | 5 #include "base/base_switches.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/string_split.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
18 #include "base/test/simple_test_clock.h" | 19 #include "base/test/simple_test_clock.h" |
19 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
21 #include "chrome/app/chrome_command_ids.h" | 22 #include "chrome/app/chrome_command_ids.h" |
22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #include "content/public/test/test_renderer_host.h" | 70 #include "content/public/test/test_renderer_host.h" |
70 #include "net/base/host_port_pair.h" | 71 #include "net/base/host_port_pair.h" |
71 #include "net/base/net_errors.h" | 72 #include "net/base/net_errors.h" |
72 #include "net/base/test_data_directory.h" | 73 #include "net/base/test_data_directory.h" |
73 #include "net/cert/cert_status_flags.h" | 74 #include "net/cert/cert_status_flags.h" |
74 #include "net/cert/mock_cert_verifier.h" | 75 #include "net/cert/mock_cert_verifier.h" |
75 #include "net/cert/x509_certificate.h" | 76 #include "net/cert/x509_certificate.h" |
76 #include "net/dns/mock_host_resolver.h" | 77 #include "net/dns/mock_host_resolver.h" |
77 #include "net/ssl/ssl_info.h" | 78 #include "net/ssl/ssl_info.h" |
78 #include "net/test/cert_test_util.h" | 79 #include "net/test/cert_test_util.h" |
79 #include "net/test/spawned_test_server/spawned_test_server.h" | 80 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 81 #include "net/test/embedded_test_server/request_handler_util.h" |
80 #include "net/test/test_certificate_data.h" | 82 #include "net/test/test_certificate_data.h" |
81 #include "net/url_request/url_request_context.h" | 83 #include "net/url_request/url_request_context.h" |
82 | 84 |
83 #if defined(USE_NSS_CERTS) | 85 #if defined(USE_NSS_CERTS) |
84 #include "chrome/browser/net/nss_context.h" | 86 #include "chrome/browser/net/nss_context.h" |
85 #include "net/base/crypto_module.h" | 87 #include "net/base/crypto_module.h" |
86 #include "net/cert/nss_cert_database.h" | 88 #include "net/cert/nss_cert_database.h" |
87 #endif // defined(USE_NSS_CERTS) | 89 #endif // defined(USE_NSS_CERTS) |
88 | 90 |
89 using base::ASCIIToUTF16; | 91 using base::ASCIIToUTF16; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 two_without_cert_id.cert_id = 0; | 263 two_without_cert_id.cert_id = 0; |
262 EXPECT_TRUE(one_without_cert_id.Equals(two_without_cert_id)); | 264 EXPECT_TRUE(one_without_cert_id.Equals(two_without_cert_id)); |
263 } | 265 } |
264 | 266 |
265 } // namespace | 267 } // namespace |
266 | 268 |
267 class SSLUITest | 269 class SSLUITest |
268 : public certificate_reporting_test_utils::CertificateReportingTest { | 270 : public certificate_reporting_test_utils::CertificateReportingTest { |
269 public: | 271 public: |
270 SSLUITest() | 272 SSLUITest() |
271 : https_server_(net::SpawnedTestServer::TYPE_HTTPS, | 273 : https_server_(net::EmbeddedTestServer::TYPE_HTTPS), |
272 SSLOptions(SSLOptions::CERT_OK), | 274 https_server_expired_(net::EmbeddedTestServer::TYPE_HTTPS), |
273 base::FilePath(kDocRoot)), | 275 https_server_mismatched_(net::EmbeddedTestServer::TYPE_HTTPS), |
274 https_server_expired_(net::SpawnedTestServer::TYPE_HTTPS, | |
275 SSLOptions(SSLOptions::CERT_EXPIRED), | |
276 base::FilePath(kDocRoot)), | |
277 https_server_mismatched_(net::SpawnedTestServer::TYPE_HTTPS, | |
278 SSLOptions(SSLOptions::CERT_MISMATCHED_NAME), | |
279 base::FilePath(kDocRoot)), | |
280 wss_server_expired_(net::SpawnedTestServer::TYPE_WSS, | 276 wss_server_expired_(net::SpawnedTestServer::TYPE_WSS, |
281 SSLOptions(SSLOptions::CERT_EXPIRED), | 277 SSLOptions(SSLOptions::CERT_EXPIRED), |
282 net::GetWebSocketTestDataDirectory()) {} | 278 net::GetWebSocketTestDataDirectory()) { |
| 279 https_server_.AddDefaultHandlers(base::FilePath(kDocRoot)); |
| 280 |
| 281 https_server_expired_.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 282 https_server_expired_.AddDefaultHandlers(base::FilePath(kDocRoot)); |
| 283 |
| 284 https_server_mismatched_.SetSSLConfig( |
| 285 net::EmbeddedTestServer::CERT_MISMATCHED_NAME); |
| 286 https_server_mismatched_.AddDefaultHandlers(base::FilePath(kDocRoot)); |
| 287 } |
283 | 288 |
284 void SetUpCommandLine(base::CommandLine* command_line) override { | 289 void SetUpCommandLine(base::CommandLine* command_line) override { |
285 // Browser will both run and display insecure content. | 290 // Browser will both run and display insecure content. |
286 command_line->AppendSwitch(switches::kAllowRunningInsecureContent); | 291 command_line->AppendSwitch(switches::kAllowRunningInsecureContent); |
287 // Use process-per-site so that navigating to a same-site page in a | 292 // Use process-per-site so that navigating to a same-site page in a |
288 // new tab will use the same process. | 293 // new tab will use the same process. |
289 command_line->AppendSwitch(switches::kProcessPerSite); | 294 command_line->AppendSwitch(switches::kProcessPerSite); |
290 } | 295 } |
291 | 296 |
292 void CheckAuthenticatedState(WebContents* tab, | 297 void CheckAuthenticatedState(WebContents* tab, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 interstitial_page->Proceed(); | 366 interstitial_page->Proceed(); |
362 observer.Wait(); | 367 observer.Wait(); |
363 } | 368 } |
364 | 369 |
365 bool IsShowingWebContentsModalDialog() const { | 370 bool IsShowingWebContentsModalDialog() const { |
366 return WebContentsModalDialogManager::FromWebContents( | 371 return WebContentsModalDialogManager::FromWebContents( |
367 browser()->tab_strip_model()->GetActiveWebContents())-> | 372 browser()->tab_strip_model()->GetActiveWebContents())-> |
368 IsDialogActive(); | 373 IsDialogActive(); |
369 } | 374 } |
370 | 375 |
371 static bool GetFilePathWithHostAndPortReplacement( | 376 static void GetFilePathWithHostAndPortReplacement( |
372 const std::string& original_file_path, | 377 const std::string& original_file_path, |
373 const net::HostPortPair& host_port_pair, | 378 const net::HostPortPair& host_port_pair, |
374 std::string* replacement_path) { | 379 std::string* replacement_path) { |
375 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 380 base::StringPairs replacement_text; |
376 replacement_text.push_back( | 381 replacement_text.push_back( |
377 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); | 382 make_pair("REPLACE_WITH_HOST_AND_PORT", host_port_pair.ToString())); |
378 return net::SpawnedTestServer::GetFilePathWithReplacements( | 383 net::test_server::GetFilePathWithReplacements( |
379 original_file_path, replacement_text, replacement_path); | 384 original_file_path, replacement_text, replacement_path); |
380 } | 385 } |
381 | 386 |
382 static bool GetTopFramePath(const net::SpawnedTestServer& http_server, | 387 static void GetTopFramePath(const net::EmbeddedTestServer& http_server, |
383 const net::SpawnedTestServer& good_https_server, | 388 const net::EmbeddedTestServer& good_https_server, |
384 const net::SpawnedTestServer& bad_https_server, | 389 const net::EmbeddedTestServer& bad_https_server, |
385 std::string* top_frame_path) { | 390 std::string* top_frame_path) { |
386 // The "frame_left.html" page contained in the top_frame.html page contains | 391 // The "frame_left.html" page contained in the top_frame.html page contains |
387 // <a href>'s to three different servers. This sets up all of the | 392 // <a href>'s to three different servers. This sets up all of the |
388 // replacement text to work with test servers which listen on ephemeral | 393 // replacement text to work with test servers which listen on ephemeral |
389 // ports. | 394 // ports. |
390 GURL http_url = http_server.GetURL("files/ssl/google.html"); | 395 GURL http_url = http_server.GetURL("/ssl/google.html"); |
391 GURL good_https_url = good_https_server.GetURL("files/ssl/google.html"); | 396 GURL good_https_url = good_https_server.GetURL("/ssl/google.html"); |
392 GURL bad_https_url = bad_https_server.GetURL( | 397 GURL bad_https_url = bad_https_server.GetURL("/ssl/bad_iframe.html"); |
393 "files/ssl/bad_iframe.html"); | |
394 | 398 |
395 std::vector<net::SpawnedTestServer::StringPair> replacement_text_frame_left; | 399 base::StringPairs replacement_text_frame_left; |
396 replacement_text_frame_left.push_back( | 400 replacement_text_frame_left.push_back( |
397 make_pair("REPLACE_WITH_HTTP_PAGE", http_url.spec())); | 401 make_pair("REPLACE_WITH_HTTP_PAGE", http_url.spec())); |
398 replacement_text_frame_left.push_back( | 402 replacement_text_frame_left.push_back( |
399 make_pair("REPLACE_WITH_GOOD_HTTPS_PAGE", good_https_url.spec())); | 403 make_pair("REPLACE_WITH_GOOD_HTTPS_PAGE", good_https_url.spec())); |
400 replacement_text_frame_left.push_back( | 404 replacement_text_frame_left.push_back( |
401 make_pair("REPLACE_WITH_BAD_HTTPS_PAGE", bad_https_url.spec())); | 405 make_pair("REPLACE_WITH_BAD_HTTPS_PAGE", bad_https_url.spec())); |
402 std::string frame_left_path; | 406 std::string frame_left_path; |
403 if (!net::SpawnedTestServer::GetFilePathWithReplacements( | 407 net::test_server::GetFilePathWithReplacements( |
404 "frame_left.html", | 408 "frame_left.html", replacement_text_frame_left, &frame_left_path); |
405 replacement_text_frame_left, | |
406 &frame_left_path)) | |
407 return false; | |
408 | 409 |
409 // Substitute the generated frame_left URL into the top_frame page. | 410 // Substitute the generated frame_left URL into the top_frame page. |
410 std::vector<net::SpawnedTestServer::StringPair> replacement_text_top_frame; | 411 base::StringPairs replacement_text_top_frame; |
411 replacement_text_top_frame.push_back( | 412 replacement_text_top_frame.push_back( |
412 make_pair("REPLACE_WITH_FRAME_LEFT_PATH", frame_left_path)); | 413 make_pair("REPLACE_WITH_FRAME_LEFT_PATH", frame_left_path)); |
413 return net::SpawnedTestServer::GetFilePathWithReplacements( | 414 net::test_server::GetFilePathWithReplacements( |
414 "files/ssl/top_frame.html", | 415 "/ssl/top_frame.html", replacement_text_top_frame, top_frame_path); |
415 replacement_text_top_frame, | |
416 top_frame_path); | |
417 } | 416 } |
418 | 417 |
419 static bool GetPageWithUnsafeWorkerPath( | 418 static void GetPageWithUnsafeWorkerPath( |
420 const net::SpawnedTestServer& https_server, | 419 const net::EmbeddedTestServer& https_server, |
421 std::string* page_with_unsafe_worker_path) { | 420 std::string* page_with_unsafe_worker_path) { |
422 // Get the "imported.js" URL from the expired https server and | 421 // Get the "imported.js" URL from the expired https server and |
423 // substitute it into the unsafe_worker.js file. | 422 // substitute it into the unsafe_worker.js file. |
424 GURL imported_js_url = https_server.GetURL("files/ssl/imported.js"); | 423 GURL imported_js_url = https_server.GetURL("/ssl/imported.js"); |
425 std::vector<net::SpawnedTestServer::StringPair> | 424 base::StringPairs replacement_text_for_unsafe_worker; |
426 replacement_text_for_unsafe_worker; | |
427 replacement_text_for_unsafe_worker.push_back( | 425 replacement_text_for_unsafe_worker.push_back( |
428 make_pair("REPLACE_WITH_IMPORTED_JS_URL", imported_js_url.spec())); | 426 make_pair("REPLACE_WITH_IMPORTED_JS_URL", imported_js_url.spec())); |
429 std::string unsafe_worker_path; | 427 std::string unsafe_worker_path; |
430 if (!net::SpawnedTestServer::GetFilePathWithReplacements( | 428 net::test_server::GetFilePathWithReplacements( |
431 "unsafe_worker.js", | 429 "unsafe_worker.js", replacement_text_for_unsafe_worker, |
432 replacement_text_for_unsafe_worker, | 430 &unsafe_worker_path); |
433 &unsafe_worker_path)) | |
434 return false; | |
435 | 431 |
436 // Now, substitute this into the page with unsafe worker. | 432 // Now, substitute this into the page with unsafe worker. |
437 std::vector<net::SpawnedTestServer::StringPair> | 433 base::StringPairs replacement_text_for_page_with_unsafe_worker; |
438 replacement_text_for_page_with_unsafe_worker; | |
439 replacement_text_for_page_with_unsafe_worker.push_back( | 434 replacement_text_for_page_with_unsafe_worker.push_back( |
440 make_pair("REPLACE_WITH_UNSAFE_WORKER_PATH", unsafe_worker_path)); | 435 make_pair("REPLACE_WITH_UNSAFE_WORKER_PATH", unsafe_worker_path)); |
441 return net::SpawnedTestServer::GetFilePathWithReplacements( | 436 net::test_server::GetFilePathWithReplacements( |
442 "files/ssl/page_with_unsafe_worker.html", | 437 "/ssl/page_with_unsafe_worker.html", |
443 replacement_text_for_page_with_unsafe_worker, | 438 replacement_text_for_page_with_unsafe_worker, |
444 page_with_unsafe_worker_path); | 439 page_with_unsafe_worker_path); |
445 } | 440 } |
446 | 441 |
447 // Helper function for testing invalid certificate chain reporting. | 442 // Helper function for testing invalid certificate chain reporting. |
448 void TestBrokenHTTPSReporting( | 443 void TestBrokenHTTPSReporting( |
449 certificate_reporting_test_utils::OptIn opt_in, | 444 certificate_reporting_test_utils::OptIn opt_in, |
450 ProceedDecision proceed, | 445 ProceedDecision proceed, |
451 certificate_reporting_test_utils::ExpectReport expect_report, | 446 certificate_reporting_test_utils::ExpectReport expect_report, |
452 Browser* browser) { | 447 Browser* browser) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // Check that the mock reporter received a request to send a report. | 538 // Check that the mock reporter received a request to send a report. |
544 run_loop.Run(); | 539 run_loop.Run(); |
545 EXPECT_EQ(https_server_expired_.GetURL("/").host(), | 540 EXPECT_EQ(https_server_expired_.GetURL("/").host(), |
546 GetLatestHostnameReported()); | 541 GetLatestHostnameReported()); |
547 } else { | 542 } else { |
548 base::RunLoop().RunUntilIdle(); | 543 base::RunLoop().RunUntilIdle(); |
549 EXPECT_EQ(std::string(), GetLatestHostnameReported()); | 544 EXPECT_EQ(std::string(), GetLatestHostnameReported()); |
550 } | 545 } |
551 } | 546 } |
552 | 547 |
553 net::SpawnedTestServer https_server_; | 548 net::EmbeddedTestServer https_server_; |
554 net::SpawnedTestServer https_server_expired_; | 549 net::EmbeddedTestServer https_server_expired_; |
555 net::SpawnedTestServer https_server_mismatched_; | 550 net::EmbeddedTestServer https_server_mismatched_; |
556 net::SpawnedTestServer wss_server_expired_; | 551 net::SpawnedTestServer wss_server_expired_; |
557 | 552 |
558 private: | 553 private: |
559 typedef net::SpawnedTestServer::SSLOptions SSLOptions; | 554 typedef net::SpawnedTestServer::SSLOptions SSLOptions; |
560 | 555 |
561 DISALLOW_COPY_AND_ASSIGN(SSLUITest); | 556 DISALLOW_COPY_AND_ASSIGN(SSLUITest); |
562 }; | 557 }; |
563 | 558 |
564 class SSLUITestBlock : public SSLUITest { | 559 class SSLUITestBlock : public SSLUITest { |
565 public: | 560 public: |
(...skipping 25 matching lines...) Expand all Loading... |
591 } | 586 } |
592 }; | 587 }; |
593 | 588 |
594 class SSLUITestWithExtendedReporting : public SSLUITest { | 589 class SSLUITestWithExtendedReporting : public SSLUITest { |
595 public: | 590 public: |
596 SSLUITestWithExtendedReporting() : SSLUITest() {} | 591 SSLUITestWithExtendedReporting() : SSLUITest() {} |
597 }; | 592 }; |
598 | 593 |
599 // Visits a regular page over http. | 594 // Visits a regular page over http. |
600 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { | 595 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { |
601 ASSERT_TRUE(test_server()->Start()); | 596 ASSERT_TRUE(embedded_test_server()->Start()); |
602 | 597 |
603 ui_test_utils::NavigateToURL(browser(), | 598 ui_test_utils::NavigateToURL( |
604 test_server()->GetURL("files/ssl/google.html")); | 599 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
605 | 600 |
606 CheckUnauthenticatedState( | 601 CheckUnauthenticatedState( |
607 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); | 602 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); |
608 } | 603 } |
609 | 604 |
610 // Visits a page over http which includes broken https resources (status should | 605 // Visits a page over http which includes broken https resources (status should |
611 // be OK). | 606 // be OK). |
612 // TODO(jcampan): test that bad HTTPS content is blocked (otherwise we'll give | 607 // TODO(jcampan): test that bad HTTPS content is blocked (otherwise we'll give |
613 // the secure cookies away!). | 608 // the secure cookies away!). |
614 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) { | 609 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPWithBrokenHTTPSResource) { |
615 ASSERT_TRUE(test_server()->Start()); | 610 ASSERT_TRUE(embedded_test_server()->Start()); |
616 ASSERT_TRUE(https_server_expired_.Start()); | 611 ASSERT_TRUE(https_server_expired_.Start()); |
617 | 612 |
618 std::string replacement_path; | 613 std::string replacement_path; |
619 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 614 GetFilePathWithHostAndPortReplacement("/ssl/page_with_unsafe_contents.html", |
620 "files/ssl/page_with_unsafe_contents.html", | 615 https_server_expired_.host_port_pair(), |
621 https_server_expired_.host_port_pair(), | 616 &replacement_path); |
622 &replacement_path)); | |
623 | 617 |
624 ui_test_utils::NavigateToURL( | 618 ui_test_utils::NavigateToURL( |
625 browser(), test_server()->GetURL(replacement_path)); | 619 browser(), embedded_test_server()->GetURL(replacement_path)); |
626 | 620 |
627 CheckUnauthenticatedState( | 621 CheckUnauthenticatedState( |
628 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); | 622 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); |
629 } | 623 } |
630 | 624 |
631 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSWithInsecureContent) { | 625 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSWithInsecureContent) { |
632 ASSERT_TRUE(test_server()->Start()); | 626 ASSERT_TRUE(embedded_test_server()->Start()); |
633 ASSERT_TRUE(https_server_expired_.Start()); | 627 ASSERT_TRUE(https_server_expired_.Start()); |
634 | 628 |
635 std::string replacement_path; | 629 std::string replacement_path; |
636 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 630 GetFilePathWithHostAndPortReplacement( |
637 "files/ssl/page_displays_insecure_content.html", | 631 "/ssl/page_displays_insecure_content.html", |
638 test_server()->host_port_pair(), | 632 embedded_test_server()->host_port_pair(), &replacement_path); |
639 &replacement_path)); | |
640 | 633 |
641 ui_test_utils::NavigateToURL(browser(), | 634 ui_test_utils::NavigateToURL(browser(), |
642 https_server_expired_.GetURL(replacement_path)); | 635 https_server_expired_.GetURL(replacement_path)); |
643 | 636 |
644 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 637 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
645 CheckAuthenticationBrokenState( | 638 CheckAuthenticationBrokenState( |
646 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 639 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
647 | 640 |
648 ProceedThroughInterstitial(tab); | 641 ProceedThroughInterstitial(tab); |
649 | 642 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 #define MAYBE_TestOKHTTPS DISABLED_TestOKHTTPS | 728 #define MAYBE_TestOKHTTPS DISABLED_TestOKHTTPS |
736 #else | 729 #else |
737 #define MAYBE_TestOKHTTPS TestOKHTTPS | 730 #define MAYBE_TestOKHTTPS TestOKHTTPS |
738 #endif | 731 #endif |
739 | 732 |
740 // Visits a page over OK https: | 733 // Visits a page over OK https: |
741 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestOKHTTPS) { | 734 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestOKHTTPS) { |
742 ASSERT_TRUE(https_server_.Start()); | 735 ASSERT_TRUE(https_server_.Start()); |
743 | 736 |
744 ui_test_utils::NavigateToURL(browser(), | 737 ui_test_utils::NavigateToURL(browser(), |
745 https_server_.GetURL("files/ssl/google.html")); | 738 https_server_.GetURL("/ssl/google.html")); |
746 | 739 |
747 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), | 740 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), |
748 AuthState::NONE); | 741 AuthState::NONE); |
749 } | 742 } |
750 | 743 |
751 // Visits a page with https error and proceed: | 744 // Visits a page with https error and proceed: |
752 #if defined(OS_LINUX) | 745 #if defined(OS_LINUX) |
753 // flaky http://crbug.com/396462 | 746 // flaky http://crbug.com/396462 |
754 #define MAYBE_TestHTTPSExpiredCertAndProceed \ | 747 #define MAYBE_TestHTTPSExpiredCertAndProceed \ |
755 DISABLED_TestHTTPSExpiredCertAndProceed | 748 DISABLED_TestHTTPSExpiredCertAndProceed |
756 #else | 749 #else |
757 #define MAYBE_TestHTTPSExpiredCertAndProceed TestHTTPSExpiredCertAndProceed | 750 #define MAYBE_TestHTTPSExpiredCertAndProceed TestHTTPSExpiredCertAndProceed |
758 #endif | 751 #endif |
759 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSExpiredCertAndProceed) { | 752 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSExpiredCertAndProceed) { |
760 ASSERT_TRUE(https_server_expired_.Start()); | 753 ASSERT_TRUE(https_server_expired_.Start()); |
761 | 754 |
762 ui_test_utils::NavigateToURL(browser(), | 755 ui_test_utils::NavigateToURL( |
763 https_server_expired_.GetURL("files/ssl/google.html")); | 756 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
764 | 757 |
765 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 758 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
766 CheckAuthenticationBrokenState( | 759 CheckAuthenticationBrokenState( |
767 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 760 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
768 | 761 |
769 ProceedThroughInterstitial(tab); | 762 ProceedThroughInterstitial(tab); |
770 | 763 |
771 CheckAuthenticationBrokenState( | 764 CheckAuthenticationBrokenState( |
772 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 765 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
773 } | 766 } |
774 | 767 |
775 #ifndef NEDBUG | 768 #ifndef NEDBUG |
776 // Flaky on Windows debug (http://crbug.com/280537). | 769 // Flaky on Windows debug (http://crbug.com/280537). |
777 #define MAYBE_TestHTTPSExpiredCertAndDontProceed \ | 770 #define MAYBE_TestHTTPSExpiredCertAndDontProceed \ |
778 DISABLED_TestHTTPSExpiredCertAndDontProceed | 771 DISABLED_TestHTTPSExpiredCertAndDontProceed |
779 #else | 772 #else |
780 #define MAYBE_TestHTTPSExpiredCertAndDontProceed \ | 773 #define MAYBE_TestHTTPSExpiredCertAndDontProceed \ |
781 TestHTTPSExpiredCertAndDontProceed | 774 TestHTTPSExpiredCertAndDontProceed |
782 #endif | 775 #endif |
783 | 776 |
784 // Visits a page with https error and don't proceed (and ensure we can still | 777 // Visits a page with https error and don't proceed (and ensure we can still |
785 // navigate at that point): | 778 // navigate at that point): |
786 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSExpiredCertAndDontProceed) { | 779 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSExpiredCertAndDontProceed) { |
787 ASSERT_TRUE(test_server()->Start()); | 780 ASSERT_TRUE(embedded_test_server()->Start()); |
788 ASSERT_TRUE(https_server_.Start()); | 781 ASSERT_TRUE(https_server_.Start()); |
789 ASSERT_TRUE(https_server_expired_.Start()); | 782 ASSERT_TRUE(https_server_expired_.Start()); |
790 | 783 |
791 // First navigate to an OK page. | 784 // First navigate to an OK page. |
792 ui_test_utils::NavigateToURL(browser(), | 785 ui_test_utils::NavigateToURL(browser(), |
793 https_server_.GetURL("files/ssl/google.html")); | 786 https_server_.GetURL("/ssl/google.html")); |
794 | 787 |
795 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 788 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
796 NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 789 NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
797 ASSERT_TRUE(entry); | 790 ASSERT_TRUE(entry); |
798 | 791 |
799 GURL cross_site_url = | 792 GURL cross_site_url = https_server_expired_.GetURL("/ssl/google.html"); |
800 https_server_expired_.GetURL("files/ssl/google.html"); | |
801 // Change the host name from 127.0.0.1 to localhost so it triggers a | 793 // Change the host name from 127.0.0.1 to localhost so it triggers a |
802 // cross-site navigation so we can test http://crbug.com/5800 is gone. | 794 // cross-site navigation so we can test http://crbug.com/5800 is gone. |
803 ASSERT_EQ("127.0.0.1", cross_site_url.host()); | 795 ASSERT_EQ("127.0.0.1", cross_site_url.host()); |
804 GURL::Replacements replacements; | 796 GURL::Replacements replacements; |
805 replacements.SetHostStr("localhost"); | 797 replacements.SetHostStr("localhost"); |
806 cross_site_url = cross_site_url.ReplaceComponents(replacements); | 798 cross_site_url = cross_site_url.ReplaceComponents(replacements); |
807 | 799 |
808 // Now go to a bad HTTPS page. | 800 // Now go to a bad HTTPS page. |
809 ui_test_utils::NavigateToURL(browser(), cross_site_url); | 801 ui_test_utils::NavigateToURL(browser(), cross_site_url); |
810 | 802 |
811 // An interstitial should be showing. | 803 // An interstitial should be showing. |
812 CheckAuthenticationBrokenState(tab, | 804 CheckAuthenticationBrokenState(tab, |
813 net::CERT_STATUS_COMMON_NAME_INVALID, | 805 net::CERT_STATUS_COMMON_NAME_INVALID, |
814 AuthState::SHOWING_INTERSTITIAL); | 806 AuthState::SHOWING_INTERSTITIAL); |
815 | 807 |
816 // Simulate user clicking "Take me back". | 808 // Simulate user clicking "Take me back". |
817 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 809 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
818 ASSERT_TRUE(interstitial_page); | 810 ASSERT_TRUE(interstitial_page); |
819 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 811 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
820 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 812 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
821 interstitial_page->DontProceed(); | 813 interstitial_page->DontProceed(); |
822 | 814 |
823 // We should be back to the original good page. | 815 // We should be back to the original good page. |
824 CheckAuthenticatedState(tab, AuthState::NONE); | 816 CheckAuthenticatedState(tab, AuthState::NONE); |
825 | 817 |
826 // Try to navigate to a new page. (to make sure bug 5800 is fixed). | 818 // Try to navigate to a new page. (to make sure bug 5800 is fixed). |
827 ui_test_utils::NavigateToURL(browser(), | 819 ui_test_utils::NavigateToURL( |
828 test_server()->GetURL("files/ssl/google.html")); | 820 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
829 CheckUnauthenticatedState(tab, AuthState::NONE); | 821 CheckUnauthenticatedState(tab, AuthState::NONE); |
830 } | 822 } |
831 | 823 |
832 // Test that localhost pages don't show an interstitial. | 824 // Test that localhost pages don't show an interstitial. |
833 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors, | 825 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors, |
834 TestNoInterstitialOnLocalhost) { | 826 TestNoInterstitialOnLocalhost) { |
835 ASSERT_TRUE(https_server_.Start()); | 827 ASSERT_TRUE(https_server_.Start()); |
836 | 828 |
837 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 829 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
838 | 830 |
839 // Navigate to a localhost page. | 831 // Navigate to a localhost page. |
840 GURL url = https_server_.GetURL("files/ssl/page_with_subresource.html"); | 832 GURL url = https_server_.GetURL("/ssl/page_with_subresource.html"); |
841 GURL::Replacements replacements; | 833 GURL::Replacements replacements; |
842 std::string new_host("localhost"); | 834 std::string new_host("localhost"); |
843 replacements.SetHostStr(new_host); | 835 replacements.SetHostStr(new_host); |
844 url = url.ReplaceComponents(replacements); | 836 url = url.ReplaceComponents(replacements); |
845 | 837 |
846 ui_test_utils::NavigateToURL(browser(), url); | 838 ui_test_utils::NavigateToURL(browser(), url); |
847 | 839 |
848 // We should see no interstitial, but we should have an error | 840 // We should see no interstitial, but we should have an error |
849 // (red-crossed-out-https) in the URL bar. | 841 // (red-crossed-out-https) in the URL bar. |
850 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 842 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
(...skipping 23 matching lines...) Expand all Loading... |
874 content::WaitForInterstitialAttach(clock_tab); | 866 content::WaitForInterstitialAttach(clock_tab); |
875 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); | 867 InterstitialPage* clock_interstitial = clock_tab->GetInterstitialPage(); |
876 ASSERT_TRUE(clock_interstitial); | 868 ASSERT_TRUE(clock_interstitial); |
877 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, | 869 EXPECT_EQ(BadClockBlockingPage::kTypeForTesting, |
878 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); | 870 clock_interstitial->GetDelegateForTesting()->GetTypeForTesting()); |
879 } | 871 } |
880 | 872 |
881 // Visits a page with https error and then goes back using Browser::GoBack. | 873 // Visits a page with https error and then goes back using Browser::GoBack. |
882 IN_PROC_BROWSER_TEST_F(SSLUITest, | 874 IN_PROC_BROWSER_TEST_F(SSLUITest, |
883 TestHTTPSExpiredCertAndGoBackViaButton) { | 875 TestHTTPSExpiredCertAndGoBackViaButton) { |
884 ASSERT_TRUE(test_server()->Start()); | 876 ASSERT_TRUE(embedded_test_server()->Start()); |
885 ASSERT_TRUE(https_server_expired_.Start()); | 877 ASSERT_TRUE(https_server_expired_.Start()); |
886 | 878 |
887 // First navigate to an HTTP page. | 879 // First navigate to an HTTP page. |
888 ui_test_utils::NavigateToURL(browser(), | 880 ui_test_utils::NavigateToURL( |
889 test_server()->GetURL("files/ssl/google.html")); | 881 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
890 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 882 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
891 NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 883 NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
892 ASSERT_TRUE(entry); | 884 ASSERT_TRUE(entry); |
893 | 885 |
894 // Now go to a bad HTTPS page that shows an interstitial. | 886 // Now go to a bad HTTPS page that shows an interstitial. |
895 ui_test_utils::NavigateToURL(browser(), | 887 ui_test_utils::NavigateToURL( |
896 https_server_expired_.GetURL("files/ssl/google.html")); | 888 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
897 CheckAuthenticationBrokenState( | 889 CheckAuthenticationBrokenState( |
898 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 890 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
899 | 891 |
900 ProvisionalLoadWaiter load_failed_observer(tab); | 892 ProvisionalLoadWaiter load_failed_observer(tab); |
901 | 893 |
902 // Simulate user clicking on back button (crbug.com/39248). | 894 // Simulate user clicking on back button (crbug.com/39248). |
903 chrome::GoBack(browser(), CURRENT_TAB); | 895 chrome::GoBack(browser(), CURRENT_TAB); |
904 | 896 |
905 // Wait until we hear the load failure, and make sure we haven't swapped out | 897 // Wait until we hear the load failure, and make sure we haven't swapped out |
906 // the previous page. Prevents regression of http://crbug.com/82667. | 898 // the previous page. Prevents regression of http://crbug.com/82667. |
907 // TODO(creis/nick): Move the swapped-out part of this test into content | 899 // TODO(creis/nick): Move the swapped-out part of this test into content |
908 // and remove IsRenderViewHostSwappedOut from the public API. | 900 // and remove IsRenderViewHostSwappedOut from the public API. |
909 load_failed_observer.Wait(); | 901 load_failed_observer.Wait(); |
910 EXPECT_FALSE(content::RenderFrameHostTester::IsRenderFrameHostSwappedOut( | 902 EXPECT_FALSE(content::RenderFrameHostTester::IsRenderFrameHostSwappedOut( |
911 tab->GetMainFrame())); | 903 tab->GetMainFrame())); |
912 | 904 |
913 // We should be back at the original good page. | 905 // We should be back at the original good page. |
914 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> | 906 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> |
915 GetInterstitialPage()); | 907 GetInterstitialPage()); |
916 CheckUnauthenticatedState(tab, AuthState::NONE); | 908 CheckUnauthenticatedState(tab, AuthState::NONE); |
917 } | 909 } |
918 | 910 |
919 // Visits a page with https error and then goes back using GoToOffset. | 911 // Visits a page with https error and then goes back using GoToOffset. |
920 // Disabled because its flaky: http://crbug.com/40932, http://crbug.com/43575. | 912 // Disabled because its flaky: http://crbug.com/40932, http://crbug.com/43575. |
921 IN_PROC_BROWSER_TEST_F(SSLUITest, | 913 IN_PROC_BROWSER_TEST_F(SSLUITest, |
922 TestHTTPSExpiredCertAndGoBackViaMenu) { | 914 TestHTTPSExpiredCertAndGoBackViaMenu) { |
923 ASSERT_TRUE(test_server()->Start()); | 915 ASSERT_TRUE(embedded_test_server()->Start()); |
924 ASSERT_TRUE(https_server_expired_.Start()); | 916 ASSERT_TRUE(https_server_expired_.Start()); |
925 | 917 |
926 // First navigate to an HTTP page. | 918 // First navigate to an HTTP page. |
927 ui_test_utils::NavigateToURL(browser(), | 919 ui_test_utils::NavigateToURL( |
928 test_server()->GetURL("files/ssl/google.html")); | 920 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
929 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 921 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
930 NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 922 NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
931 ASSERT_TRUE(entry); | 923 ASSERT_TRUE(entry); |
932 | 924 |
933 // Now go to a bad HTTPS page that shows an interstitial. | 925 // Now go to a bad HTTPS page that shows an interstitial. |
934 ui_test_utils::NavigateToURL(browser(), | 926 ui_test_utils::NavigateToURL( |
935 https_server_expired_.GetURL("files/ssl/google.html")); | 927 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
936 CheckAuthenticationBrokenState( | 928 CheckAuthenticationBrokenState( |
937 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 929 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
938 | 930 |
939 // Simulate user clicking and holding on back button (crbug.com/37215). | 931 // Simulate user clicking and holding on back button (crbug.com/37215). |
940 tab->GetController().GoToOffset(-1); | 932 tab->GetController().GoToOffset(-1); |
941 | 933 |
942 // We should be back at the original good page. | 934 // We should be back at the original good page. |
943 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> | 935 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> |
944 GetInterstitialPage()); | 936 GetInterstitialPage()); |
945 CheckUnauthenticatedState(tab, AuthState::NONE); | 937 CheckUnauthenticatedState(tab, AuthState::NONE); |
946 } | 938 } |
947 | 939 |
948 // Visits a page with https error and then goes forward using GoToOffset. | 940 // Visits a page with https error and then goes forward using GoToOffset. |
949 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) { | 941 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTPSExpiredCertAndGoForward) { |
950 ASSERT_TRUE(test_server()->Start()); | 942 ASSERT_TRUE(embedded_test_server()->Start()); |
951 ASSERT_TRUE(https_server_expired_.Start()); | 943 ASSERT_TRUE(https_server_expired_.Start()); |
952 | 944 |
953 // First navigate to two HTTP pages. | 945 // First navigate to two HTTP pages. |
954 ui_test_utils::NavigateToURL(browser(), | 946 ui_test_utils::NavigateToURL( |
955 test_server()->GetURL("files/ssl/google.html")); | 947 browser(), embedded_test_server()->GetURL("/ssl/google.html")); |
956 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 948 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
957 NavigationEntry* entry1 = tab->GetController().GetActiveEntry(); | 949 NavigationEntry* entry1 = tab->GetController().GetActiveEntry(); |
958 ASSERT_TRUE(entry1); | 950 ASSERT_TRUE(entry1); |
959 ui_test_utils::NavigateToURL(browser(), | 951 ui_test_utils::NavigateToURL( |
960 test_server()->GetURL("files/ssl/blank_page.html")); | 952 browser(), embedded_test_server()->GetURL("/ssl/blank_page.html")); |
961 NavigationEntry* entry2 = tab->GetController().GetActiveEntry(); | 953 NavigationEntry* entry2 = tab->GetController().GetActiveEntry(); |
962 ASSERT_TRUE(entry2); | 954 ASSERT_TRUE(entry2); |
963 | 955 |
964 // Now go back so that a page is in the forward history. | 956 // Now go back so that a page is in the forward history. |
965 { | 957 { |
966 content::WindowedNotificationObserver observer( | 958 content::WindowedNotificationObserver observer( |
967 content::NOTIFICATION_LOAD_STOP, | 959 content::NOTIFICATION_LOAD_STOP, |
968 content::Source<NavigationController>(&tab->GetController())); | 960 content::Source<NavigationController>(&tab->GetController())); |
969 tab->GetController().GoBack(); | 961 tab->GetController().GoBack(); |
970 observer.Wait(); | 962 observer.Wait(); |
971 } | 963 } |
972 ASSERT_TRUE(tab->GetController().CanGoForward()); | 964 ASSERT_TRUE(tab->GetController().CanGoForward()); |
973 NavigationEntry* entry3 = tab->GetController().GetActiveEntry(); | 965 NavigationEntry* entry3 = tab->GetController().GetActiveEntry(); |
974 ASSERT_TRUE(entry1 == entry3); | 966 ASSERT_TRUE(entry1 == entry3); |
975 | 967 |
976 // Now go to a bad HTTPS page that shows an interstitial. | 968 // Now go to a bad HTTPS page that shows an interstitial. |
977 ui_test_utils::NavigateToURL(browser(), | 969 ui_test_utils::NavigateToURL( |
978 https_server_expired_.GetURL("files/ssl/google.html")); | 970 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
979 CheckAuthenticationBrokenState( | 971 CheckAuthenticationBrokenState( |
980 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 972 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
981 | 973 |
982 // Simulate user clicking and holding on forward button. | 974 // Simulate user clicking and holding on forward button. |
983 { | 975 { |
984 content::WindowedNotificationObserver observer( | 976 content::WindowedNotificationObserver observer( |
985 content::NOTIFICATION_LOAD_STOP, | 977 content::NOTIFICATION_LOAD_STOP, |
986 content::Source<NavigationController>(&tab->GetController())); | 978 content::Source<NavigationController>(&tab->GetController())); |
987 tab->GetController().GoToOffset(1); | 979 tab->GetController().GoToOffset(1); |
988 observer.Wait(); | 980 observer.Wait(); |
(...skipping 11 matching lines...) Expand all Loading... |
1000 // Visit a HTTP page which request WSS connection to a server providing invalid | 992 // Visit a HTTP page which request WSS connection to a server providing invalid |
1001 // certificate. Close the page while WSS connection waits for SSLManager's | 993 // certificate. Close the page while WSS connection waits for SSLManager's |
1002 // response from UI thread. | 994 // response from UI thread. |
1003 // Disabled on Windows because it was flaking on XP Tests (1). crbug.com/165258 | 995 // Disabled on Windows because it was flaking on XP Tests (1). crbug.com/165258 |
1004 #if defined(OS_WIN) | 996 #if defined(OS_WIN) |
1005 #define MAYBE_TestWSSInvalidCertAndClose DISABLED_TestWSSInvalidCertAndClose | 997 #define MAYBE_TestWSSInvalidCertAndClose DISABLED_TestWSSInvalidCertAndClose |
1006 #else | 998 #else |
1007 #define MAYBE_TestWSSInvalidCertAndClose TestWSSInvalidCertAndClose | 999 #define MAYBE_TestWSSInvalidCertAndClose TestWSSInvalidCertAndClose |
1008 #endif | 1000 #endif |
1009 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestWSSInvalidCertAndClose) { | 1001 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestWSSInvalidCertAndClose) { |
1010 ASSERT_TRUE(test_server()->Start()); | 1002 ASSERT_TRUE(embedded_test_server()->Start()); |
1011 ASSERT_TRUE(wss_server_expired_.Start()); | 1003 ASSERT_TRUE(wss_server_expired_.Start()); |
1012 | 1004 |
1013 // Setup page title observer. | 1005 // Setup page title observer. |
1014 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1006 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1015 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | 1007 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); |
1016 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 1008 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
1017 | 1009 |
1018 // Create GURLs to test pages. | 1010 // Create GURLs to test pages. |
1019 std::string master_url_path = base::StringPrintf("%s?%d", | 1011 std::string master_url_path = base::StringPrintf( |
1020 test_server()->GetURL("files/ssl/wss_close.html").spec().c_str(), | 1012 "%s?%d", |
| 1013 embedded_test_server()->GetURL("/ssl/wss_close.html").spec().c_str(), |
1021 wss_server_expired_.host_port_pair().port()); | 1014 wss_server_expired_.host_port_pair().port()); |
1022 GURL master_url(master_url_path); | 1015 GURL master_url(master_url_path); |
1023 std::string slave_url_path = base::StringPrintf("%s?%d", | 1016 std::string slave_url_path = |
1024 test_server()->GetURL("files/ssl/wss_close_slave.html").spec().c_str(), | 1017 base::StringPrintf("%s?%d", embedded_test_server() |
1025 wss_server_expired_.host_port_pair().port()); | 1018 ->GetURL("/ssl/wss_close_slave.html") |
| 1019 .spec() |
| 1020 .c_str(), |
| 1021 wss_server_expired_.host_port_pair().port()); |
1026 GURL slave_url(slave_url_path); | 1022 GURL slave_url(slave_url_path); |
1027 | 1023 |
1028 // Create tabs and visit pages which keep on creating wss connections. | 1024 // Create tabs and visit pages which keep on creating wss connections. |
1029 WebContents* tabs[16]; | 1025 WebContents* tabs[16]; |
1030 for (int i = 0; i < 16; ++i) { | 1026 for (int i = 0; i < 16; ++i) { |
1031 tabs[i] = chrome::AddSelectedTabWithURL(browser(), slave_url, | 1027 tabs[i] = chrome::AddSelectedTabWithURL(browser(), slave_url, |
1032 ui::PAGE_TRANSITION_LINK); | 1028 ui::PAGE_TRANSITION_LINK); |
1033 } | 1029 } |
1034 chrome::SelectNextTab(browser()); | 1030 chrome::SelectNextTab(browser()); |
1035 | 1031 |
1036 // Visit a page which waits for one TLS handshake failure. | 1032 // Visit a page which waits for one TLS handshake failure. |
1037 // The title will be changed to 'PASS'. | 1033 // The title will be changed to 'PASS'. |
1038 ui_test_utils::NavigateToURL(browser(), master_url); | 1034 ui_test_utils::NavigateToURL(browser(), master_url); |
1039 const base::string16 result = watcher.WaitAndGetTitle(); | 1035 const base::string16 result = watcher.WaitAndGetTitle(); |
1040 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); | 1036 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); |
1041 | 1037 |
1042 // Close tabs which contains the test page. | 1038 // Close tabs which contains the test page. |
1043 for (int i = 0; i < 16; ++i) | 1039 for (int i = 0; i < 16; ++i) |
1044 chrome::CloseWebContents(browser(), tabs[i], false); | 1040 chrome::CloseWebContents(browser(), tabs[i], false); |
1045 chrome::CloseWebContents(browser(), tab, false); | 1041 chrome::CloseWebContents(browser(), tab, false); |
1046 } | 1042 } |
1047 | 1043 |
1048 // Visit a HTTPS page and proceeds despite an invalid certificate. The page | 1044 // Visit a HTTPS page and proceeds despite an invalid certificate. The page |
1049 // requests WSS connection to the same origin host to check if WSS connection | 1045 // requests WSS connection to the same origin host to check if WSS connection |
1050 // share certificates policy with HTTPS correcly. | 1046 // share certificates policy with HTTPS correcly. |
1051 IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) { | 1047 IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) { |
1052 ASSERT_TRUE(test_server()->Start()); | 1048 ASSERT_TRUE(embedded_test_server()->Start()); |
1053 ASSERT_TRUE(wss_server_expired_.Start()); | 1049 ASSERT_TRUE(wss_server_expired_.Start()); |
1054 | 1050 |
1055 // Setup page title observer. | 1051 // Setup page title observer. |
1056 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1052 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1057 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | 1053 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); |
1058 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 1054 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
1059 | 1055 |
1060 // Visit bad HTTPS page. | 1056 // Visit bad HTTPS page. |
1061 GURL::Replacements replacements; | 1057 GURL::Replacements replacements; |
1062 replacements.SetSchemeStr("https"); | 1058 replacements.SetSchemeStr("https"); |
1063 ui_test_utils::NavigateToURL( | 1059 ui_test_utils::NavigateToURL(browser(), |
1064 browser(), | 1060 wss_server_expired_.GetURL("connect_check.html") |
1065 wss_server_expired_.GetURL( | 1061 .ReplaceComponents(replacements)); |
1066 "connect_check.html").ReplaceComponents(replacements)); | |
1067 CheckAuthenticationBrokenState( | 1062 CheckAuthenticationBrokenState( |
1068 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1063 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
1069 | 1064 |
1070 // Proceed anyway. | 1065 // Proceed anyway. |
1071 ProceedThroughInterstitial(tab); | 1066 ProceedThroughInterstitial(tab); |
1072 | 1067 |
1073 // Test page run a WebSocket wss connection test. The result will be shown | 1068 // Test page run a WebSocket wss connection test. The result will be shown |
1074 // as page title. | 1069 // as page title. |
1075 const base::string16 result = watcher.WaitAndGetTitle(); | 1070 const base::string16 result = watcher.WaitAndGetTitle(); |
1076 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); | 1071 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 options.request_client_certificate = true; | 1149 options.request_client_certificate = true; |
1155 base::FilePath ca_path = net::GetTestCertsDirectory().Append( | 1150 base::FilePath ca_path = net::GetTestCertsDirectory().Append( |
1156 FILE_PATH_LITERAL("websocket_cacert.pem")); | 1151 FILE_PATH_LITERAL("websocket_cacert.pem")); |
1157 options.client_authorities.push_back(ca_path); | 1152 options.client_authorities.push_back(ca_path); |
1158 net::SpawnedTestServer wss_server(net::SpawnedTestServer::TYPE_WSS, | 1153 net::SpawnedTestServer wss_server(net::SpawnedTestServer::TYPE_WSS, |
1159 options, | 1154 options, |
1160 net::GetWebSocketTestDataDirectory()); | 1155 net::GetWebSocketTestDataDirectory()); |
1161 ASSERT_TRUE(wss_server.Start()); | 1156 ASSERT_TRUE(wss_server.Start()); |
1162 GURL::Replacements replacements; | 1157 GURL::Replacements replacements; |
1163 replacements.SetSchemeStr("https"); | 1158 replacements.SetSchemeStr("https"); |
1164 GURL url = wss_server.GetURL("connect_check.html").ReplaceComponents( | 1159 GURL url = |
1165 replacements); | 1160 wss_server.GetURL("connect_check.html").ReplaceComponents(replacements); |
1166 | 1161 |
1167 // Setup page title observer. | 1162 // Setup page title observer. |
1168 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1163 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1169 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | 1164 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); |
1170 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 1165 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
1171 | 1166 |
1172 // Add an entry into AutoSelectCertificateForUrls policy for automatic client | 1167 // Add an entry into AutoSelectCertificateForUrls policy for automatic client |
1173 // cert selection. | 1168 // cert selection. |
1174 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 1169 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
1175 DCHECK(profile); | 1170 DCHECK(profile); |
(...skipping 25 matching lines...) Expand all Loading... |
1201 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry | 1196 #define MAYBE_TestHTTPSErrorWithNoNavEntry TestHTTPSErrorWithNoNavEntry |
1202 #endif // defined(OS_CHROMEOS) | 1197 #endif // defined(OS_CHROMEOS) |
1203 | 1198 |
1204 // Open a page with a HTTPS error in a tab with no prior navigation (through a | 1199 // Open a page with a HTTPS error in a tab with no prior navigation (through a |
1205 // link with a blank target). This is to test that the lack of navigation entry | 1200 // link with a blank target). This is to test that the lack of navigation entry |
1206 // does not cause any problems (it was causing a crasher, see | 1201 // does not cause any problems (it was causing a crasher, see |
1207 // http://crbug.com/19941). | 1202 // http://crbug.com/19941). |
1208 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSErrorWithNoNavEntry) { | 1203 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSErrorWithNoNavEntry) { |
1209 ASSERT_TRUE(https_server_expired_.Start()); | 1204 ASSERT_TRUE(https_server_expired_.Start()); |
1210 | 1205 |
1211 GURL url = https_server_expired_.GetURL("files/ssl/google.htm"); | 1206 GURL url = https_server_expired_.GetURL("/ssl/google.htm"); |
1212 WebContents* tab2 = chrome::AddSelectedTabWithURL( | 1207 WebContents* tab2 = chrome::AddSelectedTabWithURL( |
1213 browser(), url, ui::PAGE_TRANSITION_TYPED); | 1208 browser(), url, ui::PAGE_TRANSITION_TYPED); |
1214 content::WaitForLoadStop(tab2); | 1209 content::WaitForLoadStop(tab2); |
1215 | 1210 |
1216 // Verify our assumption that there was no prior navigation. | 1211 // Verify our assumption that there was no prior navigation. |
1217 EXPECT_FALSE(chrome::CanGoBack(browser())); | 1212 EXPECT_FALSE(chrome::CanGoBack(browser())); |
1218 | 1213 |
1219 // We should have an interstitial page showing. | 1214 // We should have an interstitial page showing. |
1220 ASSERT_TRUE(tab2->GetInterstitialPage()); | 1215 ASSERT_TRUE(tab2->GetInterstitialPage()); |
1221 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, tab2->GetInterstitialPage() | 1216 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, tab2->GetInterstitialPage() |
1222 ->GetDelegateForTesting() | 1217 ->GetDelegateForTesting() |
1223 ->GetTypeForTesting()); | 1218 ->GetTypeForTesting()); |
1224 } | 1219 } |
1225 | 1220 |
1226 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadHTTPSDownload) { | 1221 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadHTTPSDownload) { |
1227 ASSERT_TRUE(test_server()->Start()); | 1222 ASSERT_TRUE(embedded_test_server()->Start()); |
1228 ASSERT_TRUE(https_server_expired_.Start()); | 1223 ASSERT_TRUE(https_server_expired_.Start()); |
1229 GURL url_non_dangerous = test_server()->GetURL(std::string()); | 1224 GURL url_non_dangerous = embedded_test_server()->GetURL("/"); |
1230 GURL url_dangerous = | 1225 GURL url_dangerous = |
1231 https_server_expired_.GetURL("files/downloads/dangerous/dangerous.exe"); | 1226 https_server_expired_.GetURL("/downloads/dangerous/dangerous.exe"); |
1232 base::ScopedTempDir downloads_directory_; | 1227 base::ScopedTempDir downloads_directory_; |
1233 | 1228 |
1234 // Need empty temp dir to avoid having Chrome ask us for a new filename | 1229 // Need empty temp dir to avoid having Chrome ask us for a new filename |
1235 // when we've downloaded dangerous.exe one hundred times. | 1230 // when we've downloaded dangerous.exe one hundred times. |
1236 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); | 1231 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); |
1237 | 1232 |
1238 browser()->profile()->GetPrefs()->SetFilePath( | 1233 browser()->profile()->GetPrefs()->SetFilePath( |
1239 prefs::kDownloadDefaultDirectory, | 1234 prefs::kDownloadDefaultDirectory, |
1240 downloads_directory_.path()); | 1235 downloads_directory_.path()); |
1241 | 1236 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 | 1291 |
1297 #if defined(OS_WIN) | 1292 #if defined(OS_WIN) |
1298 // http://crbug.com/152940 Flaky on win. | 1293 // http://crbug.com/152940 Flaky on win. |
1299 #define MAYBE_TestDisplaysInsecureContent DISABLED_TestDisplaysInsecureContent | 1294 #define MAYBE_TestDisplaysInsecureContent DISABLED_TestDisplaysInsecureContent |
1300 #else | 1295 #else |
1301 #define MAYBE_TestDisplaysInsecureContent TestDisplaysInsecureContent | 1296 #define MAYBE_TestDisplaysInsecureContent TestDisplaysInsecureContent |
1302 #endif | 1297 #endif |
1303 | 1298 |
1304 // Visits a page that displays insecure content. | 1299 // Visits a page that displays insecure content. |
1305 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestDisplaysInsecureContent) { | 1300 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestDisplaysInsecureContent) { |
1306 ASSERT_TRUE(test_server()->Start()); | 1301 ASSERT_TRUE(embedded_test_server()->Start()); |
1307 ASSERT_TRUE(https_server_.Start()); | 1302 ASSERT_TRUE(https_server_.Start()); |
1308 | 1303 |
1309 std::string replacement_path; | 1304 std::string replacement_path; |
1310 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1305 GetFilePathWithHostAndPortReplacement( |
1311 "files/ssl/page_displays_insecure_content.html", | 1306 "/ssl/page_displays_insecure_content.html", |
1312 test_server()->host_port_pair(), | 1307 embedded_test_server()->host_port_pair(), &replacement_path); |
1313 &replacement_path)); | |
1314 | 1308 |
1315 // Load a page that displays insecure content. | 1309 // Load a page that displays insecure content. |
1316 ui_test_utils::NavigateToURL(browser(), | 1310 ui_test_utils::NavigateToURL(browser(), |
1317 https_server_.GetURL(replacement_path)); | 1311 https_server_.GetURL(replacement_path)); |
1318 | 1312 |
1319 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), | 1313 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), |
1320 AuthState::DISPLAYED_INSECURE_CONTENT); | 1314 AuthState::DISPLAYED_INSECURE_CONTENT); |
1321 } | 1315 } |
1322 | 1316 |
1323 // Test that if the user proceeds and the checkbox is checked, a report | 1317 // Test that if the user proceeds and the checkbox is checked, a report |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 TestBadClockReporting( | 1411 TestBadClockReporting( |
1418 certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN, | 1412 certificate_reporting_test_utils::EXTENDED_REPORTING_OPT_IN, |
1419 expect_report, browser()); | 1413 expect_report, browser()); |
1420 } | 1414 } |
1421 | 1415 |
1422 // Visits a page that runs insecure content and tries to suppress the insecure | 1416 // Visits a page that runs insecure content and tries to suppress the insecure |
1423 // content warnings by randomizing location.hash. | 1417 // content warnings by randomizing location.hash. |
1424 // Based on http://crbug.com/8706 | 1418 // Based on http://crbug.com/8706 |
1425 IN_PROC_BROWSER_TEST_F(SSLUITest, | 1419 IN_PROC_BROWSER_TEST_F(SSLUITest, |
1426 TestRunsInsecuredContentRandomizeHash) { | 1420 TestRunsInsecuredContentRandomizeHash) { |
1427 ASSERT_TRUE(test_server()->Start()); | 1421 ASSERT_TRUE(embedded_test_server()->Start()); |
1428 ASSERT_TRUE(https_server_.Start()); | 1422 ASSERT_TRUE(https_server_.Start()); |
1429 | 1423 |
1430 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 1424 ui_test_utils::NavigateToURL( |
1431 "files/ssl/page_runs_insecure_content.html")); | 1425 browser(), https_server_.GetURL("/ssl/page_runs_insecure_content.html")); |
1432 | 1426 |
1433 CheckAuthenticationBrokenState( | 1427 CheckAuthenticationBrokenState( |
1434 browser()->tab_strip_model()->GetActiveWebContents(), CertError::NONE, | 1428 browser()->tab_strip_model()->GetActiveWebContents(), CertError::NONE, |
1435 AuthState::RAN_INSECURE_CONTENT); | 1429 AuthState::RAN_INSECURE_CONTENT); |
1436 } | 1430 } |
1437 | 1431 |
1438 // Visits a page with unsafe content and make sure that: | 1432 // Visits a page with unsafe content and make sure that: |
1439 // - frames content is replaced with warning | 1433 // - frames content is replaced with warning |
1440 // - images and scripts are filtered out entirely | 1434 // - images and scripts are filtered out entirely |
1441 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContents) { | 1435 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContents) { |
1442 ASSERT_TRUE(https_server_.Start()); | 1436 ASSERT_TRUE(https_server_.Start()); |
1443 ASSERT_TRUE(https_server_expired_.Start()); | 1437 ASSERT_TRUE(https_server_expired_.Start()); |
1444 | 1438 |
1445 std::string replacement_path; | 1439 std::string replacement_path; |
1446 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1440 GetFilePathWithHostAndPortReplacement("/ssl/page_with_unsafe_contents.html", |
1447 "files/ssl/page_with_unsafe_contents.html", | 1441 https_server_expired_.host_port_pair(), |
1448 https_server_expired_.host_port_pair(), | 1442 &replacement_path); |
1449 &replacement_path)); | |
1450 ui_test_utils::NavigateToURL(browser(), | 1443 ui_test_utils::NavigateToURL(browser(), |
1451 https_server_.GetURL(replacement_path)); | 1444 https_server_.GetURL(replacement_path)); |
1452 | 1445 |
1453 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1446 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1454 // When the bad content is filtered, the state is expected to be | 1447 // When the bad content is filtered, the state is expected to be |
1455 // authenticated. | 1448 // authenticated. |
1456 CheckAuthenticatedState(tab, AuthState::NONE); | 1449 CheckAuthenticatedState(tab, AuthState::NONE); |
1457 | 1450 |
1458 // Because of cross-frame scripting restrictions, we cannot access the iframe | 1451 // Because of cross-frame scripting restrictions, we cannot access the iframe |
1459 // content. So to know if the frame was loaded, we just check if a popup was | 1452 // content. So to know if the frame was loaded, we just check if a popup was |
(...skipping 25 matching lines...) Expand all Loading... |
1485 #if defined(OS_LINUX) | 1478 #if defined(OS_LINUX) |
1486 // flaky http://crbug.com/396462 | 1479 // flaky http://crbug.com/396462 |
1487 #define MAYBE_TestDisplaysInsecureContentLoadedFromJS \ | 1480 #define MAYBE_TestDisplaysInsecureContentLoadedFromJS \ |
1488 DISABLED_TestDisplaysInsecureContentLoadedFromJS | 1481 DISABLED_TestDisplaysInsecureContentLoadedFromJS |
1489 #else | 1482 #else |
1490 #define MAYBE_TestDisplaysInsecureContentLoadedFromJS \ | 1483 #define MAYBE_TestDisplaysInsecureContentLoadedFromJS \ |
1491 TestDisplaysInsecureContentLoadedFromJS | 1484 TestDisplaysInsecureContentLoadedFromJS |
1492 #endif | 1485 #endif |
1493 IN_PROC_BROWSER_TEST_F(SSLUITest, | 1486 IN_PROC_BROWSER_TEST_F(SSLUITest, |
1494 MAYBE_TestDisplaysInsecureContentLoadedFromJS) { | 1487 MAYBE_TestDisplaysInsecureContentLoadedFromJS) { |
1495 ASSERT_TRUE(test_server()->Start()); | 1488 ASSERT_TRUE(embedded_test_server()->Start()); |
1496 ASSERT_TRUE(https_server_.Start()); | 1489 ASSERT_TRUE(https_server_.Start()); |
1497 | 1490 |
1498 std::string replacement_path; | 1491 std::string replacement_path; |
1499 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1492 GetFilePathWithHostAndPortReplacement( |
1500 "files/ssl/page_with_dynamic_insecure_content.html", | 1493 "/ssl/page_with_dynamic_insecure_content.html", |
1501 test_server()->host_port_pair(), | 1494 embedded_test_server()->host_port_pair(), &replacement_path); |
1502 &replacement_path)); | |
1503 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 1495 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( |
1504 replacement_path)); | 1496 replacement_path)); |
1505 | 1497 |
1506 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1498 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1507 CheckAuthenticatedState(tab, AuthState::NONE); | 1499 CheckAuthenticatedState(tab, AuthState::NONE); |
1508 | 1500 |
1509 // Load the insecure image. | 1501 // Load the insecure image. |
1510 bool js_result = false; | 1502 bool js_result = false; |
1511 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 1503 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
1512 tab, | 1504 tab, |
1513 "loadBadImage();", | 1505 "loadBadImage();", |
1514 &js_result)); | 1506 &js_result)); |
1515 EXPECT_TRUE(js_result); | 1507 EXPECT_TRUE(js_result); |
1516 | 1508 |
1517 // We should now have insecure content. | 1509 // We should now have insecure content. |
1518 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); | 1510 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); |
1519 } | 1511 } |
1520 | 1512 |
1521 // Visits two pages from the same origin: one that displays insecure content and | 1513 // Visits two pages from the same origin: one that displays insecure content and |
1522 // one that doesn't. The test checks that we do not propagate the insecure | 1514 // one that doesn't. The test checks that we do not propagate the insecure |
1523 // content state from one to the other. | 1515 // content state from one to the other. |
1524 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) { | 1516 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysInsecureContentTwoTabs) { |
1525 ASSERT_TRUE(test_server()->Start()); | 1517 ASSERT_TRUE(embedded_test_server()->Start()); |
1526 ASSERT_TRUE(https_server_.Start()); | 1518 ASSERT_TRUE(https_server_.Start()); |
1527 | 1519 |
1528 ui_test_utils::NavigateToURL(browser(), | 1520 ui_test_utils::NavigateToURL(browser(), |
1529 https_server_.GetURL("files/ssl/blank_page.html")); | 1521 https_server_.GetURL("/ssl/blank_page.html")); |
1530 | 1522 |
1531 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); | 1523 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); |
1532 | 1524 |
1533 // This tab should be fine. | 1525 // This tab should be fine. |
1534 CheckAuthenticatedState(tab1, AuthState::NONE); | 1526 CheckAuthenticatedState(tab1, AuthState::NONE); |
1535 | 1527 |
1536 // Create a new tab. | 1528 // Create a new tab. |
1537 std::string replacement_path; | 1529 std::string replacement_path; |
1538 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1530 GetFilePathWithHostAndPortReplacement( |
1539 "files/ssl/page_displays_insecure_content.html", | 1531 "/ssl/page_displays_insecure_content.html", |
1540 test_server()->host_port_pair(), | 1532 embedded_test_server()->host_port_pair(), &replacement_path); |
1541 &replacement_path)); | |
1542 | 1533 |
1543 GURL url = https_server_.GetURL(replacement_path); | 1534 GURL url = https_server_.GetURL(replacement_path); |
1544 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1535 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
1545 params.disposition = NEW_FOREGROUND_TAB; | 1536 params.disposition = NEW_FOREGROUND_TAB; |
1546 params.tabstrip_index = 0; | 1537 params.tabstrip_index = 0; |
1547 params.source_contents = tab1; | 1538 params.source_contents = tab1; |
1548 content::WindowedNotificationObserver observer( | 1539 content::WindowedNotificationObserver observer( |
1549 content::NOTIFICATION_LOAD_STOP, | 1540 content::NOTIFICATION_LOAD_STOP, |
1550 content::NotificationService::AllSources()); | 1541 content::NotificationService::AllSources()); |
1551 chrome::Navigate(¶ms); | 1542 chrome::Navigate(¶ms); |
1552 WebContents* tab2 = params.target_contents; | 1543 WebContents* tab2 = params.target_contents; |
1553 observer.Wait(); | 1544 observer.Wait(); |
1554 | 1545 |
1555 // The new tab has insecure content. | 1546 // The new tab has insecure content. |
1556 CheckAuthenticatedState(tab2, AuthState::DISPLAYED_INSECURE_CONTENT); | 1547 CheckAuthenticatedState(tab2, AuthState::DISPLAYED_INSECURE_CONTENT); |
1557 | 1548 |
1558 // The original tab should not be contaminated. | 1549 // The original tab should not be contaminated. |
1559 CheckAuthenticatedState(tab1, AuthState::NONE); | 1550 CheckAuthenticatedState(tab1, AuthState::NONE); |
1560 } | 1551 } |
1561 | 1552 |
1562 // Visits two pages from the same origin: one that runs insecure content and one | 1553 // Visits two pages from the same origin: one that runs insecure content and one |
1563 // that doesn't. The test checks that we propagate the insecure content state | 1554 // that doesn't. The test checks that we propagate the insecure content state |
1564 // from one to the other. | 1555 // from one to the other. |
1565 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { | 1556 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRunsInsecureContentTwoTabs) { |
1566 ASSERT_TRUE(test_server()->Start()); | 1557 ASSERT_TRUE(embedded_test_server()->Start()); |
1567 ASSERT_TRUE(https_server_.Start()); | 1558 ASSERT_TRUE(https_server_.Start()); |
1568 | 1559 |
1569 ui_test_utils::NavigateToURL(browser(), | 1560 ui_test_utils::NavigateToURL(browser(), |
1570 https_server_.GetURL("files/ssl/blank_page.html")); | 1561 https_server_.GetURL("/ssl/blank_page.html")); |
1571 | 1562 |
1572 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); | 1563 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); |
1573 | 1564 |
1574 // This tab should be fine. | 1565 // This tab should be fine. |
1575 CheckAuthenticatedState(tab1, AuthState::NONE); | 1566 CheckAuthenticatedState(tab1, AuthState::NONE); |
1576 | 1567 |
1577 std::string replacement_path; | 1568 std::string replacement_path; |
1578 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1569 GetFilePathWithHostAndPortReplacement( |
1579 "files/ssl/page_runs_insecure_content.html", | 1570 "/ssl/page_runs_insecure_content.html", |
1580 test_server()->host_port_pair(), | 1571 embedded_test_server()->host_port_pair(), &replacement_path); |
1581 &replacement_path)); | |
1582 | 1572 |
1583 // Create a new tab in the same process. Using a NEW_FOREGROUND_TAB | 1573 // Create a new tab in the same process. Using a NEW_FOREGROUND_TAB |
1584 // disposition won't usually stay in the same process, but this works | 1574 // disposition won't usually stay in the same process, but this works |
1585 // because we are using process-per-site in SetUpCommandLine. | 1575 // because we are using process-per-site in SetUpCommandLine. |
1586 GURL url = https_server_.GetURL(replacement_path); | 1576 GURL url = https_server_.GetURL(replacement_path); |
1587 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1577 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
1588 params.disposition = NEW_FOREGROUND_TAB; | 1578 params.disposition = NEW_FOREGROUND_TAB; |
1589 params.source_contents = tab1; | 1579 params.source_contents = tab1; |
1590 content::WindowedNotificationObserver observer( | 1580 content::WindowedNotificationObserver observer( |
1591 content::NOTIFICATION_LOAD_STOP, | 1581 content::NOTIFICATION_LOAD_STOP, |
(...skipping 12 matching lines...) Expand all Loading... |
1604 // Which means the origin for the first tab has also been contaminated with | 1594 // Which means the origin for the first tab has also been contaminated with |
1605 // insecure content. | 1595 // insecure content. |
1606 CheckAuthenticationBrokenState( | 1596 CheckAuthenticationBrokenState( |
1607 tab1, CertError::NONE, AuthState::RAN_INSECURE_CONTENT); | 1597 tab1, CertError::NONE, AuthState::RAN_INSECURE_CONTENT); |
1608 } | 1598 } |
1609 | 1599 |
1610 // Visits a page with an image over http. Visits another page over https | 1600 // Visits a page with an image over http. Visits another page over https |
1611 // referencing that same image over http (hoping it is coming from the webcore | 1601 // referencing that same image over http (hoping it is coming from the webcore |
1612 // memory cache). | 1602 // memory cache). |
1613 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysCachedInsecureContent) { | 1603 IN_PROC_BROWSER_TEST_F(SSLUITest, TestDisplaysCachedInsecureContent) { |
1614 ASSERT_TRUE(test_server()->Start()); | 1604 ASSERT_TRUE(embedded_test_server()->Start()); |
1615 ASSERT_TRUE(https_server_.Start()); | 1605 ASSERT_TRUE(https_server_.Start()); |
1616 | 1606 |
1617 std::string replacement_path; | 1607 std::string replacement_path; |
1618 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1608 GetFilePathWithHostAndPortReplacement( |
1619 "files/ssl/page_displays_insecure_content.html", | 1609 "/ssl/page_displays_insecure_content.html", |
1620 test_server()->host_port_pair(), | 1610 embedded_test_server()->host_port_pair(), &replacement_path); |
1621 &replacement_path)); | |
1622 | 1611 |
1623 // Load original page over HTTP. | 1612 // Load original page over HTTP. |
1624 const GURL url_http = test_server()->GetURL(replacement_path); | 1613 const GURL url_http = embedded_test_server()->GetURL(replacement_path); |
1625 ui_test_utils::NavigateToURL(browser(), url_http); | 1614 ui_test_utils::NavigateToURL(browser(), url_http); |
1626 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1615 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1627 CheckUnauthenticatedState(tab, AuthState::NONE); | 1616 CheckUnauthenticatedState(tab, AuthState::NONE); |
1628 | 1617 |
1629 // Load again but over SSL. It should be marked as displaying insecure | 1618 // Load again but over SSL. It should be marked as displaying insecure |
1630 // content (even though the image comes from the WebCore memory cache). | 1619 // content (even though the image comes from the WebCore memory cache). |
1631 const GURL url_https = https_server_.GetURL(replacement_path); | 1620 const GURL url_https = https_server_.GetURL(replacement_path); |
1632 ui_test_utils::NavigateToURL(browser(), url_https); | 1621 ui_test_utils::NavigateToURL(browser(), url_https); |
1633 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); | 1622 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); |
1634 } | 1623 } |
1635 | 1624 |
1636 // http://crbug.com/84729 | 1625 // http://crbug.com/84729 |
1637 #if defined(OS_CHROMEOS) | 1626 #if defined(OS_CHROMEOS) |
1638 #define MAYBE_TestRunsCachedInsecureContent \ | 1627 #define MAYBE_TestRunsCachedInsecureContent \ |
1639 DISABLED_TestRunsCachedInsecureContent | 1628 DISABLED_TestRunsCachedInsecureContent |
1640 #else | 1629 #else |
1641 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent | 1630 #define MAYBE_TestRunsCachedInsecureContent TestRunsCachedInsecureContent |
1642 #endif // defined(OS_CHROMEOS) | 1631 #endif // defined(OS_CHROMEOS) |
1643 | 1632 |
1644 // Visits a page with script over http. Visits another page over https | 1633 // Visits a page with script over http. Visits another page over https |
1645 // referencing that same script over http (hoping it is coming from the webcore | 1634 // referencing that same script over http (hoping it is coming from the webcore |
1646 // memory cache). | 1635 // memory cache). |
1647 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRunsCachedInsecureContent) { | 1636 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRunsCachedInsecureContent) { |
1648 ASSERT_TRUE(test_server()->Start()); | 1637 ASSERT_TRUE(embedded_test_server()->Start()); |
1649 ASSERT_TRUE(https_server_.Start()); | 1638 ASSERT_TRUE(https_server_.Start()); |
1650 | 1639 |
1651 std::string replacement_path; | 1640 std::string replacement_path; |
1652 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1641 GetFilePathWithHostAndPortReplacement( |
1653 "files/ssl/page_runs_insecure_content.html", | 1642 "/ssl/page_runs_insecure_content.html", |
1654 test_server()->host_port_pair(), | 1643 embedded_test_server()->host_port_pair(), &replacement_path); |
1655 &replacement_path)); | |
1656 | 1644 |
1657 // Load original page over HTTP. | 1645 // Load original page over HTTP. |
1658 const GURL url_http = test_server()->GetURL(replacement_path); | 1646 const GURL url_http = embedded_test_server()->GetURL(replacement_path); |
1659 ui_test_utils::NavigateToURL(browser(), url_http); | 1647 ui_test_utils::NavigateToURL(browser(), url_http); |
1660 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1648 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1661 CheckUnauthenticatedState(tab, AuthState::NONE); | 1649 CheckUnauthenticatedState(tab, AuthState::NONE); |
1662 | 1650 |
1663 // Load again but over SSL. It should be marked as displaying insecure | 1651 // Load again but over SSL. It should be marked as displaying insecure |
1664 // content (even though the image comes from the WebCore memory cache). | 1652 // content (even though the image comes from the WebCore memory cache). |
1665 const GURL url_https = https_server_.GetURL(replacement_path); | 1653 const GURL url_https = https_server_.GetURL(replacement_path); |
1666 ui_test_utils::NavigateToURL(browser(), url_https); | 1654 ui_test_utils::NavigateToURL(browser(), url_https); |
1667 CheckAuthenticationBrokenState(tab, CertError::NONE, | 1655 CheckAuthenticationBrokenState(tab, CertError::NONE, |
1668 AuthState::RAN_INSECURE_CONTENT); | 1656 AuthState::RAN_INSECURE_CONTENT); |
1669 } | 1657 } |
1670 | 1658 |
1671 // This test ensures the CN invalid status does not 'stick' to a certificate | 1659 // This test ensures the CN invalid status does not 'stick' to a certificate |
1672 // (see bug #1044942) and that it depends on the host-name. | 1660 // (see bug #1044942) and that it depends on the host-name. |
1673 // Test if disabled due to flakiness http://crbug.com/368280 . | 1661 // Test if disabled due to flakiness http://crbug.com/368280 . |
1674 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) { | 1662 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCNInvalidStickiness) { |
1675 ASSERT_TRUE(https_server_.Start()); | 1663 ASSERT_TRUE(https_server_.Start()); |
1676 ASSERT_TRUE(https_server_mismatched_.Start()); | 1664 ASSERT_TRUE(https_server_mismatched_.Start()); |
1677 | 1665 |
1678 // First we hit the server with hostname, this generates an invalid policy | 1666 // First we hit the server with hostname, this generates an invalid policy |
1679 // error. | 1667 // error. |
1680 ui_test_utils::NavigateToURL(browser(), | 1668 ui_test_utils::NavigateToURL( |
1681 https_server_mismatched_.GetURL("files/ssl/google.html")); | 1669 browser(), https_server_mismatched_.GetURL("/ssl/google.html")); |
1682 | 1670 |
1683 // We get an interstitial page as a result. | 1671 // We get an interstitial page as a result. |
1684 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1672 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1685 CheckAuthenticationBrokenState(tab, | 1673 CheckAuthenticationBrokenState(tab, |
1686 net::CERT_STATUS_COMMON_NAME_INVALID, | 1674 net::CERT_STATUS_COMMON_NAME_INVALID, |
1687 AuthState::SHOWING_INTERSTITIAL); | 1675 AuthState::SHOWING_INTERSTITIAL); |
1688 ProceedThroughInterstitial(tab); | 1676 ProceedThroughInterstitial(tab); |
1689 CheckAuthenticationBrokenState( | 1677 CheckAuthenticationBrokenState( |
1690 tab, net::CERT_STATUS_COMMON_NAME_INVALID, AuthState::NONE); | 1678 tab, net::CERT_STATUS_COMMON_NAME_INVALID, AuthState::NONE); |
1691 | 1679 |
1692 // Now we try again with the right host name this time. | 1680 // Now we try again with the right host name this time. |
1693 GURL url(https_server_.GetURL("files/ssl/google.html")); | 1681 GURL url(https_server_.GetURL("/ssl/google.html")); |
1694 ui_test_utils::NavigateToURL(browser(), url); | 1682 ui_test_utils::NavigateToURL(browser(), url); |
1695 | 1683 |
1696 // Security state should be OK. | 1684 // Security state should be OK. |
1697 CheckAuthenticatedState(tab, AuthState::NONE); | 1685 CheckAuthenticatedState(tab, AuthState::NONE); |
1698 | 1686 |
1699 // Now try again the broken one to make sure it is still broken. | 1687 // Now try again the broken one to make sure it is still broken. |
1700 ui_test_utils::NavigateToURL(browser(), | 1688 ui_test_utils::NavigateToURL( |
1701 https_server_mismatched_.GetURL("files/ssl/google.html")); | 1689 browser(), https_server_mismatched_.GetURL("/ssl/google.html")); |
1702 | 1690 |
1703 // Since we OKed the interstitial last time, we get right to the page. | 1691 // Since we OKed the interstitial last time, we get right to the page. |
1704 CheckAuthenticationBrokenState( | 1692 CheckAuthenticationBrokenState( |
1705 tab, net::CERT_STATUS_COMMON_NAME_INVALID, AuthState::NONE); | 1693 tab, net::CERT_STATUS_COMMON_NAME_INVALID, AuthState::NONE); |
1706 } | 1694 } |
1707 | 1695 |
1708 #if defined(OS_CHROMEOS) | 1696 #if defined(OS_CHROMEOS) |
1709 // This test seems to be flaky and hang on chromiumos. | 1697 // This test seems to be flaky and hang on chromiumos. |
1710 // http://crbug.com/84419 | 1698 // http://crbug.com/84419 |
1711 #define MAYBE_TestRefNavigation DISABLED_TestRefNavigation | 1699 #define MAYBE_TestRefNavigation DISABLED_TestRefNavigation |
1712 #else | 1700 #else |
1713 #define MAYBE_TestRefNavigation TestRefNavigation | 1701 #define MAYBE_TestRefNavigation TestRefNavigation |
1714 #endif | 1702 #endif |
1715 | 1703 |
1716 // Test that navigating to a #ref does not change a bad security state. | 1704 // Test that navigating to a #ref does not change a bad security state. |
1717 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) { | 1705 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRefNavigation) { |
1718 ASSERT_TRUE(https_server_expired_.Start()); | 1706 ASSERT_TRUE(https_server_expired_.Start()); |
1719 | 1707 |
1720 ui_test_utils::NavigateToURL(browser(), | 1708 ui_test_utils::NavigateToURL( |
1721 https_server_expired_.GetURL("files/ssl/page_with_refs.html")); | 1709 browser(), https_server_expired_.GetURL("/ssl/page_with_refs.html")); |
1722 | 1710 |
1723 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1711 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1724 CheckAuthenticationBrokenState( | 1712 CheckAuthenticationBrokenState( |
1725 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1713 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
1726 | 1714 |
1727 ProceedThroughInterstitial(tab); | 1715 ProceedThroughInterstitial(tab); |
1728 | 1716 |
1729 CheckAuthenticationBrokenState( | 1717 CheckAuthenticationBrokenState( |
1730 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1718 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
1731 // Now navigate to a ref in the page, the security state should not have | 1719 // Now navigate to a ref in the page, the security state should not have |
1732 // changed. | 1720 // changed. |
1733 ui_test_utils::NavigateToURL(browser(), | 1721 ui_test_utils::NavigateToURL( |
1734 https_server_expired_.GetURL("files/ssl/page_with_refs.html#jp")); | 1722 browser(), https_server_expired_.GetURL("/ssl/page_with_refs.html#jp")); |
1735 | 1723 |
1736 CheckAuthenticationBrokenState( | 1724 CheckAuthenticationBrokenState( |
1737 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1725 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
1738 } | 1726 } |
1739 | 1727 |
1740 // Tests that closing a page that has a unsafe pop-up does not crash the | 1728 // Tests that closing a page that has a unsafe pop-up does not crash the |
1741 // browser (bug #1966). | 1729 // browser (bug #1966). |
1742 // TODO(jcampan): http://crbug.com/2136 disabled because the popup is not | 1730 // TODO(jcampan): http://crbug.com/2136 disabled because the popup is not |
1743 // opened as it is not initiated by a user gesture. | 1731 // opened as it is not initiated by a user gesture. |
1744 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { | 1732 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestCloseTabWithUnsafePopup) { |
1745 ASSERT_TRUE(test_server()->Start()); | 1733 ASSERT_TRUE(embedded_test_server()->Start()); |
1746 ASSERT_TRUE(https_server_expired_.Start()); | 1734 ASSERT_TRUE(https_server_expired_.Start()); |
1747 | 1735 |
1748 std::string replacement_path; | 1736 std::string replacement_path; |
1749 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 1737 GetFilePathWithHostAndPortReplacement("/ssl/page_with_unsafe_popup.html", |
1750 "files/ssl/page_with_unsafe_popup.html", | 1738 https_server_expired_.host_port_pair(), |
1751 https_server_expired_.host_port_pair(), | 1739 &replacement_path); |
1752 &replacement_path)); | |
1753 | 1740 |
1754 ui_test_utils::NavigateToURL(browser(), | 1741 ui_test_utils::NavigateToURL( |
1755 test_server()->GetURL(replacement_path)); | 1742 browser(), embedded_test_server()->GetURL(replacement_path)); |
1756 | 1743 |
1757 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); | 1744 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); |
1758 // It is probably overkill to add a notification for a popup-opening, let's | 1745 // It is probably overkill to add a notification for a popup-opening, let's |
1759 // just poll. | 1746 // just poll. |
1760 for (int i = 0; i < 10; i++) { | 1747 for (int i = 0; i < 10; i++) { |
1761 if (IsShowingWebContentsModalDialog()) | 1748 if (IsShowingWebContentsModalDialog()) |
1762 break; | 1749 break; |
1763 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1750 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1764 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 1751 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
1765 base::TimeDelta::FromSeconds(1)); | 1752 base::TimeDelta::FromSeconds(1)); |
1766 content::RunMessageLoop(); | 1753 content::RunMessageLoop(); |
1767 } | 1754 } |
1768 ASSERT_TRUE(IsShowingWebContentsModalDialog()); | 1755 ASSERT_TRUE(IsShowingWebContentsModalDialog()); |
1769 | 1756 |
1770 // Let's add another tab to make sure the browser does not exit when we close | 1757 // Let's add another tab to make sure the browser does not exit when we close |
1771 // the first tab. | 1758 // the first tab. |
1772 GURL url = test_server()->GetURL("files/ssl/google.html"); | 1759 GURL url = embedded_test_server()->GetURL("/ssl/google.html"); |
1773 content::WindowedNotificationObserver observer( | 1760 content::WindowedNotificationObserver observer( |
1774 content::NOTIFICATION_LOAD_STOP, | 1761 content::NOTIFICATION_LOAD_STOP, |
1775 content::NotificationService::AllSources()); | 1762 content::NotificationService::AllSources()); |
1776 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1763 chrome::AddSelectedTabWithURL(browser(), url, ui::PAGE_TRANSITION_TYPED); |
1777 observer.Wait(); | 1764 observer.Wait(); |
1778 | 1765 |
1779 // Close the first tab. | 1766 // Close the first tab. |
1780 chrome::CloseWebContents(browser(), tab1, false); | 1767 chrome::CloseWebContents(browser(), tab1, false); |
1781 } | 1768 } |
1782 | 1769 |
1783 // Visit a page over bad https that is a redirect to a page with good https. | 1770 // Visit a page over bad https that is a redirect to a page with good https. |
1784 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectBadToGoodHTTPS) { | 1771 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectBadToGoodHTTPS) { |
1785 ASSERT_TRUE(https_server_.Start()); | 1772 ASSERT_TRUE(https_server_.Start()); |
1786 ASSERT_TRUE(https_server_expired_.Start()); | 1773 ASSERT_TRUE(https_server_expired_.Start()); |
1787 | 1774 |
1788 GURL url1 = https_server_expired_.GetURL("server-redirect?"); | 1775 GURL url1 = https_server_expired_.GetURL("/server-redirect?"); |
1789 GURL url2 = https_server_.GetURL("files/ssl/google.html"); | 1776 GURL url2 = https_server_.GetURL("/ssl/google.html"); |
1790 | 1777 |
1791 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); | 1778 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); |
1792 | 1779 |
1793 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1780 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1794 | 1781 |
1795 CheckAuthenticationBrokenState( | 1782 CheckAuthenticationBrokenState( |
1796 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1783 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
1797 | 1784 |
1798 ProceedThroughInterstitial(tab); | 1785 ProceedThroughInterstitial(tab); |
1799 | 1786 |
1800 // We have been redirected to the good page. | 1787 // We have been redirected to the good page. |
1801 CheckAuthenticatedState(tab, AuthState::NONE); | 1788 CheckAuthenticatedState(tab, AuthState::NONE); |
1802 } | 1789 } |
1803 | 1790 |
1804 // Flaky on Linux. http://crbug.com/368280. | 1791 // Flaky on Linux. http://crbug.com/368280. |
1805 #if defined(OS_LINUX) | 1792 #if defined(OS_LINUX) |
1806 #define MAYBE_TestRedirectGoodToBadHTTPS DISABLED_TestRedirectGoodToBadHTTPS | 1793 #define MAYBE_TestRedirectGoodToBadHTTPS DISABLED_TestRedirectGoodToBadHTTPS |
1807 #else | 1794 #else |
1808 #define MAYBE_TestRedirectGoodToBadHTTPS TestRedirectGoodToBadHTTPS | 1795 #define MAYBE_TestRedirectGoodToBadHTTPS TestRedirectGoodToBadHTTPS |
1809 #endif | 1796 #endif |
1810 | 1797 |
1811 // Visit a page over good https that is a redirect to a page with bad https. | 1798 // Visit a page over good https that is a redirect to a page with bad https. |
1812 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRedirectGoodToBadHTTPS) { | 1799 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRedirectGoodToBadHTTPS) { |
1813 ASSERT_TRUE(https_server_.Start()); | 1800 ASSERT_TRUE(https_server_.Start()); |
1814 ASSERT_TRUE(https_server_expired_.Start()); | 1801 ASSERT_TRUE(https_server_expired_.Start()); |
1815 | 1802 |
1816 GURL url1 = https_server_.GetURL("server-redirect?"); | 1803 GURL url1 = https_server_.GetURL("/server-redirect?"); |
1817 GURL url2 = https_server_expired_.GetURL("files/ssl/google.html"); | 1804 GURL url2 = https_server_expired_.GetURL("/ssl/google.html"); |
1818 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); | 1805 ui_test_utils::NavigateToURL(browser(), GURL(url1.spec() + url2.spec())); |
1819 | 1806 |
1820 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1807 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1821 CheckAuthenticationBrokenState( | 1808 CheckAuthenticationBrokenState( |
1822 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1809 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
1823 | 1810 |
1824 ProceedThroughInterstitial(tab); | 1811 ProceedThroughInterstitial(tab); |
1825 | 1812 |
1826 CheckAuthenticationBrokenState( | 1813 CheckAuthenticationBrokenState( |
1827 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1814 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
1828 } | 1815 } |
1829 | 1816 |
1830 // Visit a page over http that is a redirect to a page with good HTTPS. | 1817 // Visit a page over http that is a redirect to a page with good HTTPS. |
1831 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToGoodHTTPS) { | 1818 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPToGoodHTTPS) { |
1832 ASSERT_TRUE(test_server()->Start()); | 1819 ASSERT_TRUE(embedded_test_server()->Start()); |
1833 ASSERT_TRUE(https_server_.Start()); | 1820 ASSERT_TRUE(https_server_.Start()); |
1834 | 1821 |
1835 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1822 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1836 | 1823 |
1837 // HTTP redirects to good HTTPS. | 1824 // HTTP redirects to good HTTPS. |
1838 GURL http_url = test_server()->GetURL("server-redirect?"); | 1825 GURL http_url = embedded_test_server()->GetURL("/server-redirect?"); |
1839 GURL good_https_url = | 1826 GURL good_https_url = https_server_.GetURL("/ssl/google.html"); |
1840 https_server_.GetURL("files/ssl/google.html"); | |
1841 | 1827 |
1842 ui_test_utils::NavigateToURL(browser(), | 1828 ui_test_utils::NavigateToURL(browser(), |
1843 GURL(http_url.spec() + good_https_url.spec())); | 1829 GURL(http_url.spec() + good_https_url.spec())); |
1844 CheckAuthenticatedState(tab, AuthState::NONE); | 1830 CheckAuthenticatedState(tab, AuthState::NONE); |
1845 } | 1831 } |
1846 | 1832 |
1847 // Flaky on Linux. http://crbug.com/368280. | 1833 // Flaky on Linux. http://crbug.com/368280. |
1848 #if defined(OS_LINUX) | 1834 #if defined(OS_LINUX) |
1849 #define MAYBE_TestRedirectHTTPToBadHTTPS DISABLED_TestRedirectHTTPToBadHTTPS | 1835 #define MAYBE_TestRedirectHTTPToBadHTTPS DISABLED_TestRedirectHTTPToBadHTTPS |
1850 #else | 1836 #else |
1851 #define MAYBE_TestRedirectHTTPToBadHTTPS TestRedirectHTTPToBadHTTPS | 1837 #define MAYBE_TestRedirectHTTPToBadHTTPS TestRedirectHTTPToBadHTTPS |
1852 #endif | 1838 #endif |
1853 | 1839 |
1854 // Visit a page over http that is a redirect to a page with bad HTTPS. | 1840 // Visit a page over http that is a redirect to a page with bad HTTPS. |
1855 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRedirectHTTPToBadHTTPS) { | 1841 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestRedirectHTTPToBadHTTPS) { |
1856 ASSERT_TRUE(test_server()->Start()); | 1842 ASSERT_TRUE(embedded_test_server()->Start()); |
1857 ASSERT_TRUE(https_server_expired_.Start()); | 1843 ASSERT_TRUE(https_server_expired_.Start()); |
1858 | 1844 |
1859 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1845 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1860 | 1846 |
1861 GURL http_url = test_server()->GetURL("server-redirect?"); | 1847 GURL http_url = embedded_test_server()->GetURL("/server-redirect?"); |
1862 GURL bad_https_url = | 1848 GURL bad_https_url = https_server_expired_.GetURL("/ssl/google.html"); |
1863 https_server_expired_.GetURL("files/ssl/google.html"); | |
1864 ui_test_utils::NavigateToURL(browser(), | 1849 ui_test_utils::NavigateToURL(browser(), |
1865 GURL(http_url.spec() + bad_https_url.spec())); | 1850 GURL(http_url.spec() + bad_https_url.spec())); |
1866 CheckAuthenticationBrokenState( | 1851 CheckAuthenticationBrokenState( |
1867 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1852 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
1868 | 1853 |
1869 ProceedThroughInterstitial(tab); | 1854 ProceedThroughInterstitial(tab); |
1870 | 1855 |
1871 CheckAuthenticationBrokenState( | 1856 CheckAuthenticationBrokenState( |
1872 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 1857 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
1873 } | 1858 } |
1874 | 1859 |
1875 // Visit a page over https that is a redirect to a page with http (to make sure | 1860 // Visit a page over https that is a redirect to a page with http (to make sure |
1876 // we don't keep the secure state). | 1861 // we don't keep the secure state). |
1877 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) { | 1862 IN_PROC_BROWSER_TEST_F(SSLUITest, TestRedirectHTTPSToHTTP) { |
1878 ASSERT_TRUE(test_server()->Start()); | 1863 ASSERT_TRUE(embedded_test_server()->Start()); |
1879 ASSERT_TRUE(https_server_.Start()); | 1864 ASSERT_TRUE(https_server_.Start()); |
1880 | 1865 |
1881 GURL https_url = https_server_.GetURL("server-redirect?"); | 1866 GURL https_url = https_server_.GetURL("/server-redirect?"); |
1882 GURL http_url = test_server()->GetURL("files/ssl/google.html"); | 1867 GURL http_url = embedded_test_server()->GetURL("/ssl/google.html"); |
1883 | 1868 |
1884 ui_test_utils::NavigateToURL(browser(), | 1869 ui_test_utils::NavigateToURL(browser(), |
1885 GURL(https_url.spec() + http_url.spec())); | 1870 GURL(https_url.spec() + http_url.spec())); |
1886 CheckUnauthenticatedState( | 1871 CheckUnauthenticatedState( |
1887 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); | 1872 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); |
1888 } | 1873 } |
1889 | 1874 |
1890 // Visits a page to which we could not connect (bad port) over http and https | 1875 // Visits a page to which we could not connect (bad port) over http and https |
1891 // and make sure the security style is correct. | 1876 // and make sure the security style is correct. |
1892 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { | 1877 IN_PROC_BROWSER_TEST_F(SSLUITest, TestConnectToBadPort) { |
(...skipping 12 matching lines...) Expand all Loading... |
1905 // | 1890 // |
1906 // Frame navigation | 1891 // Frame navigation |
1907 // | 1892 // |
1908 | 1893 |
1909 // From a good HTTPS top frame: | 1894 // From a good HTTPS top frame: |
1910 // - navigate to an OK HTTPS frame | 1895 // - navigate to an OK HTTPS frame |
1911 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then | 1896 // - navigate to a bad HTTPS (expect unsafe content and filtered frame), then |
1912 // back | 1897 // back |
1913 // - navigate to HTTP (expect insecure content), then back | 1898 // - navigate to HTTP (expect insecure content), then back |
1914 IN_PROC_BROWSER_TEST_F(SSLUITest, TestGoodFrameNavigation) { | 1899 IN_PROC_BROWSER_TEST_F(SSLUITest, TestGoodFrameNavigation) { |
1915 ASSERT_TRUE(test_server()->Start()); | 1900 ASSERT_TRUE(embedded_test_server()->Start()); |
1916 ASSERT_TRUE(https_server_.Start()); | 1901 ASSERT_TRUE(https_server_.Start()); |
1917 ASSERT_TRUE(https_server_expired_.Start()); | 1902 ASSERT_TRUE(https_server_expired_.Start()); |
1918 | 1903 |
1919 std::string top_frame_path; | 1904 std::string top_frame_path; |
1920 ASSERT_TRUE(GetTopFramePath(*test_server(), | 1905 GetTopFramePath(*embedded_test_server(), https_server_, https_server_expired_, |
1921 https_server_, | 1906 &top_frame_path); |
1922 https_server_expired_, | |
1923 &top_frame_path)); | |
1924 | 1907 |
1925 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1908 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
1926 ui_test_utils::NavigateToURL(browser(), | 1909 ui_test_utils::NavigateToURL(browser(), |
1927 https_server_.GetURL(top_frame_path)); | 1910 https_server_.GetURL(top_frame_path)); |
1928 | 1911 |
1929 CheckAuthenticatedState(tab, AuthState::NONE); | 1912 CheckAuthenticatedState(tab, AuthState::NONE); |
1930 | 1913 |
1931 bool success = false; | 1914 bool success = false; |
1932 // Now navigate inside the frame. | 1915 // Now navigate inside the frame. |
1933 { | 1916 { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 | 1995 |
2013 CheckAuthenticationBrokenState( | 1996 CheckAuthenticationBrokenState( |
2014 tab, | 1997 tab, |
2015 CertError::NONE, | 1998 CertError::NONE, |
2016 AuthState::DISPLAYED_INSECURE_CONTENT | AuthState::RAN_INSECURE_CONTENT); | 1999 AuthState::DISPLAYED_INSECURE_CONTENT | AuthState::RAN_INSECURE_CONTENT); |
2017 } | 2000 } |
2018 | 2001 |
2019 // From a bad HTTPS top frame: | 2002 // From a bad HTTPS top frame: |
2020 // - navigate to an OK HTTPS frame (expected to be still authentication broken). | 2003 // - navigate to an OK HTTPS frame (expected to be still authentication broken). |
2021 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadFrameNavigation) { | 2004 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBadFrameNavigation) { |
| 2005 ASSERT_TRUE(embedded_test_server()->Start()); |
2022 ASSERT_TRUE(https_server_.Start()); | 2006 ASSERT_TRUE(https_server_.Start()); |
2023 ASSERT_TRUE(https_server_expired_.Start()); | 2007 ASSERT_TRUE(https_server_expired_.Start()); |
2024 | 2008 |
2025 std::string top_frame_path; | 2009 std::string top_frame_path; |
2026 ASSERT_TRUE(GetTopFramePath(*test_server(), | 2010 GetTopFramePath(*embedded_test_server(), https_server_, https_server_expired_, |
2027 https_server_, | 2011 &top_frame_path); |
2028 https_server_expired_, | |
2029 &top_frame_path)); | |
2030 | 2012 |
2031 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2013 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2032 ui_test_utils::NavigateToURL(browser(), | 2014 ui_test_utils::NavigateToURL(browser(), |
2033 https_server_expired_.GetURL(top_frame_path)); | 2015 https_server_expired_.GetURL(top_frame_path)); |
2034 CheckAuthenticationBrokenState( | 2016 CheckAuthenticationBrokenState( |
2035 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 2017 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
2036 | 2018 |
2037 ProceedThroughInterstitial(tab); | 2019 ProceedThroughInterstitial(tab); |
2038 | 2020 |
2039 // Navigate to a good frame. | 2021 // Navigate to a good frame. |
(...skipping 10 matching lines...) Expand all Loading... |
2050 | 2032 |
2051 // We should still be authentication broken. | 2033 // We should still be authentication broken. |
2052 CheckAuthenticationBrokenState( | 2034 CheckAuthenticationBrokenState( |
2053 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 2035 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
2054 } | 2036 } |
2055 | 2037 |
2056 // From an HTTP top frame, navigate to good and bad HTTPS (security state should | 2038 // From an HTTP top frame, navigate to good and bad HTTPS (security state should |
2057 // stay unauthenticated). | 2039 // stay unauthenticated). |
2058 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. | 2040 // Disabled, flakily exceeds test timeout, http://crbug.com/43437. |
2059 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { | 2041 IN_PROC_BROWSER_TEST_F(SSLUITest, DISABLED_TestUnauthenticatedFrameNavigation) { |
2060 ASSERT_TRUE(test_server()->Start()); | 2042 ASSERT_TRUE(embedded_test_server()->Start()); |
2061 ASSERT_TRUE(https_server_.Start()); | 2043 ASSERT_TRUE(https_server_.Start()); |
2062 ASSERT_TRUE(https_server_expired_.Start()); | 2044 ASSERT_TRUE(https_server_expired_.Start()); |
2063 | 2045 |
2064 std::string top_frame_path; | 2046 std::string top_frame_path; |
2065 ASSERT_TRUE(GetTopFramePath(*test_server(), | 2047 GetTopFramePath(*embedded_test_server(), https_server_, https_server_expired_, |
2066 https_server_, | 2048 &top_frame_path); |
2067 https_server_expired_, | |
2068 &top_frame_path)); | |
2069 | 2049 |
2070 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2050 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2071 ui_test_utils::NavigateToURL(browser(), | 2051 ui_test_utils::NavigateToURL(browser(), |
2072 test_server()->GetURL(top_frame_path)); | 2052 embedded_test_server()->GetURL(top_frame_path)); |
2073 CheckUnauthenticatedState(tab, AuthState::NONE); | 2053 CheckUnauthenticatedState(tab, AuthState::NONE); |
2074 | 2054 |
2075 // Now navigate inside the frame to a secure HTTPS frame. | 2055 // Now navigate inside the frame to a secure HTTPS frame. |
2076 { | 2056 { |
2077 bool success = false; | 2057 bool success = false; |
2078 content::WindowedNotificationObserver observer( | 2058 content::WindowedNotificationObserver observer( |
2079 content::NOTIFICATION_LOAD_STOP, | 2059 content::NOTIFICATION_LOAD_STOP, |
2080 content::Source<NavigationController>(&tab->GetController())); | 2060 content::Source<NavigationController>(&tab->GetController())); |
2081 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 2061 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
2082 tab, | 2062 tab, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 EXPECT_FALSE(is_content_evil); | 2098 EXPECT_FALSE(is_content_evil); |
2119 } | 2099 } |
2120 | 2100 |
2121 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerFiltered) { | 2101 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerFiltered) { |
2122 ASSERT_TRUE(https_server_.Start()); | 2102 ASSERT_TRUE(https_server_.Start()); |
2123 ASSERT_TRUE(https_server_expired_.Start()); | 2103 ASSERT_TRUE(https_server_expired_.Start()); |
2124 | 2104 |
2125 // This page will spawn a Worker which will try to load content from | 2105 // This page will spawn a Worker which will try to load content from |
2126 // BadCertServer. | 2106 // BadCertServer. |
2127 std::string page_with_unsafe_worker_path; | 2107 std::string page_with_unsafe_worker_path; |
2128 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_expired_, | 2108 GetPageWithUnsafeWorkerPath(https_server_expired_, |
2129 &page_with_unsafe_worker_path)); | 2109 &page_with_unsafe_worker_path); |
2130 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( | 2110 ui_test_utils::NavigateToURL(browser(), https_server_.GetURL( |
2131 page_with_unsafe_worker_path)); | 2111 page_with_unsafe_worker_path)); |
2132 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2112 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2133 // Expect Worker not to load insecure content. | 2113 // Expect Worker not to load insecure content. |
2134 CheckWorkerLoadResult(tab, false); | 2114 CheckWorkerLoadResult(tab, false); |
2135 // The bad content is filtered, expect the state to be authenticated. | 2115 // The bad content is filtered, expect the state to be authenticated. |
2136 CheckAuthenticatedState(tab, AuthState::NONE); | 2116 CheckAuthenticatedState(tab, AuthState::NONE); |
2137 } | 2117 } |
2138 | 2118 |
2139 // This test, and the related test TestUnsafeContentsWithUserException, verify | 2119 // This test, and the related test TestUnsafeContentsWithUserException, verify |
2140 // that if unsafe content is loaded but the host of that unsafe content has a | 2120 // that if unsafe content is loaded but the host of that unsafe content has a |
2141 // user exception, the content runs and the security style remains | 2121 // user exception, the content runs and the security style remains |
2142 // authenticated. This is not necessarily the behavior that should exist, but it | 2122 // authenticated. This is not necessarily the behavior that should exist, but it |
2143 // is verification that it does behave that way. See https://crbug.com/477868 | 2123 // is verification that it does behave that way. See https://crbug.com/477868 |
2144 // for more inforamtion on this. | 2124 // for more inforamtion on this. |
2145 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) { | 2125 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) { |
2146 ASSERT_TRUE(https_server_.Start()); | 2126 ASSERT_TRUE(https_server_.Start()); |
2147 // Note that it is necessary to user https_server_mismatched_ here over the | 2127 // Note that it is necessary to user https_server_mismatched_ here over the |
2148 // other invalid cert servers. This is because the test relies on the two | 2128 // other invalid cert servers. This is because the test relies on the two |
2149 // servers having different hosts since SSL exceptions are per-host, not per | 2129 // servers having different hosts since SSL exceptions are per-host, not per |
2150 // origin, and https_server_mismatched_ uses 'localhost' rather than | 2130 // origin, and https_server_mismatched_ uses 'localhost' rather than |
2151 // '127.0.0.1'. | 2131 // '127.0.0.1'. |
2152 ASSERT_TRUE(https_server_mismatched_.Start()); | 2132 ASSERT_TRUE(https_server_mismatched_.Start()); |
2153 | 2133 |
2154 // Navigate to an unsafe site. Proceed with interstitial page to indicate | 2134 // Navigate to an unsafe site. Proceed with interstitial page to indicate |
2155 // the user approves the bad certificate. | 2135 // the user approves the bad certificate. |
2156 ui_test_utils::NavigateToURL( | 2136 ui_test_utils::NavigateToURL( |
2157 browser(), https_server_mismatched_.GetURL("files/ssl/blank_page.html")); | 2137 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html")); |
2158 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2138 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2159 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 2139 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
2160 AuthState::SHOWING_INTERSTITIAL); | 2140 AuthState::SHOWING_INTERSTITIAL); |
2161 ProceedThroughInterstitial(tab); | 2141 ProceedThroughInterstitial(tab); |
2162 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 2142 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
2163 AuthState::NONE); | 2143 AuthState::NONE); |
2164 | 2144 |
2165 // Navigate to safe page that has Worker loading unsafe content. | 2145 // Navigate to safe page that has Worker loading unsafe content. |
2166 // Expect content to load but be marked as auth broken due to running insecure | 2146 // Expect content to load but be marked as auth broken due to running insecure |
2167 // content. | 2147 // content. |
2168 std::string page_with_unsafe_worker_path; | 2148 std::string page_with_unsafe_worker_path; |
2169 ASSERT_TRUE(GetPageWithUnsafeWorkerPath(https_server_mismatched_, | 2149 GetPageWithUnsafeWorkerPath(https_server_mismatched_, |
2170 &page_with_unsafe_worker_path)); | 2150 &page_with_unsafe_worker_path); |
2171 ui_test_utils::NavigateToURL( | 2151 ui_test_utils::NavigateToURL( |
2172 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); | 2152 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); |
2173 CheckWorkerLoadResult(tab, true); // Worker loads insecure content | 2153 CheckWorkerLoadResult(tab, true); // Worker loads insecure content |
2174 CheckAuthenticatedState(tab, CertError::NONE); | 2154 CheckAuthenticatedState(tab, CertError::NONE); |
2175 } | 2155 } |
2176 | 2156 |
2177 // Visits a page with unsafe content and makes sure that if a user exception to | 2157 // Visits a page with unsafe content and makes sure that if a user exception to |
2178 // the certificate error is present, the image is loaded and script executes. | 2158 // the certificate error is present, the image is loaded and script executes. |
2179 // | 2159 // |
2180 // See the comment above SSLUITest.TestUnsafeContentsInWorkerWithUserException | 2160 // See the comment above SSLUITest.TestUnsafeContentsInWorkerWithUserException |
2181 // for a discussion about the desired behavior. | 2161 // for a discussion about the desired behavior. |
2182 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { | 2162 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { |
2183 ASSERT_TRUE(https_server_.Start()); | 2163 ASSERT_TRUE(https_server_.Start()); |
2184 // Note that it is necessary to user https_server_mismatched_ here over the | 2164 // Note that it is necessary to user https_server_mismatched_ here over the |
2185 // other invalid cert servers. This is because the test relies on the two | 2165 // other invalid cert servers. This is because the test relies on the two |
2186 // servers having different hosts since SSL exceptions are per-host, not per | 2166 // servers having different hosts since SSL exceptions are per-host, not per |
2187 // origin, and https_server_mismatched_ uses 'localhost' rather than | 2167 // origin, and https_server_mismatched_ uses 'localhost' rather than |
2188 // '127.0.0.1'. | 2168 // '127.0.0.1'. |
2189 ASSERT_TRUE(https_server_mismatched_.Start()); | 2169 ASSERT_TRUE(https_server_mismatched_.Start()); |
2190 | 2170 |
2191 // Navigate to an unsafe site. Proceed with interstitial page to indicate | 2171 // Navigate to an unsafe site. Proceed with interstitial page to indicate |
2192 // the user approves the bad certificate. | 2172 // the user approves the bad certificate. |
2193 ui_test_utils::NavigateToURL( | 2173 ui_test_utils::NavigateToURL( |
2194 browser(), https_server_mismatched_.GetURL("files/ssl/blank_page.html")); | 2174 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html")); |
2195 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2175 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2196 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 2176 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
2197 AuthState::SHOWING_INTERSTITIAL); | 2177 AuthState::SHOWING_INTERSTITIAL); |
2198 ProceedThroughInterstitial(tab); | 2178 ProceedThroughInterstitial(tab); |
2199 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, | 2179 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
2200 AuthState::NONE); | 2180 AuthState::NONE); |
2201 | 2181 |
2202 std::string replacement_path; | 2182 std::string replacement_path; |
2203 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2183 GetFilePathWithHostAndPortReplacement( |
2204 "files/ssl/page_with_unsafe_contents.html", | 2184 "/ssl/page_with_unsafe_contents.html", |
2205 https_server_mismatched_.host_port_pair(), &replacement_path)); | 2185 https_server_mismatched_.host_port_pair(), &replacement_path); |
2206 ui_test_utils::NavigateToURL(browser(), | 2186 ui_test_utils::NavigateToURL(browser(), |
2207 https_server_.GetURL(replacement_path)); | 2187 https_server_.GetURL(replacement_path)); |
2208 | 2188 |
2209 // When the bad content is filtered, the state is expected to be | 2189 // When the bad content is filtered, the state is expected to be |
2210 // authenticated. | 2190 // authenticated. |
2211 CheckAuthenticatedState(tab, AuthState::NONE); | 2191 CheckAuthenticatedState(tab, AuthState::NONE); |
2212 | 2192 |
2213 int img_width; | 2193 int img_width; |
2214 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( | 2194 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( |
2215 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); | 2195 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); |
2216 // In order to check that the image was loaded, we check its width. | 2196 // In order to check that the image was loaded, we check its width. |
2217 // The actual image (Google logo) is 114 pixels wide, so we assume a good | 2197 // The actual image (Google logo) is 114 pixels wide, so we assume a good |
2218 // image is greater than 100. | 2198 // image is greater than 100. |
2219 EXPECT_GT(img_width, 100); | 2199 EXPECT_GT(img_width, 100); |
2220 | 2200 |
2221 bool js_result = false; | 2201 bool js_result = false; |
2222 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 2202 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
2223 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); | 2203 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); |
2224 EXPECT_TRUE(js_result); | 2204 EXPECT_TRUE(js_result); |
2225 CheckAuthenticatedState(tab, CertError::NONE); | 2205 CheckAuthenticatedState(tab, CertError::NONE); |
2226 } | 2206 } |
2227 | 2207 |
2228 // Test that when the browser blocks displaying insecure content (images), the | 2208 // Test that when the browser blocks displaying insecure content (images), the |
2229 // indicator shows a secure page, because the blocking made the otherwise | 2209 // indicator shows a secure page, because the blocking made the otherwise |
2230 // unsafe page safe (the notification of this state is handled by other means). | 2210 // unsafe page safe (the notification of this state is handled by other means). |
2231 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureImage) { | 2211 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureImage) { |
2232 ASSERT_TRUE(test_server()->Start()); | 2212 ASSERT_TRUE(embedded_test_server()->Start()); |
2233 ASSERT_TRUE(https_server_.Start()); | 2213 ASSERT_TRUE(https_server_.Start()); |
2234 | 2214 |
2235 std::string replacement_path; | 2215 std::string replacement_path; |
2236 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2216 GetFilePathWithHostAndPortReplacement( |
2237 "files/ssl/page_displays_insecure_content.html", | 2217 "/ssl/page_displays_insecure_content.html", |
2238 test_server()->host_port_pair(), | 2218 embedded_test_server()->host_port_pair(), &replacement_path); |
2239 &replacement_path)); | |
2240 | 2219 |
2241 ui_test_utils::NavigateToURL(browser(), | 2220 ui_test_utils::NavigateToURL(browser(), |
2242 https_server_.GetURL(replacement_path)); | 2221 https_server_.GetURL(replacement_path)); |
2243 | 2222 |
2244 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), | 2223 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), |
2245 AuthState::NONE); | 2224 AuthState::NONE); |
2246 } | 2225 } |
2247 | 2226 |
2248 // Test that when the browser blocks displaying insecure content (iframes), the | 2227 // Test that when the browser blocks displaying insecure content (iframes), the |
2249 // indicator shows a secure page, because the blocking made the otherwise | 2228 // indicator shows a secure page, because the blocking made the otherwise |
2250 // unsafe page safe (the notification of this state is handled by other means) | 2229 // unsafe page safe (the notification of this state is handled by other means) |
2251 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureIframe) { | 2230 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureIframe) { |
2252 ASSERT_TRUE(test_server()->Start()); | 2231 ASSERT_TRUE(embedded_test_server()->Start()); |
2253 ASSERT_TRUE(https_server_.Start()); | 2232 ASSERT_TRUE(https_server_.Start()); |
2254 | 2233 |
2255 std::string replacement_path; | 2234 std::string replacement_path; |
2256 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2235 GetFilePathWithHostAndPortReplacement( |
2257 "files/ssl/page_displays_insecure_iframe.html", | 2236 "/ssl/page_displays_insecure_iframe.html", |
2258 test_server()->host_port_pair(), | 2237 embedded_test_server()->host_port_pair(), &replacement_path); |
2259 &replacement_path)); | |
2260 | 2238 |
2261 ui_test_utils::NavigateToURL(browser(), | 2239 ui_test_utils::NavigateToURL(browser(), |
2262 https_server_.GetURL(replacement_path)); | 2240 https_server_.GetURL(replacement_path)); |
2263 | 2241 |
2264 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), | 2242 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), |
2265 AuthState::NONE); | 2243 AuthState::NONE); |
2266 } | 2244 } |
2267 | 2245 |
2268 // Test that when the browser blocks running insecure content, the | 2246 // Test that when the browser blocks running insecure content, the |
2269 // indicator shows a secure page, because the blocking made the otherwise | 2247 // indicator shows a secure page, because the blocking made the otherwise |
2270 // unsafe page safe (the notification of this state is handled by other means). | 2248 // unsafe page safe (the notification of this state is handled by other means). |
2271 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockRunningInsecureContent) { | 2249 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockRunningInsecureContent) { |
2272 ASSERT_TRUE(test_server()->Start()); | 2250 ASSERT_TRUE(embedded_test_server()->Start()); |
2273 ASSERT_TRUE(https_server_.Start()); | 2251 ASSERT_TRUE(https_server_.Start()); |
2274 | 2252 |
2275 std::string replacement_path; | 2253 std::string replacement_path; |
2276 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | 2254 GetFilePathWithHostAndPortReplacement( |
2277 "files/ssl/page_runs_insecure_content.html", | 2255 "/ssl/page_runs_insecure_content.html", |
2278 test_server()->host_port_pair(), | 2256 embedded_test_server()->host_port_pair(), &replacement_path); |
2279 &replacement_path)); | |
2280 | 2257 |
2281 ui_test_utils::NavigateToURL(browser(), | 2258 ui_test_utils::NavigateToURL(browser(), |
2282 https_server_.GetURL(replacement_path)); | 2259 https_server_.GetURL(replacement_path)); |
2283 | 2260 |
2284 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), | 2261 CheckAuthenticatedState(browser()->tab_strip_model()->GetActiveWebContents(), |
2285 AuthState::NONE); | 2262 AuthState::NONE); |
2286 } | 2263 } |
2287 | 2264 |
2288 // Visit a page and establish a WebSocket connection over bad https with | 2265 // Visit a page and establish a WebSocket connection over bad https with |
2289 // --ignore-certificate-errors. The connection should be established without | 2266 // --ignore-certificate-errors. The connection should be established without |
2290 // interstitial page showing. | 2267 // interstitial page showing. |
2291 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreCertErrors, TestWSS) { | 2268 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreCertErrors, TestWSS) { |
2292 ASSERT_TRUE(test_server()->Start()); | 2269 ASSERT_TRUE(embedded_test_server()->Start()); |
2293 ASSERT_TRUE(wss_server_expired_.Start()); | 2270 ASSERT_TRUE(wss_server_expired_.Start()); |
2294 | 2271 |
2295 // Setup page title observer. | 2272 // Setup page title observer. |
2296 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2273 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2297 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | 2274 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); |
2298 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 2275 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
2299 | 2276 |
2300 // Visit bad HTTPS page. | 2277 // Visit bad HTTPS page. |
2301 GURL::Replacements replacements; | 2278 GURL::Replacements replacements; |
2302 replacements.SetSchemeStr("https"); | 2279 replacements.SetSchemeStr("https"); |
2303 ui_test_utils::NavigateToURL( | 2280 ui_test_utils::NavigateToURL(browser(), |
2304 browser(), | 2281 wss_server_expired_.GetURL("connect_check.html") |
2305 wss_server_expired_.GetURL( | 2282 .ReplaceComponents(replacements)); |
2306 "connect_check.html").ReplaceComponents(replacements)); | |
2307 | 2283 |
2308 // We shouldn't have an interstitial page showing here. | 2284 // We shouldn't have an interstitial page showing here. |
2309 | 2285 |
2310 // Test page run a WebSocket wss connection test. The result will be shown | 2286 // Test page run a WebSocket wss connection test. The result will be shown |
2311 // as page title. | 2287 // as page title. |
2312 const base::string16 result = watcher.WaitAndGetTitle(); | 2288 const base::string16 result = watcher.WaitAndGetTitle(); |
2313 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); | 2289 EXPECT_TRUE(base::LowerCaseEqualsASCII(result, "pass")); |
2314 } | 2290 } |
2315 | 2291 |
2316 // Verifies that the interstitial can proceed, even if JavaScript is disabled. | 2292 // Verifies that the interstitial can proceed, even if JavaScript is disabled. |
2317 // http://crbug.com/322948 | 2293 // http://crbug.com/322948 |
2318 #if defined(OS_LINUX) | 2294 #if defined(OS_LINUX) |
2319 // flaky http://crbug.com/396458 | 2295 // flaky http://crbug.com/396458 |
2320 #define MAYBE_TestInterstitialJavaScriptProceeds \ | 2296 #define MAYBE_TestInterstitialJavaScriptProceeds \ |
2321 DISABLED_TestInterstitialJavaScriptProceeds | 2297 DISABLED_TestInterstitialJavaScriptProceeds |
2322 #else | 2298 #else |
2323 #define MAYBE_TestInterstitialJavaScriptProceeds \ | 2299 #define MAYBE_TestInterstitialJavaScriptProceeds \ |
2324 TestInterstitialJavaScriptProceeds | 2300 TestInterstitialJavaScriptProceeds |
2325 #endif | 2301 #endif |
2326 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestInterstitialJavaScriptProceeds) { | 2302 IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestInterstitialJavaScriptProceeds) { |
2327 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) | 2303 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) |
2328 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 2304 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
2329 CONTENT_SETTING_BLOCK); | 2305 CONTENT_SETTING_BLOCK); |
2330 | 2306 |
2331 ASSERT_TRUE(https_server_expired_.Start()); | 2307 ASSERT_TRUE(https_server_expired_.Start()); |
2332 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2308 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2333 ui_test_utils::NavigateToURL(browser(), | 2309 ui_test_utils::NavigateToURL( |
2334 https_server_expired_.GetURL("files/ssl/google.html")); | 2310 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
2335 CheckAuthenticationBrokenState( | 2311 CheckAuthenticationBrokenState( |
2336 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 2312 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
2337 | 2313 |
2338 content::WindowedNotificationObserver observer( | 2314 content::WindowedNotificationObserver observer( |
2339 content::NOTIFICATION_LOAD_STOP, | 2315 content::NOTIFICATION_LOAD_STOP, |
2340 content::Source<NavigationController>(&tab->GetController())); | 2316 content::Source<NavigationController>(&tab->GetController())); |
2341 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 2317 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
2342 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 2318 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
2343 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 2319 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
2344 content::RenderViewHost* interstitial_rvh = | 2320 content::RenderViewHost* interstitial_rvh = |
(...skipping 13 matching lines...) Expand all Loading... |
2358 | 2334 |
2359 // Verifies that the interstitial can go back, even if JavaScript is disabled. | 2335 // Verifies that the interstitial can go back, even if JavaScript is disabled. |
2360 // http://crbug.com/322948 | 2336 // http://crbug.com/322948 |
2361 IN_PROC_BROWSER_TEST_F(SSLUITest, TestInterstitialJavaScriptGoesBack) { | 2337 IN_PROC_BROWSER_TEST_F(SSLUITest, TestInterstitialJavaScriptGoesBack) { |
2362 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) | 2338 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) |
2363 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 2339 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
2364 CONTENT_SETTING_BLOCK); | 2340 CONTENT_SETTING_BLOCK); |
2365 | 2341 |
2366 ASSERT_TRUE(https_server_expired_.Start()); | 2342 ASSERT_TRUE(https_server_expired_.Start()); |
2367 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2343 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2368 ui_test_utils::NavigateToURL(browser(), | 2344 ui_test_utils::NavigateToURL( |
2369 https_server_expired_.GetURL("files/ssl/google.html")); | 2345 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
2370 CheckAuthenticationBrokenState( | 2346 CheckAuthenticationBrokenState( |
2371 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 2347 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
2372 | 2348 |
2373 content::WindowedNotificationObserver observer( | 2349 content::WindowedNotificationObserver observer( |
2374 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 2350 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
2375 content::NotificationService::AllSources()); | 2351 content::NotificationService::AllSources()); |
2376 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 2352 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
2377 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 2353 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
2378 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 2354 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
2379 content::RenderViewHost* interstitial_rvh = | 2355 content::RenderViewHost* interstitial_rvh = |
2380 interstitial_page->GetMainFrame()->GetRenderViewHost(); | 2356 interstitial_page->GetMainFrame()->GetRenderViewHost(); |
2381 int result = -1; | 2357 int result = -1; |
2382 std::string javascript = base::StringPrintf( | 2358 std::string javascript = base::StringPrintf( |
2383 "window.domAutomationController.send(%d);", | 2359 "window.domAutomationController.send(%d);", |
2384 SecurityInterstitialPage::CMD_DONT_PROCEED); | 2360 SecurityInterstitialPage::CMD_DONT_PROCEED); |
2385 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 2361 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
2386 interstitial_rvh, javascript, &result)); | 2362 interstitial_rvh, javascript, &result)); |
2387 // The above will hang without the fix. | 2363 // The above will hang without the fix. |
2388 EXPECT_EQ(0, result); | 2364 EXPECT_EQ(0, result); |
2389 observer.Wait(); | 2365 observer.Wait(); |
2390 EXPECT_EQ("about:blank", tab->GetVisibleURL().spec()); | 2366 EXPECT_EQ("about:blank", tab->GetVisibleURL().spec()); |
2391 } | 2367 } |
2392 | 2368 |
2393 // Verifies that switching tabs, while showing interstitial page, will not | 2369 // Verifies that switching tabs, while showing interstitial page, will not |
2394 // affect the visibility of the interestitial. | 2370 // affect the visibility of the interestitial. |
2395 // https://crbug.com/381439 | 2371 // https://crbug.com/381439 |
2396 IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByHideShow) { | 2372 IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByHideShow) { |
2397 ASSERT_TRUE(https_server_expired_.Start()); | 2373 ASSERT_TRUE(https_server_expired_.Start()); |
| 2374 ASSERT_TRUE(https_server_.Start()); |
| 2375 |
2398 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2376 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2399 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); | 2377 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
2400 ui_test_utils::NavigateToURL( | 2378 ui_test_utils::NavigateToURL( |
2401 browser(), https_server_expired_.GetURL("files/ssl/google.html")); | 2379 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
2402 CheckAuthenticationBrokenState( | 2380 CheckAuthenticationBrokenState( |
2403 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 2381 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
2404 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); | 2382 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
2405 | 2383 |
2406 AddTabAtIndex(0, | 2384 AddTabAtIndex(0, https_server_.GetURL("/ssl/google.html"), |
2407 https_server_.GetURL("files/ssl/google.html"), | |
2408 ui::PAGE_TRANSITION_TYPED); | 2385 ui::PAGE_TRANSITION_TYPED); |
2409 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 2386 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
2410 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 2387 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
2411 EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1)); | 2388 EXPECT_EQ(tab, browser()->tab_strip_model()->GetWebContentsAt(1)); |
2412 EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing()); | 2389 EXPECT_FALSE(tab->GetRenderWidgetHostView()->IsShowing()); |
2413 | 2390 |
2414 browser()->tab_strip_model()->ActivateTabAt(1, true); | 2391 browser()->tab_strip_model()->ActivateTabAt(1, true); |
2415 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); | 2392 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
2416 } | 2393 } |
2417 | 2394 |
2418 // Verifies that if a bad certificate is seen for a host and the user proceeds | 2395 // Verifies that if a bad certificate is seen for a host and the user proceeds |
2419 // through the interstitial, the decision to proceed is initially remembered. | 2396 // through the interstitial, the decision to proceed is initially remembered. |
2420 // However, if this is followed by another visit, and a good certificate | 2397 // However, if this is followed by another visit, and a good certificate |
2421 // is seen for the same host, the original exception is forgotten. | 2398 // is seen for the same host, the original exception is forgotten. |
2422 IN_PROC_BROWSER_TEST_F(SSLUITest, BadCertFollowedByGoodCert) { | 2399 IN_PROC_BROWSER_TEST_F(SSLUITest, BadCertFollowedByGoodCert) { |
2423 // It is necessary to use |https_server_expired_| rather than | 2400 // It is necessary to use |https_server_expired_| rather than |
2424 // |https_server_mismatched| because the former shares a host with | 2401 // |https_server_mismatched| because the former shares a host with |
2425 // |https_server_| and cert exceptions are per host. | 2402 // |https_server_| and cert exceptions are per host. |
2426 ASSERT_TRUE(https_server_expired_.Start()); | 2403 ASSERT_TRUE(https_server_expired_.Start()); |
2427 ASSERT_TRUE(https_server_.Start()); | 2404 ASSERT_TRUE(https_server_.Start()); |
2428 | 2405 |
2429 std::string https_server_expired_host = | 2406 std::string https_server_expired_host = |
2430 https_server_.GetURL("files/ssl/google.html").host(); | 2407 https_server_.GetURL("/ssl/google.html").host(); |
2431 std::string https_server_host = | 2408 std::string https_server_host = |
2432 https_server_.GetURL("files/ssl/google.html").host(); | 2409 https_server_.GetURL("/ssl/google.html").host(); |
2433 ASSERT_EQ(https_server_expired_host, https_server_host); | 2410 ASSERT_EQ(https_server_expired_host, https_server_host); |
2434 | 2411 |
2435 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2412 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2436 | 2413 |
2437 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 2414 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
2438 ChromeSSLHostStateDelegate* state = | 2415 ChromeSSLHostStateDelegate* state = |
2439 reinterpret_cast<ChromeSSLHostStateDelegate*>( | 2416 reinterpret_cast<ChromeSSLHostStateDelegate*>( |
2440 profile->GetSSLHostStateDelegate()); | 2417 profile->GetSSLHostStateDelegate()); |
2441 | 2418 |
2442 ui_test_utils::NavigateToURL( | 2419 ui_test_utils::NavigateToURL( |
2443 browser(), https_server_expired_.GetURL("files/ssl/google.html")); | 2420 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
2444 | 2421 |
2445 ProceedThroughInterstitial(tab); | 2422 ProceedThroughInterstitial(tab); |
2446 EXPECT_TRUE(state->HasAllowException(https_server_host)); | 2423 EXPECT_TRUE(state->HasAllowException(https_server_host)); |
2447 | 2424 |
2448 ui_test_utils::NavigateToURL(browser(), | 2425 ui_test_utils::NavigateToURL(browser(), |
2449 https_server_.GetURL("files/ssl/google.html")); | 2426 https_server_.GetURL("/ssl/google.html")); |
2450 ASSERT_FALSE(tab->GetInterstitialPage()); | 2427 ASSERT_FALSE(tab->GetInterstitialPage()); |
2451 EXPECT_FALSE(state->HasAllowException(https_server_host)); | 2428 EXPECT_FALSE(state->HasAllowException(https_server_host)); |
2452 } | 2429 } |
2453 | 2430 |
2454 // Tests that the SSLStatus of a navigation entry for an SSL | 2431 // Tests that the SSLStatus of a navigation entry for an SSL |
2455 // interstitial matches the navigation entry once the interstitial is | 2432 // interstitial matches the navigation entry once the interstitial is |
2456 // clicked through. https://crbug.com/529456 | 2433 // clicked through. https://crbug.com/529456 |
2457 IN_PROC_BROWSER_TEST_F(SSLUITest, | 2434 IN_PROC_BROWSER_TEST_F(SSLUITest, |
2458 SSLStatusMatchesOnInterstitialAndAfterProceed) { | 2435 SSLStatusMatchesOnInterstitialAndAfterProceed) { |
2459 ASSERT_TRUE(https_server_expired_.Start()); | 2436 ASSERT_TRUE(https_server_expired_.Start()); |
2460 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2437 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
2461 ASSERT_TRUE(tab); | 2438 ASSERT_TRUE(tab); |
2462 | 2439 |
2463 ui_test_utils::NavigateToURL( | 2440 ui_test_utils::NavigateToURL( |
2464 browser(), https_server_expired_.GetURL("files/ssl/google.html")); | 2441 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
2465 content::WaitForInterstitialAttach(tab); | 2442 content::WaitForInterstitialAttach(tab); |
2466 EXPECT_TRUE(tab->ShowingInterstitialPage()); | 2443 EXPECT_TRUE(tab->ShowingInterstitialPage()); |
2467 | 2444 |
2468 content::NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 2445 content::NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
2469 ASSERT_TRUE(entry); | 2446 ASSERT_TRUE(entry); |
2470 content::SSLStatus interstitial_ssl_status = entry->GetSSL(); | 2447 content::SSLStatus interstitial_ssl_status = entry->GetSSL(); |
2471 | 2448 |
2472 ProceedThroughInterstitial(tab); | 2449 ProceedThroughInterstitial(tab); |
2473 EXPECT_FALSE(tab->ShowingInterstitialPage()); | 2450 EXPECT_FALSE(tab->ShowingInterstitialPage()); |
2474 entry = tab->GetController().GetActiveEntry(); | 2451 entry = tab->GetController().GetActiveEntry(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 2516 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
2540 "SSLCommonNameMismatchHandling/Enabled/"); | 2517 "SSLCommonNameMismatchHandling/Enabled/"); |
2541 } | 2518 } |
2542 }; | 2519 }; |
2543 | 2520 |
2544 // Visit the URL www.mail.example.com on a server that presents a valid | 2521 // Visit the URL www.mail.example.com on a server that presents a valid |
2545 // certificate for mail.example.com. Verify that the page navigates to | 2522 // certificate for mail.example.com. Verify that the page navigates to |
2546 // mail.example.com. | 2523 // mail.example.com. |
2547 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, | 2524 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, |
2548 ShouldShowWWWSubdomainMismatchInterstitial) { | 2525 ShouldShowWWWSubdomainMismatchInterstitial) { |
2549 net::SpawnedTestServer https_server_example_domain_( | 2526 net::EmbeddedTestServer https_server_example_domain_( |
2550 net::SpawnedTestServer::TYPE_HTTPS, | 2527 net::EmbeddedTestServer::TYPE_HTTPS); |
2551 net::SpawnedTestServer::SSLOptions( | 2528 https_server_example_domain_.ServeFilesFromSourceDirectory( |
2552 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
2553 base::FilePath(kDocRoot)); | 2529 base::FilePath(kDocRoot)); |
2554 ASSERT_TRUE(https_server_example_domain_.Start()); | 2530 ASSERT_TRUE(https_server_example_domain_.Start()); |
2555 | 2531 |
2556 host_resolver()->AddRule( | 2532 host_resolver()->AddRule( |
2557 "mail.example.com", https_server_example_domain_.host_port_pair().host()); | 2533 "mail.example.com", https_server_example_domain_.host_port_pair().host()); |
2558 host_resolver()->AddRule( | 2534 host_resolver()->AddRule( |
2559 "www.mail.example.com", | 2535 "www.mail.example.com", |
2560 https_server_example_domain_.host_port_pair().host()); | 2536 https_server_example_domain_.host_port_pair().host()); |
2561 | 2537 |
2562 scoped_refptr<net::X509Certificate> cert = | 2538 scoped_refptr<net::X509Certificate> cert = |
(...skipping 15 matching lines...) Expand all Loading... |
2578 net::CertVerifyResult verify_result_valid; | 2554 net::CertVerifyResult verify_result_valid; |
2579 verify_result_valid.verified_cert = | 2555 verify_result_valid.verified_cert = |
2580 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2556 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2581 // Request to "www.mail.example.com" should not result in any error. | 2557 // Request to "www.mail.example.com" should not result in any error. |
2582 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", | 2558 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", |
2583 verify_result_valid, net::OK); | 2559 verify_result_valid, net::OK); |
2584 | 2560 |
2585 // Use a complex URL to ensure the path, etc., are preserved. The path itself | 2561 // Use a complex URL to ensure the path, etc., are preserved. The path itself |
2586 // does not matter. | 2562 // does not matter. |
2587 GURL https_server_url = | 2563 GURL https_server_url = |
2588 https_server_example_domain_.GetURL("files/ssl/google.html?a=b#anchor"); | 2564 https_server_example_domain_.GetURL("/ssl/google.html?a=b#anchor"); |
2589 GURL::Replacements replacements; | 2565 GURL::Replacements replacements; |
2590 replacements.SetHostStr("www.mail.example.com"); | 2566 replacements.SetHostStr("www.mail.example.com"); |
2591 GURL https_server_mismatched_url = | 2567 GURL https_server_mismatched_url = |
2592 https_server_url.ReplaceComponents(replacements); | 2568 https_server_url.ReplaceComponents(replacements); |
2593 | 2569 |
2594 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2570 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
2595 content::TestNavigationObserver observer(contents, 2); | 2571 content::TestNavigationObserver observer(contents, 2); |
2596 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); | 2572 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); |
2597 observer.Wait(); | 2573 observer.Wait(); |
2598 | 2574 |
2599 CheckSecurityState(contents, CertError::NONE, | 2575 CheckSecurityState(contents, CertError::NONE, |
2600 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); | 2576 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); |
2601 replacements.SetHostStr("mail.example.com"); | 2577 replacements.SetHostStr("mail.example.com"); |
2602 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements); | 2578 GURL https_server_new_url = https_server_url.ReplaceComponents(replacements); |
2603 // Verify that the current URL is the suggested URL. | 2579 // Verify that the current URL is the suggested URL. |
2604 EXPECT_EQ(https_server_new_url.spec(), | 2580 EXPECT_EQ(https_server_new_url.spec(), |
2605 contents->GetLastCommittedURL().spec()); | 2581 contents->GetLastCommittedURL().spec()); |
2606 } | 2582 } |
2607 | 2583 |
2608 // Visit the URL example.org on a server that presents a valid certificate | 2584 // Visit the URL example.org on a server that presents a valid certificate |
2609 // for www.example.org. Verify that the page redirects to www.example.org. | 2585 // for www.example.org. Verify that the page redirects to www.example.org. |
2610 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, | 2586 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, |
2611 CheckWWWSubdomainMismatchInverse) { | 2587 CheckWWWSubdomainMismatchInverse) { |
2612 net::SpawnedTestServer https_server_example_domain_( | 2588 net::EmbeddedTestServer https_server_example_domain_( |
2613 net::SpawnedTestServer::TYPE_HTTPS, | 2589 net::EmbeddedTestServer::TYPE_HTTPS); |
2614 net::SpawnedTestServer::SSLOptions( | 2590 https_server_example_domain_.ServeFilesFromSourceDirectory( |
2615 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
2616 base::FilePath(kDocRoot)); | 2591 base::FilePath(kDocRoot)); |
2617 ASSERT_TRUE(https_server_example_domain_.Start()); | 2592 ASSERT_TRUE(https_server_example_domain_.Start()); |
2618 | 2593 |
2619 host_resolver()->AddRule( | 2594 host_resolver()->AddRule( |
2620 "www.example.org", https_server_example_domain_.host_port_pair().host()); | 2595 "www.example.org", https_server_example_domain_.host_port_pair().host()); |
2621 host_resolver()->AddRule( | 2596 host_resolver()->AddRule( |
2622 "example.org", https_server_example_domain_.host_port_pair().host()); | 2597 "example.org", https_server_example_domain_.host_port_pair().host()); |
2623 | 2598 |
2624 scoped_refptr<net::X509Certificate> cert = | 2599 scoped_refptr<net::X509Certificate> cert = |
2625 https_server_example_domain_.GetCertificate(); | 2600 https_server_example_domain_.GetCertificate(); |
2626 | 2601 |
2627 net::CertVerifyResult verify_result; | 2602 net::CertVerifyResult verify_result; |
2628 verify_result.verified_cert = | 2603 verify_result.verified_cert = |
2629 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2604 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2630 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; | 2605 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; |
2631 | 2606 |
2632 mock_cert_verifier()->AddResultForCertAndHost( | 2607 mock_cert_verifier()->AddResultForCertAndHost( |
2633 cert.get(), "example.org", verify_result, | 2608 cert.get(), "example.org", verify_result, |
2634 net::ERR_CERT_COMMON_NAME_INVALID); | 2609 net::ERR_CERT_COMMON_NAME_INVALID); |
2635 | 2610 |
2636 net::CertVerifyResult verify_result_valid; | 2611 net::CertVerifyResult verify_result_valid; |
2637 verify_result_valid.verified_cert = | 2612 verify_result_valid.verified_cert = |
2638 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2613 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2639 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "www.example.org", | 2614 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "www.example.org", |
2640 verify_result_valid, net::OK); | 2615 verify_result_valid, net::OK); |
2641 | 2616 |
2642 GURL https_server_url = | 2617 GURL https_server_url = |
2643 https_server_example_domain_.GetURL("files/ssl/google.html?a=b"); | 2618 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); |
2644 GURL::Replacements replacements; | 2619 GURL::Replacements replacements; |
2645 replacements.SetHostStr("example.org"); | 2620 replacements.SetHostStr("example.org"); |
2646 GURL https_server_mismatched_url = | 2621 GURL https_server_mismatched_url = |
2647 https_server_url.ReplaceComponents(replacements); | 2622 https_server_url.ReplaceComponents(replacements); |
2648 | 2623 |
2649 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2624 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
2650 content::TestNavigationObserver observer(contents, 2); | 2625 content::TestNavigationObserver observer(contents, 2); |
2651 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); | 2626 ui_test_utils::NavigateToURL(browser(), https_server_mismatched_url); |
2652 observer.Wait(); | 2627 observer.Wait(); |
2653 | 2628 |
2654 CheckSecurityState(contents, CertError::NONE, | 2629 CheckSecurityState(contents, CertError::NONE, |
2655 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); | 2630 content::SECURITY_STYLE_AUTHENTICATED, AuthState::NONE); |
2656 } | 2631 } |
2657 | 2632 |
2658 // Tests this scenario: | 2633 // Tests this scenario: |
2659 // - |CommonNameMismatchHandler| does not give a callback as it's set into the | 2634 // - |CommonNameMismatchHandler| does not give a callback as it's set into the |
2660 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can | 2635 // state |IGNORE_REQUESTS_FOR_TESTING|. So no suggested URL check result can |
2661 // arrive. | 2636 // arrive. |
2662 // - A cert error triggers an interstitial timer with a very long timeout. | 2637 // - A cert error triggers an interstitial timer with a very long timeout. |
2663 // - No suggested URL check results arrive, causing the tab to appear as loading | 2638 // - No suggested URL check results arrive, causing the tab to appear as loading |
2664 // indefinitely (also because the timer has a long timeout). | 2639 // indefinitely (also because the timer has a long timeout). |
2665 // - Stopping the page load shouldn't result in any interstitials. | 2640 // - Stopping the page load shouldn't result in any interstitials. |
2666 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, | 2641 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, |
2667 InterstitialStopNavigationWhileLoading) { | 2642 InterstitialStopNavigationWhileLoading) { |
2668 net::SpawnedTestServer https_server_example_domain_( | 2643 net::EmbeddedTestServer https_server_example_domain_( |
2669 net::SpawnedTestServer::TYPE_HTTPS, | 2644 net::EmbeddedTestServer::TYPE_HTTPS); |
2670 net::SpawnedTestServer::SSLOptions( | 2645 https_server_example_domain_.ServeFilesFromSourceDirectory( |
2671 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
2672 base::FilePath(kDocRoot)); | 2646 base::FilePath(kDocRoot)); |
2673 ASSERT_TRUE(https_server_example_domain_.Start()); | 2647 ASSERT_TRUE(https_server_example_domain_.Start()); |
2674 | 2648 |
2675 host_resolver()->AddRule( | 2649 host_resolver()->AddRule( |
2676 "mail.example.com", https_server_example_domain_.host_port_pair().host()); | 2650 "mail.example.com", https_server_example_domain_.host_port_pair().host()); |
2677 host_resolver()->AddRule( | 2651 host_resolver()->AddRule( |
2678 "www.mail.example.com", | 2652 "www.mail.example.com", |
2679 https_server_example_domain_.host_port_pair().host()); | 2653 https_server_example_domain_.host_port_pair().host()); |
2680 | 2654 |
2681 scoped_refptr<net::X509Certificate> cert = | 2655 scoped_refptr<net::X509Certificate> cert = |
2682 https_server_example_domain_.GetCertificate(); | 2656 https_server_example_domain_.GetCertificate(); |
2683 | 2657 |
2684 net::CertVerifyResult verify_result; | 2658 net::CertVerifyResult verify_result; |
2685 verify_result.verified_cert = | 2659 verify_result.verified_cert = |
2686 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2660 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2687 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; | 2661 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; |
2688 | 2662 |
2689 mock_cert_verifier()->AddResultForCertAndHost( | 2663 mock_cert_verifier()->AddResultForCertAndHost( |
2690 cert.get(), "www.mail.example.com", verify_result, | 2664 cert.get(), "www.mail.example.com", verify_result, |
2691 net::ERR_CERT_COMMON_NAME_INVALID); | 2665 net::ERR_CERT_COMMON_NAME_INVALID); |
2692 | 2666 |
2693 net::CertVerifyResult verify_result_valid; | 2667 net::CertVerifyResult verify_result_valid; |
2694 verify_result_valid.verified_cert = | 2668 verify_result_valid.verified_cert = |
2695 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2669 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2696 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", | 2670 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", |
2697 verify_result_valid, net::OK); | 2671 verify_result_valid, net::OK); |
2698 | 2672 |
2699 GURL https_server_url = | 2673 GURL https_server_url = |
2700 https_server_example_domain_.GetURL("files/ssl/google.html?a=b"); | 2674 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); |
2701 GURL::Replacements replacements; | 2675 GURL::Replacements replacements; |
2702 replacements.SetHostStr("www.mail.example.com"); | 2676 replacements.SetHostStr("www.mail.example.com"); |
2703 GURL https_server_mismatched_url = | 2677 GURL https_server_mismatched_url = |
2704 https_server_url.ReplaceComponents(replacements); | 2678 https_server_url.ReplaceComponents(replacements); |
2705 | 2679 |
2706 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2680 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
2707 CommonNameMismatchHandler::set_state_for_testing( | 2681 CommonNameMismatchHandler::set_state_for_testing( |
2708 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 2682 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
2709 // Set delay long enough so that the page appears loading. | 2683 // Set delay long enough so that the page appears loading. |
2710 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 2684 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
(...skipping 16 matching lines...) Expand all Loading... |
2727 // Make sure that the |SSLErrorHandler| is deleted. | 2701 // Make sure that the |SSLErrorHandler| is deleted. |
2728 EXPECT_FALSE(ssl_error_handler); | 2702 EXPECT_FALSE(ssl_error_handler); |
2729 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 2703 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
2730 EXPECT_FALSE(contents->IsLoading()); | 2704 EXPECT_FALSE(contents->IsLoading()); |
2731 } | 2705 } |
2732 | 2706 |
2733 // Same as above, but instead of stopping, the loading page is reloaded. The end | 2707 // Same as above, but instead of stopping, the loading page is reloaded. The end |
2734 // result is the same. (i.e. page load stops, no interstitials shown) | 2708 // result is the same. (i.e. page load stops, no interstitials shown) |
2735 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, | 2709 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, |
2736 InterstitialReloadNavigationWhileLoading) { | 2710 InterstitialReloadNavigationWhileLoading) { |
2737 net::SpawnedTestServer https_server_example_domain_( | 2711 net::EmbeddedTestServer https_server_example_domain_( |
2738 net::SpawnedTestServer::TYPE_HTTPS, | 2712 net::EmbeddedTestServer::TYPE_HTTPS); |
2739 net::SpawnedTestServer::SSLOptions( | 2713 https_server_example_domain_.ServeFilesFromSourceDirectory( |
2740 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
2741 base::FilePath(kDocRoot)); | 2714 base::FilePath(kDocRoot)); |
2742 ASSERT_TRUE(https_server_example_domain_.Start()); | 2715 ASSERT_TRUE(https_server_example_domain_.Start()); |
2743 | 2716 |
2744 host_resolver()->AddRule( | 2717 host_resolver()->AddRule( |
2745 "mail.example.com", https_server_example_domain_.host_port_pair().host()); | 2718 "mail.example.com", https_server_example_domain_.host_port_pair().host()); |
2746 host_resolver()->AddRule( | 2719 host_resolver()->AddRule( |
2747 "www.mail.example.com", | 2720 "www.mail.example.com", |
2748 https_server_example_domain_.host_port_pair().host()); | 2721 https_server_example_domain_.host_port_pair().host()); |
2749 | 2722 |
2750 scoped_refptr<net::X509Certificate> cert = | 2723 scoped_refptr<net::X509Certificate> cert = |
2751 https_server_example_domain_.GetCertificate(); | 2724 https_server_example_domain_.GetCertificate(); |
2752 | 2725 |
2753 net::CertVerifyResult verify_result; | 2726 net::CertVerifyResult verify_result; |
2754 verify_result.verified_cert = | 2727 verify_result.verified_cert = |
2755 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2728 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2756 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; | 2729 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; |
2757 | 2730 |
2758 mock_cert_verifier()->AddResultForCertAndHost( | 2731 mock_cert_verifier()->AddResultForCertAndHost( |
2759 cert.get(), "www.mail.example.com", verify_result, | 2732 cert.get(), "www.mail.example.com", verify_result, |
2760 net::ERR_CERT_COMMON_NAME_INVALID); | 2733 net::ERR_CERT_COMMON_NAME_INVALID); |
2761 | 2734 |
2762 net::CertVerifyResult verify_result_valid; | 2735 net::CertVerifyResult verify_result_valid; |
2763 verify_result_valid.verified_cert = | 2736 verify_result_valid.verified_cert = |
2764 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2737 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2765 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", | 2738 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", |
2766 verify_result_valid, net::OK); | 2739 verify_result_valid, net::OK); |
2767 | 2740 |
2768 GURL https_server_url = | 2741 GURL https_server_url = |
2769 https_server_example_domain_.GetURL("files/ssl/google.html?a=b"); | 2742 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); |
2770 GURL::Replacements replacements; | 2743 GURL::Replacements replacements; |
2771 replacements.SetHostStr("www.mail.example.com"); | 2744 replacements.SetHostStr("www.mail.example.com"); |
2772 GURL https_server_mismatched_url = | 2745 GURL https_server_mismatched_url = |
2773 https_server_url.ReplaceComponents(replacements); | 2746 https_server_url.ReplaceComponents(replacements); |
2774 | 2747 |
2775 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2748 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
2776 CommonNameMismatchHandler::set_state_for_testing( | 2749 CommonNameMismatchHandler::set_state_for_testing( |
2777 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 2750 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
2778 // Set delay long enough so that the page appears loading. | 2751 // Set delay long enough so that the page appears loading. |
2779 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 2752 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
(...skipping 14 matching lines...) Expand all Loading... |
2794 // Make sure that the |SSLErrorHandler| is deleted. | 2767 // Make sure that the |SSLErrorHandler| is deleted. |
2795 EXPECT_FALSE(ssl_error_handler); | 2768 EXPECT_FALSE(ssl_error_handler); |
2796 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 2769 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
2797 EXPECT_FALSE(contents->IsLoading()); | 2770 EXPECT_FALSE(contents->IsLoading()); |
2798 } | 2771 } |
2799 | 2772 |
2800 // Same as above, but instead of reloading, the page is navigated away. The | 2773 // Same as above, but instead of reloading, the page is navigated away. The |
2801 // new page should load, and no interstitials should be shown. | 2774 // new page should load, and no interstitials should be shown. |
2802 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, | 2775 IN_PROC_BROWSER_TEST_F(CommonNameMismatchBrowserTest, |
2803 InterstitialNavigateAwayWhileLoading) { | 2776 InterstitialNavigateAwayWhileLoading) { |
2804 net::SpawnedTestServer https_server_example_domain_( | 2777 net::EmbeddedTestServer https_server_example_domain_( |
2805 net::SpawnedTestServer::TYPE_HTTPS, | 2778 net::EmbeddedTestServer::TYPE_HTTPS); |
2806 net::SpawnedTestServer::SSLOptions( | 2779 https_server_example_domain_.ServeFilesFromSourceDirectory( |
2807 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
2808 base::FilePath(kDocRoot)); | 2780 base::FilePath(kDocRoot)); |
2809 ASSERT_TRUE(https_server_example_domain_.Start()); | 2781 ASSERT_TRUE(https_server_example_domain_.Start()); |
2810 | 2782 |
2811 host_resolver()->AddRule( | 2783 host_resolver()->AddRule( |
2812 "mail.example.com", https_server_example_domain_.host_port_pair().host()); | 2784 "mail.example.com", https_server_example_domain_.host_port_pair().host()); |
2813 host_resolver()->AddRule( | 2785 host_resolver()->AddRule( |
2814 "www.mail.example.com", | 2786 "www.mail.example.com", |
2815 https_server_example_domain_.host_port_pair().host()); | 2787 https_server_example_domain_.host_port_pair().host()); |
2816 | 2788 |
2817 scoped_refptr<net::X509Certificate> cert = | 2789 scoped_refptr<net::X509Certificate> cert = |
2818 https_server_example_domain_.GetCertificate(); | 2790 https_server_example_domain_.GetCertificate(); |
2819 | 2791 |
2820 net::CertVerifyResult verify_result; | 2792 net::CertVerifyResult verify_result; |
2821 verify_result.verified_cert = | 2793 verify_result.verified_cert = |
2822 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2794 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2823 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; | 2795 verify_result.cert_status = net::CERT_STATUS_COMMON_NAME_INVALID; |
2824 | 2796 |
2825 mock_cert_verifier()->AddResultForCertAndHost( | 2797 mock_cert_verifier()->AddResultForCertAndHost( |
2826 cert.get(), "www.mail.example.com", verify_result, | 2798 cert.get(), "www.mail.example.com", verify_result, |
2827 net::ERR_CERT_COMMON_NAME_INVALID); | 2799 net::ERR_CERT_COMMON_NAME_INVALID); |
2828 | 2800 |
2829 net::CertVerifyResult verify_result_valid; | 2801 net::CertVerifyResult verify_result_valid; |
2830 verify_result_valid.verified_cert = | 2802 verify_result_valid.verified_cert = |
2831 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); | 2803 net::ImportCertFromFile(net::GetTestCertsDirectory(), "spdy_pooling.pem"); |
2832 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", | 2804 mock_cert_verifier()->AddResultForCertAndHost(cert.get(), "mail.example.com", |
2833 verify_result_valid, net::OK); | 2805 verify_result_valid, net::OK); |
2834 | 2806 |
2835 GURL https_server_url = | 2807 GURL https_server_url = |
2836 https_server_example_domain_.GetURL("files/ssl/google.html?a=b"); | 2808 https_server_example_domain_.GetURL("/ssl/google.html?a=b"); |
2837 GURL::Replacements replacements; | 2809 GURL::Replacements replacements; |
2838 replacements.SetHostStr("www.mail.example.com"); | 2810 replacements.SetHostStr("www.mail.example.com"); |
2839 GURL https_server_mismatched_url = | 2811 GURL https_server_mismatched_url = |
2840 https_server_url.ReplaceComponents(replacements); | 2812 https_server_url.ReplaceComponents(replacements); |
2841 | 2813 |
2842 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2814 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
2843 CommonNameMismatchHandler::set_state_for_testing( | 2815 CommonNameMismatchHandler::set_state_for_testing( |
2844 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 2816 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
2845 // Set delay long enough so that the page appears loading. | 2817 // Set delay long enough so that the page appears loading. |
2846 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 2818 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 contents, net::ERR_CERT_CONTAINS_ERRORS, ssl_info, request_url, 0, | 2851 contents, net::ERR_CERT_CONTAINS_ERRORS, ssl_info, request_url, 0, |
2880 base::Time::NowFromSystemTime(), nullptr, base::Callback<void(bool)>()); | 2852 base::Time::NowFromSystemTime(), nullptr, base::Callback<void(bool)>()); |
2881 } | 2853 } |
2882 }; | 2854 }; |
2883 | 2855 |
2884 IN_PROC_BROWSER_TEST_F(SSLBlockingPageIDNTest, SSLBlockingPageDecodesIDN) { | 2856 IN_PROC_BROWSER_TEST_F(SSLBlockingPageIDNTest, SSLBlockingPageDecodesIDN) { |
2885 EXPECT_TRUE(VerifyIDNDecoded()); | 2857 EXPECT_TRUE(VerifyIDNDecoded()); |
2886 } | 2858 } |
2887 | 2859 |
2888 IN_PROC_BROWSER_TEST_F(CertVerifierBrowserTest, MockCertVerifierSmokeTest) { | 2860 IN_PROC_BROWSER_TEST_F(CertVerifierBrowserTest, MockCertVerifierSmokeTest) { |
2889 net::SpawnedTestServer https_server( | 2861 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
2890 net::SpawnedTestServer::TYPE_HTTPS, | 2862 https_server.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
2891 net::SpawnedTestServer::SSLOptions( | |
2892 net::SpawnedTestServer::SSLOptions::CERT_OK), | |
2893 base::FilePath(kDocRoot)); | |
2894 ASSERT_TRUE(https_server.Start()); | 2863 ASSERT_TRUE(https_server.Start()); |
2895 | 2864 |
2896 mock_cert_verifier()->set_default_result( | 2865 mock_cert_verifier()->set_default_result( |
2897 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION); | 2866 net::ERR_CERT_NAME_CONSTRAINT_VIOLATION); |
2898 | 2867 |
2899 ui_test_utils::NavigateToURL(browser(), | 2868 ui_test_utils::NavigateToURL(browser(), |
2900 https_server.GetURL("files/ssl/google.html")); | 2869 https_server.GetURL("/ssl/google.html")); |
2901 | 2870 |
2902 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), | 2871 CheckSecurityState(browser()->tab_strip_model()->GetActiveWebContents(), |
2903 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, | 2872 net::CERT_STATUS_NAME_CONSTRAINT_VIOLATION, |
2904 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 2873 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
2905 AuthState::SHOWING_INTERSTITIAL); | 2874 AuthState::SHOWING_INTERSTITIAL); |
2906 } | 2875 } |
2907 | 2876 |
2908 // TODO(jcampan): more tests to do below. | 2877 // TODO(jcampan): more tests to do below. |
2909 | 2878 |
2910 // Visit a page over https that contains a frame with a redirect. | 2879 // Visit a page over https that contains a frame with a redirect. |
2911 | 2880 |
2912 // XMLHttpRequest insecure content in synchronous mode. | 2881 // XMLHttpRequest insecure content in synchronous mode. |
2913 | 2882 |
2914 // XMLHttpRequest insecure content in asynchronous mode. | 2883 // XMLHttpRequest insecure content in asynchronous mode. |
2915 | 2884 |
2916 // XMLHttpRequest over bad ssl in synchronous mode. | 2885 // XMLHttpRequest over bad ssl in synchronous mode. |
2917 | 2886 |
2918 // XMLHttpRequest over OK ssl in synchronous mode. | 2887 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |