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/security_state_tab_helper.h" | 5 #include "chrome/browser/ssl/security_state_tab_helper.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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 embedded_test_server()->host_port_pair(), &replacement_path); | 755 embedded_test_server()->host_port_pair(), &replacement_path); |
756 ui_test_utils::NavigateToURL(browser(), | 756 ui_test_utils::NavigateToURL(browser(), |
757 https_server_.GetURL(replacement_path)); | 757 https_server_.GetURL(replacement_path)); |
758 CheckSecurityInfoForSecure( | 758 CheckSecurityInfoForSecure( |
759 browser()->tab_strip_model()->GetActiveWebContents(), | 759 browser()->tab_strip_model()->GetActiveWebContents(), |
760 security_state::DANGEROUS, false, | 760 security_state::DANGEROUS, false, |
761 security_state::CONTENT_STATUS_DISPLAYED, false, | 761 security_state::CONTENT_STATUS_DISPLAYED, false, |
762 true /* expect cert status error */); | 762 true /* expect cert status error */); |
763 } | 763 } |
764 | 764 |
| 765 // Tests that the security level of data: URLs is always downgraded to |
| 766 // HTTP_SHOW_WARNING. |
| 767 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest, |
| 768 SecurityLevelDowngradedOnDataUrl) { |
| 769 content::WebContents* contents = |
| 770 browser()->tab_strip_model()->GetActiveWebContents(); |
| 771 ASSERT_TRUE(contents); |
| 772 |
| 773 SecurityStateTabHelper* helper = |
| 774 SecurityStateTabHelper::FromWebContents(contents); |
| 775 ASSERT_TRUE(helper); |
| 776 |
| 777 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,<html></html>")); |
| 778 security_state::SecurityInfo security_info; |
| 779 helper->GetSecurityInfo(&security_info); |
| 780 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); |
| 781 |
| 782 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
| 783 ASSERT_TRUE(entry); |
| 784 EXPECT_EQ(content::SSLStatus::NORMAL_CONTENT, entry->GetSSL().content_status); |
| 785 } |
| 786 |
765 const char kReportURI[] = "https://report-hpkp.test"; | 787 const char kReportURI[] = "https://report-hpkp.test"; |
766 | 788 |
767 class PKPModelClientTest : public SecurityStateTabHelperTest { | 789 class PKPModelClientTest : public SecurityStateTabHelperTest { |
768 public: | 790 public: |
769 void SetUpOnMainThread() override { | 791 void SetUpOnMainThread() override { |
770 ASSERT_TRUE(https_server_.Start()); | 792 ASSERT_TRUE(https_server_.Start()); |
771 url_request_context_getter_ = browser()->profile()->GetRequestContext(); | 793 url_request_context_getter_ = browser()->profile()->GetRequestContext(); |
772 content::BrowserThread::PostTask( | 794 content::BrowserThread::PostTask( |
773 content::BrowserThread::IO, FROM_HERE, | 795 content::BrowserThread::IO, FROM_HERE, |
774 base::Bind(&PKPModelClientTest::SetUpOnIOThread, | 796 base::Bind(&PKPModelClientTest::SetUpOnIOThread, |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 SecurityStateTabHelper* helper = | 2043 SecurityStateTabHelper* helper = |
2022 SecurityStateTabHelper::FromWebContents(web_contents); | 2044 SecurityStateTabHelper::FromWebContents(web_contents); |
2023 ASSERT_TRUE(helper); | 2045 ASSERT_TRUE(helper); |
2024 security_state::SecurityInfo security_info; | 2046 security_state::SecurityInfo security_info; |
2025 helper->GetSecurityInfo(&security_info); | 2047 helper->GetSecurityInfo(&security_info); |
2026 EXPECT_EQ(security_state::SECURE, security_info.security_level); | 2048 EXPECT_EQ(security_state::SECURE, security_info.security_level); |
2027 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); | 2049 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); |
2028 } | 2050 } |
2029 | 2051 |
2030 } // namespace | 2052 } // namespace |
OLD | NEW |