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/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "third_party/boringssl/src/include/openssl/ssl.h" | 56 #include "third_party/boringssl/src/include/openssl/ssl.h" |
| 57 #include "ui/base/l10n/l10n_util.h" | 57 #include "ui/base/l10n/l10n_util.h" |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 enum CertificateStatus { VALID_CERTIFICATE, INVALID_CERTIFICATE }; | 61 enum CertificateStatus { VALID_CERTIFICATE, INVALID_CERTIFICATE }; |
| 62 | 62 |
| 63 const base::FilePath::CharType kDocRoot[] = | 63 const base::FilePath::CharType kDocRoot[] = |
| 64 FILE_PATH_LITERAL("chrome/test/data"); | 64 FILE_PATH_LITERAL("chrome/test/data"); |
| 65 | 65 |
| 66 // Inject a script into the page. Used by tests that check for visible | 66 // Inject a script into every frame in the page. Used by tests that check for |
| 67 // password fields to wait for notifications about these | 67 // visible password fields to wait for notifications about these |
| 68 // fields. Notifications about visible password fields are queued at the | 68 // fields. Notifications about visible password fields are queued at the end of |
| 69 // end of the event loop, so waiting for a dummy script to run ensures | 69 // the event loop, so waiting for a dummy script to run ensures that these |
| 70 // that these notifcations have been sent. | 70 // notifcations have been sent. |
|
meacer
2017/02/10 01:50:55
nit: notifications
estark
2017/02/10 01:53:56
Good eye, done!
| |
| 71 void InjectScript(content::WebContents* contents) { | 71 void InjectScript(content::WebContents* contents) { |
| 72 bool js_result = false; | 72 // Any frame in the page might have a password field, so inject scripts into |
| 73 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 73 // all of them to ensure that notifications from all of them have been sent. |
| 74 contents, "window.domAutomationController.send(true);", &js_result)); | 74 for (const auto& frame : contents->GetAllFrames()) { |
| 75 EXPECT_TRUE(js_result); | 75 bool js_result = false; |
| 76 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 77 frame, "window.domAutomationController.send(true);", &js_result)); | |
| 78 EXPECT_TRUE(js_result); | |
| 79 } | |
| 76 } | 80 } |
| 77 | 81 |
| 78 // A WebContentsObserver useful for testing the DidChangeVisibleSecurityState() | 82 // A WebContentsObserver useful for testing the DidChangeVisibleSecurityState() |
| 79 // method: it keeps track of the latest security style and explanation that was | 83 // method: it keeps track of the latest security style and explanation that was |
| 80 // fired. | 84 // fired. |
| 81 class SecurityStyleTestObserver : public content::WebContentsObserver { | 85 class SecurityStyleTestObserver : public content::WebContentsObserver { |
| 82 public: | 86 public: |
| 83 explicit SecurityStyleTestObserver(content::WebContents* web_contents) | 87 explicit SecurityStyleTestObserver(content::WebContents* web_contents) |
| 84 : content::WebContentsObserver(web_contents), | 88 : content::WebContentsObserver(web_contents), |
| 85 latest_security_style_(blink::WebSecurityStyleUnknown) {} | 89 latest_security_style_(blink::WebSecurityStyleUnknown) {} |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1145 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); | 1149 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); |
| 1146 ASSERT_TRUE(entry); | 1150 ASSERT_TRUE(entry); |
| 1147 EXPECT_TRUE(entry->GetSSL().content_status & | 1151 EXPECT_TRUE(entry->GetSSL().content_status & |
| 1148 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | 1152 content::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| 1149 } | 1153 } |
| 1150 | 1154 |
| 1151 // Tests that when a visible password field is detected inside an iframe | 1155 // Tests that when a visible password field is detected inside an iframe |
| 1152 // on an HTTP page load, and when the command-line flag is set, the | 1156 // on an HTTP page load, and when the command-line flag is set, the |
| 1153 // security level is downgraded to HTTP_SHOW_WARNING, even if the iframe | 1157 // security level is downgraded to HTTP_SHOW_WARNING, even if the iframe |
| 1154 // itself was loaded over HTTPS. | 1158 // itself was loaded over HTTPS. |
| 1155 #if defined(OS_LINUX) | |
| 1156 // Flaky on Linux. See https://crbug.com/662485. | |
| 1157 #define MAYBE_PasswordSecurityLevelDowngradedFromHttpsIframe \ | |
| 1158 DISABLED_PasswordSecurityLevelDowngradedFromHttpsIframe | |
| 1159 #else | |
| 1160 #define MAYBE_PasswordSecurityLevelDowngradedFromHttpsIframe \ | |
| 1161 PasswordSecurityLevelDowngradedFromHttpsIframe | |
| 1162 #endif | |
| 1163 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, | 1159 IN_PROC_BROWSER_TEST_F(SecurityStateTabHelperTestWithPasswordCcSwitch, |
| 1164 MAYBE_PasswordSecurityLevelDowngradedFromHttpsIframe) { | 1160 PasswordSecurityLevelDowngradedFromHttpsIframe) { |
| 1165 content::WebContents* contents = | 1161 content::WebContents* contents = |
| 1166 browser()->tab_strip_model()->GetActiveWebContents(); | 1162 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1167 ASSERT_TRUE(contents); | 1163 ASSERT_TRUE(contents); |
| 1168 | 1164 |
| 1169 SecurityStateTabHelper* helper = | 1165 SecurityStateTabHelper* helper = |
| 1170 SecurityStateTabHelper::FromWebContents(contents); | 1166 SecurityStateTabHelper::FromWebContents(contents); |
| 1171 ASSERT_TRUE(helper); | 1167 ASSERT_TRUE(helper); |
| 1172 | 1168 |
| 1173 // Navigate to an HTTP URL, which loads an iframe using the host and port of | 1169 // Navigate to an HTTP URL, which loads an iframe using the host and port of |
| 1174 // |https_server_|. | 1170 // |https_server_|. |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2158 SecurityStateTabHelper* helper = | 2154 SecurityStateTabHelper* helper = |
| 2159 SecurityStateTabHelper::FromWebContents(web_contents); | 2155 SecurityStateTabHelper::FromWebContents(web_contents); |
| 2160 ASSERT_TRUE(helper); | 2156 ASSERT_TRUE(helper); |
| 2161 security_state::SecurityInfo security_info; | 2157 security_state::SecurityInfo security_info; |
| 2162 helper->GetSecurityInfo(&security_info); | 2158 helper->GetSecurityInfo(&security_info); |
| 2163 EXPECT_EQ(security_state::SECURE, security_info.security_level); | 2159 EXPECT_EQ(security_state::SECURE, security_info.security_level); |
| 2164 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); | 2160 EXPECT_EQ(kTestSCTStatuses, security_info.sct_verify_statuses); |
| 2165 } | 2161 } |
| 2166 | 2162 |
| 2167 } // namespace | 2163 } // namespace |
| OLD | NEW |