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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 789 } |
790 | 790 |
791 // Tests that the security level of data: URLs is always downgraded to | 791 // Tests that the security level of data: URLs is always downgraded to |
792 // HTTP_SHOW_WARNING. | 792 // HTTP_SHOW_WARNING. |
793 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest, | 793 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTest, |
794 SecurityLevelDowngradedOnDataUrl) { | 794 SecurityLevelDowngradedOnDataUrl) { |
795 content::WebContents* contents = | 795 content::WebContents* contents = |
796 browser()->tab_strip_model()->GetActiveWebContents(); | 796 browser()->tab_strip_model()->GetActiveWebContents(); |
797 ASSERT_TRUE(contents); | 797 ASSERT_TRUE(contents); |
798 | 798 |
| 799 SecurityStyleTestObserver observer(contents); |
| 800 |
799 SecurityStateTabHelper* helper = | 801 SecurityStateTabHelper* helper = |
800 SecurityStateTabHelper::FromWebContents(contents); | 802 SecurityStateTabHelper::FromWebContents(contents); |
801 ASSERT_TRUE(helper); | 803 ASSERT_TRUE(helper); |
802 | 804 |
803 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,<html></html>")); | 805 ui_test_utils::NavigateToURL(browser(), GURL("data:text/html,<html></html>")); |
804 security_state::SecurityInfo security_info; | 806 security_state::SecurityInfo security_info; |
805 helper->GetSecurityInfo(&security_info); | 807 helper->GetSecurityInfo(&security_info); |
806 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); | 808 EXPECT_EQ(security_state::HTTP_SHOW_WARNING, security_info.security_level); |
807 | 809 |
| 810 // Ensure that WebContentsObservers don't show an incorrect Form Not Secure |
| 811 // explanation. Regression test for https://crbug.com/691412. |
| 812 EXPECT_EQ(0u, |
| 813 observer.latest_explanations().unauthenticated_explanations.size()); |
| 814 EXPECT_EQ(blink::WebSecurityStyleUnauthenticated, |
| 815 observer.latest_security_style()); |
| 816 |
808 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 817 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
809 ASSERT_TRUE(entry); | 818 ASSERT_TRUE(entry); |
810 EXPECT_EQ(content::SSLStatus::NORMAL_CONTENT, entry->GetSSL().content_status); | 819 EXPECT_EQ(content::SSLStatus::NORMAL_CONTENT, entry->GetSSL().content_status); |
811 } | 820 } |
812 | 821 |
813 const char kReportURI[] = "https://report-hpkp.test"; | 822 const char kReportURI[] = "https://report-hpkp.test"; |
814 | 823 |
815 class PKPModelClientTest : public SecurityStateTabHelperTest { | 824 class PKPModelClientTest : public SecurityStateTabHelperTest { |
816 public: | 825 public: |
817 void SetUpOnMainThread() override { | 826 void SetUpOnMainThread() override { |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 SecurityStateTabHelper* helper = | 2018 SecurityStateTabHelper* helper = |
2010 SecurityStateTabHelper::FromWebContents(web_contents); | 2019 SecurityStateTabHelper::FromWebContents(web_contents); |
2011 ASSERT_TRUE(helper); | 2020 ASSERT_TRUE(helper); |
2012 security_state::SecurityInfo security_info; | 2021 security_state::SecurityInfo security_info; |
2013 helper->GetSecurityInfo(&security_info); | 2022 helper->GetSecurityInfo(&security_info); |
2014 EXPECT_EQ(security_state::SECURE, security_info.security_level); | 2023 EXPECT_EQ(security_state::SECURE, security_info.security_level); |
2015 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); | 2024 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); |
2016 } | 2025 } |
2017 | 2026 |
2018 } // namespace | 2027 } // namespace |
OLD | NEW |