Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ssl/chrome_security_state_model_client.h" | 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 SecurityStateModel::DEPRECATED_SHA1_MAJOR, | 339 SecurityStateModel::DEPRECATED_SHA1_MAJOR, |
| 340 SecurityStateModel::NO_MIXED_CONTENT, false, | 340 SecurityStateModel::NO_MIXED_CONTENT, false, |
| 341 false /* expect cert status error */); | 341 false /* expect cert status error */); |
| 342 } | 342 } |
| 343 | 343 |
| 344 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, MixedContent) { | 344 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, MixedContent) { |
| 345 ASSERT_TRUE(embedded_test_server()->Start()); | 345 ASSERT_TRUE(embedded_test_server()->Start()); |
| 346 ASSERT_TRUE(https_server_.Start()); | 346 ASSERT_TRUE(https_server_.Start()); |
| 347 SetUpMockCertVerifierForHttpsServer(0, net::OK); | 347 SetUpMockCertVerifierForHttpsServer(0, net::OK); |
| 348 host_resolver()->AddRule("example.test", | 348 host_resolver()->AddRule("example.test", |
| 349 https_server_.GetURL("/").host()); | 349 https_server_.GetURL("/title1.html").host()); |
| 350 | 350 |
| 351 net::HostPortPair replacement_pair = embedded_test_server()->host_port_pair(); | 351 net::HostPortPair replacement_pair = embedded_test_server()->host_port_pair(); |
| 352 replacement_pair.set_host("example.test"); | 352 replacement_pair.set_host("example.test"); |
| 353 | 353 |
| 354 // Navigate to an HTTPS page that displays mixed content. | 354 // Navigate to an HTTPS page that displays mixed content. |
| 355 std::string replacement_path; | 355 std::string replacement_path; |
| 356 GetFilePathWithHostAndPortReplacement( | 356 GetFilePathWithHostAndPortReplacement( |
| 357 "/ssl/page_displays_insecure_content.html", | 357 "/ssl/page_displays_insecure_content.html", |
| 358 replacement_pair, &replacement_path); | 358 replacement_pair, &replacement_path); |
| 359 ui_test_utils::NavigateToURL(browser(), | 359 ui_test_utils::NavigateToURL(browser(), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 https_server_.GetURL(replacement_path)); | 408 https_server_.GetURL(replacement_path)); |
| 409 CheckSecurityInfoForSecure( | 409 CheckSecurityInfoForSecure( |
| 410 browser()->tab_strip_model()->GetActiveWebContents(), | 410 browser()->tab_strip_model()->GetActiveWebContents(), |
| 411 SecurityStateModel::SECURITY_ERROR, | 411 SecurityStateModel::SECURITY_ERROR, |
| 412 SecurityStateModel::NO_DEPRECATED_SHA1, | 412 SecurityStateModel::NO_DEPRECATED_SHA1, |
| 413 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT, false, | 413 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT, false, |
| 414 false /* expect cert status error */); | 414 false /* expect cert status error */); |
| 415 | 415 |
| 416 // Navigate to an HTTPS page that runs mixed content in an iframe. | 416 // Navigate to an HTTPS page that runs mixed content in an iframe. |
| 417 net::HostPortPair host_port_pair = | 417 net::HostPortPair host_port_pair = |
| 418 net::HostPortPair::FromURL(https_server_.GetURL("/")); | 418 net::HostPortPair::FromURL(https_server_.GetURL("/title1.html")); |
| 419 host_port_pair.set_host("different-host.test"); | 419 host_port_pair.set_host("different-host.test"); |
| 420 host_resolver()->AddRule("different-host.test", | 420 host_resolver()->AddRule("different-host.test", |
| 421 https_server_.GetURL("/").host()); | 421 https_server_.GetURL("/title1.html").host()); |
| 422 host_resolver()->AddRule("different-http-host.test", | 422 host_resolver()->AddRule( |
| 423 embedded_test_server()->GetURL("/").host()); | 423 "different-http-host.test", |
| 424 embedded_test_server()->GetURL("/title1.html").host()); | |
| 424 GetFilePathWithHostAndPortReplacement( | 425 GetFilePathWithHostAndPortReplacement( |
| 425 "/ssl/page_runs_insecure_content_in_iframe.html", host_port_pair, | 426 "/ssl/page_runs_insecure_content_in_iframe.html", host_port_pair, |
| 426 &replacement_path); | 427 &replacement_path); |
| 427 ui_test_utils::NavigateToURL(browser(), | 428 ui_test_utils::NavigateToURL(browser(), |
| 428 https_server_.GetURL(replacement_path)); | 429 https_server_.GetURL(replacement_path)); |
| 429 CheckSecurityInfoForSecure( | 430 CheckSecurityInfoForSecure( |
| 430 browser()->tab_strip_model()->GetActiveWebContents(), | 431 browser()->tab_strip_model()->GetActiveWebContents(), |
| 431 SecurityStateModel::SECURITY_ERROR, | 432 SecurityStateModel::SECURITY_ERROR, |
| 432 SecurityStateModel::NO_DEPRECATED_SHA1, | 433 SecurityStateModel::NO_DEPRECATED_SHA1, |
| 433 SecurityStateModel::RAN_MIXED_CONTENT, false, | 434 SecurityStateModel::RAN_MIXED_CONTENT, false, |
| 434 false /* expect cert status error */); | 435 false /* expect cert status error */); |
| 435 } | 436 } |
| 436 | 437 |
| 437 // Same as the test above but with a long-lived SHA1 cert. | 438 // Same as the test above but with a long-lived SHA1 cert. |
| 438 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, | 439 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, |
| 439 MixedContentWithBrokenSHA1) { | 440 MixedContentWithBrokenSHA1) { |
| 440 ASSERT_TRUE(embedded_test_server()->Start()); | 441 ASSERT_TRUE(embedded_test_server()->Start()); |
| 441 ASSERT_TRUE(https_server_.Start()); | 442 ASSERT_TRUE(https_server_.Start()); |
| 442 // The test server uses a long-lived cert by default, so a SHA1 | 443 // The test server uses a long-lived cert by default, so a SHA1 |
| 443 // signature in it will register as a "broken" condition rather than | 444 // signature in it will register as a "broken" condition rather than |
| 444 // "warning". | 445 // "warning". |
| 445 SetUpMockCertVerifierForHttpsServer(net::CERT_STATUS_SHA1_SIGNATURE_PRESENT, | 446 SetUpMockCertVerifierForHttpsServer(net::CERT_STATUS_SHA1_SIGNATURE_PRESENT, |
| 446 net::OK); | 447 net::OK); |
| 447 | 448 |
| 448 host_resolver()->AddRule("example.test", | 449 host_resolver()->AddRule("example.test", |
| 449 https_server_.GetURL("/").host()); | 450 https_server_.GetURL("/title1.html").host()); |
| 450 | 451 |
| 451 net::HostPortPair replacement_pair = embedded_test_server()->host_port_pair(); | 452 net::HostPortPair replacement_pair = embedded_test_server()->host_port_pair(); |
| 452 replacement_pair.set_host("example.test"); | 453 replacement_pair.set_host("example.test"); |
| 453 | 454 |
| 454 // Navigate to an HTTPS page that displays mixed content. | 455 // Navigate to an HTTPS page that displays mixed content. |
| 455 std::string replacement_path; | 456 std::string replacement_path; |
| 456 GetFilePathWithHostAndPortReplacement( | 457 GetFilePathWithHostAndPortReplacement( |
| 457 "/ssl/page_displays_insecure_content.html", | 458 "/ssl/page_displays_insecure_content.html", |
| 458 replacement_pair, &replacement_path); | 459 replacement_pair, &replacement_path); |
| 459 ui_test_utils::NavigateToURL(browser(), | 460 ui_test_utils::NavigateToURL(browser(), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 // directive stops mixed content from running. | 522 // directive stops mixed content from running. |
| 522 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, | 523 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, |
| 523 MixedContentStrictBlocking) { | 524 MixedContentStrictBlocking) { |
| 524 ASSERT_TRUE(https_server_.Start()); | 525 ASSERT_TRUE(https_server_.Start()); |
| 525 SetUpMockCertVerifierForHttpsServer(0, net::OK); | 526 SetUpMockCertVerifierForHttpsServer(0, net::OK); |
| 526 | 527 |
| 527 // Navigate to an HTTPS page that tries to run mixed content in an | 528 // Navigate to an HTTPS page that tries to run mixed content in an |
| 528 // iframe, with strict mixed content blocking. | 529 // iframe, with strict mixed content blocking. |
| 529 std::string replacement_path; | 530 std::string replacement_path; |
| 530 net::HostPortPair host_port_pair = | 531 net::HostPortPair host_port_pair = |
| 531 net::HostPortPair::FromURL(https_server_.GetURL("/")); | 532 net::HostPortPair::FromURL(https_server_.GetURL("/title1.html")); |
| 532 host_port_pair.set_host("different-host.test"); | 533 host_port_pair.set_host("different-host.test"); |
| 533 host_resolver()->AddRule("different-host.test", | 534 host_resolver()->AddRule("different-host.test", |
| 534 https_server_.GetURL("/").host()); | 535 https_server_.GetURL("/title1.html").host()); |
| 535 GetFilePathWithHostAndPortReplacement( | 536 GetFilePathWithHostAndPortReplacement( |
| 536 "/ssl/page_runs_insecure_content_in_iframe_with_strict_blocking.html", | 537 "/ssl/page_runs_insecure_content_in_iframe_with_strict_blocking.html", |
| 537 host_port_pair, &replacement_path); | 538 host_port_pair, &replacement_path); |
| 538 ui_test_utils::NavigateToURL(browser(), | 539 ui_test_utils::NavigateToURL(browser(), |
| 539 https_server_.GetURL(replacement_path)); | 540 https_server_.GetURL(replacement_path)); |
| 540 CheckSecurityInfoForSecure( | 541 CheckSecurityInfoForSecure( |
| 541 browser()->tab_strip_model()->GetActiveWebContents(), | 542 browser()->tab_strip_model()->GetActiveWebContents(), |
| 542 SecurityStateModel::SECURE, SecurityStateModel::NO_DEPRECATED_SHA1, | 543 SecurityStateModel::SECURE, SecurityStateModel::NO_DEPRECATED_SHA1, |
| 543 SecurityStateModel::NO_MIXED_CONTENT, false, | 544 SecurityStateModel::NO_MIXED_CONTENT, false, |
| 544 false /* expect cert status error */); | 545 false /* expect cert status error */); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 SecurityStateModelLoadingTest() : ChromeSecurityStateModelClientTest() {} | 703 SecurityStateModelLoadingTest() : ChromeSecurityStateModelClientTest() {} |
| 703 ~SecurityStateModelLoadingTest() override{}; | 704 ~SecurityStateModelLoadingTest() override{}; |
| 704 | 705 |
| 705 protected: | 706 protected: |
| 706 void SetUpOnMainThread() override { | 707 void SetUpOnMainThread() override { |
| 707 ASSERT_TRUE(embedded_test_server()->Start()); | 708 ASSERT_TRUE(embedded_test_server()->Start()); |
| 708 | 709 |
| 709 content::BrowserThread::PostTask( | 710 content::BrowserThread::PostTask( |
| 710 content::BrowserThread::IO, FROM_HERE, | 711 content::BrowserThread::IO, FROM_HERE, |
| 711 base::Bind(&InstallLoadingInterceptor, | 712 base::Bind(&InstallLoadingInterceptor, |
| 712 embedded_test_server()->GetURL("/").host())); | 713 embedded_test_server()->GetURL("/title1.html").host())); |
|
estark
2016/08/02 15:56:27
None of the changes above here appear to be necess
mmenke
2016/08/02 16:27:00
Two tests in this file fail without the change, no
| |
| 713 } | 714 } |
| 714 | 715 |
| 715 DISALLOW_COPY_AND_ASSIGN(SecurityStateModelLoadingTest); | 716 DISALLOW_COPY_AND_ASSIGN(SecurityStateModelLoadingTest); |
| 716 }; | 717 }; |
| 717 | 718 |
| 718 // Tests that navigation state changes cause the security state to be | 719 // Tests that navigation state changes cause the security state to be |
| 719 // updated. | 720 // updated. |
| 720 IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) { | 721 IN_PROC_BROWSER_TEST_F(SecurityStateModelLoadingTest, NavigationStateChanges) { |
| 721 ASSERT_TRUE(https_server_.Start()); | 722 ASSERT_TRUE(https_server_.Start()); |
| 722 SetUpMockCertVerifierForHttpsServer(0, net::OK); | 723 SetUpMockCertVerifierForHttpsServer(0, net::OK); |
| 723 | 724 |
| 724 // Navigate to an HTTPS page. | 725 // Navigate to an HTTPS page. |
| 725 ui_test_utils::NavigateToURL(browser(), | 726 ui_test_utils::NavigateToURL(browser(), |
| 726 https_server_.GetURL("/ssl/google.html")); | 727 https_server_.GetURL("/ssl/google.html")); |
| 727 CheckSecurityInfoForSecure( | 728 CheckSecurityInfoForSecure( |
| 728 browser()->tab_strip_model()->GetActiveWebContents(), | 729 browser()->tab_strip_model()->GetActiveWebContents(), |
| 729 SecurityStateModel::SECURE, SecurityStateModel::NO_DEPRECATED_SHA1, | 730 SecurityStateModel::SECURE, SecurityStateModel::NO_DEPRECATED_SHA1, |
| 730 SecurityStateModel::NO_MIXED_CONTENT, false, | 731 SecurityStateModel::NO_MIXED_CONTENT, false, |
| 731 false /* expect cert status error */); | 732 false /* expect cert status error */); |
| 732 | 733 |
| 733 // Navigate to a page that doesn't finish loading. Test that the | 734 // Navigate to a page that doesn't finish loading. Test that the |
| 734 // security state is neutral while the page is loading. | 735 // security state is neutral while the page is loading. |
| 735 browser()->OpenURL(content::OpenURLParams(embedded_test_server()->GetURL("/"), | 736 browser()->OpenURL(content::OpenURLParams( |
| 736 content::Referrer(), CURRENT_TAB, | 737 embedded_test_server()->GetURL("/title1.html"), content::Referrer(), |
| 737 ui::PAGE_TRANSITION_TYPED, false)); | 738 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 738 CheckSecurityInfoForNonSecure( | 739 CheckSecurityInfoForNonSecure( |
| 739 browser()->tab_strip_model()->GetActiveWebContents()); | 740 browser()->tab_strip_model()->GetActiveWebContents()); |
| 740 } | 741 } |
| 741 | 742 |
| 742 // Tests that the SecurityStateModel for a WebContents is up to date | 743 // Tests that the SecurityStateModel for a WebContents is up to date |
| 743 // when the WebContents is inserted into a Browser's TabStripModel. | 744 // when the WebContents is inserted into a Browser's TabStripModel. |
| 744 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, AddedTab) { | 745 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, AddedTab) { |
| 745 ASSERT_TRUE(https_server_.Start()); | 746 ASSERT_TRUE(https_server_.Start()); |
| 746 SetUpMockCertVerifierForHttpsServer(0, net::OK); | 747 SetUpMockCertVerifierForHttpsServer(0, net::OK); |
| 747 | 748 |
| 748 content::WebContents* tab = | 749 content::WebContents* tab = |
| 749 browser()->tab_strip_model()->GetActiveWebContents(); | 750 browser()->tab_strip_model()->GetActiveWebContents(); |
| 750 ASSERT_TRUE(tab); | 751 ASSERT_TRUE(tab); |
| 751 | 752 |
| 752 content::WebContents* new_contents = content::WebContents::Create( | 753 content::WebContents* new_contents = content::WebContents::Create( |
| 753 content::WebContents::CreateParams(tab->GetBrowserContext())); | 754 content::WebContents::CreateParams(tab->GetBrowserContext())); |
| 754 content::NavigationController& controller = new_contents->GetController(); | 755 content::NavigationController& controller = new_contents->GetController(); |
| 755 ChromeSecurityStateModelClient::CreateForWebContents(new_contents); | 756 ChromeSecurityStateModelClient::CreateForWebContents(new_contents); |
| 756 CheckSecurityInfoForNonSecure(new_contents); | 757 CheckSecurityInfoForNonSecure(new_contents); |
| 757 controller.LoadURL(https_server_.GetURL("/"), content::Referrer(), | 758 controller.LoadURL(https_server_.GetURL("/title1.html"), content::Referrer(), |
| 758 ui::PAGE_TRANSITION_TYPED, std::string()); | 759 ui::PAGE_TRANSITION_TYPED, std::string()); |
| 759 EXPECT_TRUE(content::WaitForLoadStop(new_contents)); | 760 EXPECT_TRUE(content::WaitForLoadStop(new_contents)); |
| 760 CheckSecurityInfoForSecure(new_contents, SecurityStateModel::SECURE, | 761 CheckSecurityInfoForSecure(new_contents, SecurityStateModel::SECURE, |
| 761 SecurityStateModel::NO_DEPRECATED_SHA1, | 762 SecurityStateModel::NO_DEPRECATED_SHA1, |
| 762 SecurityStateModel::NO_MIXED_CONTENT, false, | 763 SecurityStateModel::NO_MIXED_CONTENT, false, |
| 763 false /* expect cert status error */); | 764 false /* expect cert status error */); |
| 764 | 765 |
| 765 browser()->tab_strip_model()->InsertWebContentsAt(0, new_contents, | 766 browser()->tab_strip_model()->InsertWebContentsAt(0, new_contents, |
| 766 TabStripModel::ADD_NONE); | 767 TabStripModel::ADD_NONE); |
| 767 CheckSecurityInfoForSecure(new_contents, SecurityStateModel::SECURE, | 768 CheckSecurityInfoForSecure(new_contents, SecurityStateModel::SECURE, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 781 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | 782 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 782 https_test_server_expired.ServeFilesFromSourceDirectory( | 783 https_test_server_expired.ServeFilesFromSourceDirectory( |
| 783 base::FilePath(kDocRoot)); | 784 base::FilePath(kDocRoot)); |
| 784 ASSERT_TRUE(https_test_server_expired.Start()); | 785 ASSERT_TRUE(https_test_server_expired.Start()); |
| 785 | 786 |
| 786 content::WebContents* web_contents = | 787 content::WebContents* web_contents = |
| 787 browser()->tab_strip_model()->GetActiveWebContents(); | 788 browser()->tab_strip_model()->GetActiveWebContents(); |
| 788 SecurityStyleTestObserver observer(web_contents); | 789 SecurityStyleTestObserver observer(web_contents); |
| 789 | 790 |
| 790 // Visit an HTTP url. | 791 // Visit an HTTP url. |
| 791 GURL http_url(embedded_test_server()->GetURL("/")); | 792 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
| 792 ui_test_utils::NavigateToURL(browser(), http_url); | 793 ui_test_utils::NavigateToURL(browser(), http_url); |
| 793 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 794 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 794 observer.latest_security_style()); | 795 observer.latest_security_style()); |
| 795 EXPECT_EQ(0u, | 796 EXPECT_EQ(0u, |
| 796 observer.latest_explanations().unauthenticated_explanations.size()); | 797 observer.latest_explanations().unauthenticated_explanations.size()); |
| 797 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 798 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 798 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); | 799 EXPECT_EQ(0u, observer.latest_explanations().secure_explanations.size()); |
| 799 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); | 800 EXPECT_FALSE(observer.latest_explanations().scheme_is_cryptographic); |
| 800 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); | 801 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); |
| 801 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); | 802 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 823 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); | 824 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); |
| 824 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); | 825 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); |
| 825 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); | 826 EXPECT_TRUE(mixed_content_explanation.displayed_insecure_content); |
| 826 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); | 827 EXPECT_FALSE(mixed_content_explanation.ran_insecure_content); |
| 827 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, | 828 EXPECT_EQ(content::SECURITY_STYLE_UNAUTHENTICATED, |
| 828 mixed_content_explanation.displayed_insecure_content_style); | 829 mixed_content_explanation.displayed_insecure_content_style); |
| 829 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, | 830 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATION_BROKEN, |
| 830 mixed_content_explanation.ran_insecure_content_style); | 831 mixed_content_explanation.ran_insecure_content_style); |
| 831 | 832 |
| 832 // Visit a broken HTTPS url. | 833 // Visit a broken HTTPS url. |
| 833 GURL expired_url(https_test_server_expired.GetURL(std::string("/"))); | 834 GURL expired_url(https_test_server_expired.GetURL("/title1.html")); |
| 834 ui_test_utils::NavigateToURL(browser(), expired_url); | 835 ui_test_utils::NavigateToURL(browser(), expired_url); |
| 835 | 836 |
| 836 // An interstitial should show, and an event for the lock icon on the | 837 // An interstitial should show, and an event for the lock icon on the |
| 837 // interstitial should fire. | 838 // interstitial should fire. |
| 838 content::WaitForInterstitialAttach(web_contents); | 839 content::WaitForInterstitialAttach(web_contents); |
| 839 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); | 840 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); |
| 840 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser()); | 841 CheckBrokenSecurityStyle(observer, net::ERR_CERT_DATE_INVALID, browser()); |
| 841 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 842 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 842 INVALID_CERTIFICATE, browser()); | 843 INVALID_CERTIFICATE, browser()); |
| 843 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 844 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 844 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); | 845 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); |
| 845 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); | 846 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); |
| 846 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 847 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 847 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 848 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 848 | 849 |
| 849 // Before clicking through, navigate to a different page, and then go | 850 // Before clicking through, navigate to a different page, and then go |
| 850 // back to the interstitial. | 851 // back to the interstitial. |
| 851 GURL valid_https_url(https_server_.GetURL(std::string("/"))); | 852 GURL valid_https_url(https_server_.GetURL("/title1.html")); |
| 852 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 853 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
| 853 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 854 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 854 observer.latest_security_style()); | 855 observer.latest_security_style()); |
| 855 EXPECT_EQ(0u, | 856 EXPECT_EQ(0u, |
| 856 observer.latest_explanations().unauthenticated_explanations.size()); | 857 observer.latest_explanations().unauthenticated_explanations.size()); |
| 857 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 858 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 858 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 859 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 859 VALID_CERTIFICATE, browser()); | 860 VALID_CERTIFICATE, browser()); |
| 860 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 861 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 861 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); | 862 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | 908 https_test_server_expired.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); |
| 908 https_test_server_expired.ServeFilesFromSourceDirectory( | 909 https_test_server_expired.ServeFilesFromSourceDirectory( |
| 909 base::FilePath(kDocRoot)); | 910 base::FilePath(kDocRoot)); |
| 910 ASSERT_TRUE(https_test_server_expired.Start()); | 911 ASSERT_TRUE(https_test_server_expired.Start()); |
| 911 | 912 |
| 912 content::WebContents* web_contents = | 913 content::WebContents* web_contents = |
| 913 browser()->tab_strip_model()->GetActiveWebContents(); | 914 browser()->tab_strip_model()->GetActiveWebContents(); |
| 914 SecurityStyleTestObserver observer(web_contents); | 915 SecurityStyleTestObserver observer(web_contents); |
| 915 | 916 |
| 916 // Visit a valid HTTPS url. | 917 // Visit a valid HTTPS url. |
| 917 GURL valid_https_url(https_server_.GetURL(std::string("/"))); | 918 GURL valid_https_url(https_server_.GetURL("/title1.html")); |
| 918 ui_test_utils::NavigateToURL(browser(), valid_https_url); | 919 ui_test_utils::NavigateToURL(browser(), valid_https_url); |
| 919 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, | 920 EXPECT_EQ(content::SECURITY_STYLE_AUTHENTICATED, |
| 920 observer.latest_security_style()); | 921 observer.latest_security_style()); |
| 921 EXPECT_EQ(0u, | 922 EXPECT_EQ(0u, |
| 922 observer.latest_explanations().unauthenticated_explanations.size()); | 923 observer.latest_explanations().unauthenticated_explanations.size()); |
| 923 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); | 924 EXPECT_EQ(0u, observer.latest_explanations().broken_explanations.size()); |
| 924 CheckSecureExplanations(observer.latest_explanations().secure_explanations, | 925 CheckSecureExplanations(observer.latest_explanations().secure_explanations, |
| 925 VALID_CERTIFICATE, browser()); | 926 VALID_CERTIFICATE, browser()); |
| 926 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); | 927 EXPECT_TRUE(observer.latest_explanations().scheme_is_cryptographic); |
| 927 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); | 928 EXPECT_FALSE(observer.latest_explanations().pkp_bypassed); |
| 928 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); | 929 EXPECT_TRUE(observer.latest_explanations().info_explanations.empty()); |
| 929 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); | 930 EXPECT_FALSE(observer.latest_explanations().displayed_insecure_content); |
| 930 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); | 931 EXPECT_FALSE(observer.latest_explanations().ran_insecure_content); |
| 931 | 932 |
| 932 // Navigate to a bad HTTPS page on a different host, and then click | 933 // Navigate to a bad HTTPS page on a different host, and then click |
| 933 // Back to verify that the previous good security style is seen again. | 934 // Back to verify that the previous good security style is seen again. |
| 934 GURL expired_https_url(https_test_server_expired.GetURL(std::string("/"))); | 935 GURL expired_https_url(https_test_server_expired.GetURL("/title1.html")); |
| 935 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1"); | 936 host_resolver()->AddRule("www.example_broken.test", "127.0.0.1"); |
| 936 GURL::Replacements replace_host; | 937 GURL::Replacements replace_host; |
| 937 replace_host.SetHostStr("www.example_broken.test"); | 938 replace_host.SetHostStr("www.example_broken.test"); |
| 938 GURL https_url_different_host = | 939 GURL https_url_different_host = |
| 939 expired_https_url.ReplaceComponents(replace_host); | 940 expired_https_url.ReplaceComponents(replace_host); |
| 940 | 941 |
| 941 ui_test_utils::NavigateToURL(browser(), https_url_different_host); | 942 ui_test_utils::NavigateToURL(browser(), https_url_different_host); |
| 942 | 943 |
| 943 content::WaitForInterstitialAttach(web_contents); | 944 content::WaitForInterstitialAttach(web_contents); |
| 944 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); | 945 EXPECT_TRUE(web_contents->ShowingInterstitialPage()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1107 // downgraded: SECURE_PROTOCOL_AND_CIPHERSUITE should not show up when | 1108 // downgraded: SECURE_PROTOCOL_AND_CIPHERSUITE should not show up when |
| 1108 // the TLS settings are obsolete. | 1109 // the TLS settings are obsolete. |
| 1109 for (const auto& explanation : | 1110 for (const auto& explanation : |
| 1110 observer.latest_explanations().secure_explanations) { | 1111 observer.latest_explanations().secure_explanations) { |
| 1111 EXPECT_NE(l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), | 1112 EXPECT_NE(l10n_util::GetStringUTF8(IDS_SECURE_PROTOCOL_AND_CIPHERSUITE), |
| 1112 explanation.summary); | 1113 explanation.summary); |
| 1113 } | 1114 } |
| 1114 } | 1115 } |
| 1115 | 1116 |
| 1116 } // namespace | 1117 } // namespace |
| OLD | NEW |