Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ssl_host_state_delegate.h" | 5 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 // DidHostRunInsecureContent unit tests the expected behavior of calling | 189 // DidHostRunInsecureContent unit tests the expected behavior of calling |
| 190 // DidHostRunInsecureContent as well as HostRanInsecureContent to check if | 190 // DidHostRunInsecureContent as well as HostRanInsecureContent to check if |
| 191 // insecure content has been run and to mark it as such. | 191 // insecure content has been run and to mark it as such. |
| 192 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, | 192 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, |
| 193 DidHostRunInsecureContent) { | 193 DidHostRunInsecureContent) { |
| 194 content::WebContents* tab = | 194 content::WebContents* tab = |
| 195 browser()->tab_strip_model()->GetActiveWebContents(); | 195 browser()->tab_strip_model()->GetActiveWebContents(); |
| 196 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 196 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 197 content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate(); | 197 content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate(); |
| 198 | 198 |
| 199 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 42)); | 199 EXPECT_FALSE(state->DidHostRunInsecureContent( |
| 200 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191)); | 200 "www.google.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); |
| 201 EXPECT_FALSE(state->DidHostRunInsecureContent("example.com", 42)); | 201 EXPECT_FALSE(state->DidHostRunInsecureContent( |
| 202 "www.google.com", 191, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 203 EXPECT_FALSE(state->DidHostRunInsecureContent( | |
| 204 "example.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 202 | 205 |
| 203 state->HostRanInsecureContent("www.google.com", 42); | 206 state->HostRanInsecureContent("www.google.com", 42, |
| 207 content::SSLHostStateDelegate::MIXED_CONTENT); | |
| 204 | 208 |
| 205 EXPECT_TRUE(state->DidHostRunInsecureContent("www.google.com", 42)); | 209 EXPECT_TRUE(state->DidHostRunInsecureContent( |
| 206 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191)); | 210 "www.google.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); |
| 207 EXPECT_FALSE(state->DidHostRunInsecureContent("example.com", 42)); | 211 EXPECT_FALSE(state->DidHostRunInsecureContent( |
| 212 "www.google.com", 191, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 213 EXPECT_FALSE(state->DidHostRunInsecureContent( | |
| 214 "example.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 208 | 215 |
| 209 state->HostRanInsecureContent("example.com", 42); | 216 state->HostRanInsecureContent("example.com", 42, |
| 217 content::SSLHostStateDelegate::MIXED_CONTENT); | |
| 210 | 218 |
| 211 EXPECT_TRUE(state->DidHostRunInsecureContent("www.google.com", 42)); | 219 EXPECT_TRUE(state->DidHostRunInsecureContent( |
| 212 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191)); | 220 "www.google.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); |
| 213 EXPECT_TRUE(state->DidHostRunInsecureContent("example.com", 42)); | 221 EXPECT_FALSE(state->DidHostRunInsecureContent( |
| 222 "www.google.com", 191, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 223 EXPECT_TRUE(state->DidHostRunInsecureContent( | |
| 224 "example.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 225 | |
| 226 state->HostRanInsecureContent( | |
| 227 "example.com", 42, content::SSLHostStateDelegate::CERT_ERRORS_CONTENT); | |
| 228 EXPECT_FALSE(state->DidHostRunInsecureContent( | |
| 229 "www.google.com", 191, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 230 EXPECT_TRUE(state->DidHostRunInsecureContent( | |
| 231 "example.com", 42, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 232 EXPECT_TRUE(state->DidHostRunInsecureContent( | |
| 233 "example.com", 42, content::SSLHostStateDelegate::CERT_ERRORS_CONTENT)); | |
| 234 | |
| 235 state->HostRanInsecureContent( | |
|
jww
2016/08/11 18:50:15
This looks identical to the set of tests right abo
estark
2016/08/11 20:58:38
As best as I can interpret past-Emily's intentions
| |
| 236 "www.google.com", 191, | |
| 237 content::SSLHostStateDelegate::CERT_ERRORS_CONTENT); | |
| 238 EXPECT_TRUE(state->DidHostRunInsecureContent( | |
| 239 "www.google.com", 191, | |
| 240 content::SSLHostStateDelegate::CERT_ERRORS_CONTENT)); | |
| 241 EXPECT_FALSE(state->DidHostRunInsecureContent( | |
| 242 "www.google.com", 191, content::SSLHostStateDelegate::MIXED_CONTENT)); | |
| 214 } | 243 } |
| 215 | 244 |
| 216 // Test the migration code needed as a result of changing how the content | 245 // Test the migration code needed as a result of changing how the content |
| 217 // setting is stored. We used to map the settings dictionary to the pattern | 246 // setting is stored. We used to map the settings dictionary to the pattern |
| 218 // pair <origin, origin> but now we map it to <origin, wildcard>. | 247 // pair <origin, origin> but now we map it to <origin, wildcard>. |
| 219 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, Migrate) { | 248 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, Migrate) { |
| 220 scoped_refptr<net::X509Certificate> cert = GetOkCert(); | 249 scoped_refptr<net::X509Certificate> cert = GetOkCert(); |
| 221 content::WebContents* tab = | 250 content::WebContents* tab = |
| 222 browser()->tab_strip_model()->GetActiveWebContents(); | 251 browser()->tab_strip_model()->GetActiveWebContents(); |
| 223 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 252 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 EXPECT_EQ( | 653 EXPECT_EQ( |
| 625 content::SSLHostStateDelegate::ALLOWED, | 654 content::SSLHostStateDelegate::ALLOWED, |
| 626 state->QueryPolicy("localhost", *cert, | 655 state->QueryPolicy("localhost", *cert, |
| 627 net::CERT_STATUS_COMMON_NAME_INVALID, &unused_value)); | 656 net::CERT_STATUS_COMMON_NAME_INVALID, &unused_value)); |
| 628 | 657 |
| 629 EXPECT_EQ( | 658 EXPECT_EQ( |
| 630 content::SSLHostStateDelegate::ALLOWED, | 659 content::SSLHostStateDelegate::ALLOWED, |
| 631 state->QueryPolicy("127.0.0.1", *cert, | 660 state->QueryPolicy("127.0.0.1", *cert, |
| 632 net::CERT_STATUS_COMMON_NAME_INVALID, &unused_value)); | 661 net::CERT_STATUS_COMMON_NAME_INVALID, &unused_value)); |
| 633 } | 662 } |
| OLD | NEW |