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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/test/simple_test_clock.h" | 9 #include "base/test/simple_test_clock.h" |
10 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 net::CertPolicy::UNKNOWN, | 195 net::CertPolicy::UNKNOWN, |
196 state->QueryPolicy( | 196 state->QueryPolicy( |
197 kWWWGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID)); | 197 kWWWGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID)); |
198 EXPECT_FALSE(state->HasAllowedOrDeniedCert(kExampleHost)); | 198 EXPECT_FALSE(state->HasAllowedOrDeniedCert(kExampleHost)); |
199 EXPECT_EQ( | 199 EXPECT_EQ( |
200 net::CertPolicy::UNKNOWN, | 200 net::CertPolicy::UNKNOWN, |
201 state->QueryPolicy( | 201 state->QueryPolicy( |
202 kExampleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID)); | 202 kExampleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID)); |
203 } | 203 } |
204 | 204 |
| 205 // DidHostRunInsecureContent unit tests the expected behavior of calling |
| 206 // DidHostRunInsecureContent as well as HostRanInsecureContent to check if |
| 207 // insecure content has been run and to mark it as such. |
| 208 IN_PROC_BROWSER_TEST_F(ChromeSSLHostStateDelegateTest, |
| 209 DidHostRunInsecureContent) { |
| 210 content::WebContents* tab = |
| 211 browser()->tab_strip_model()->GetActiveWebContents(); |
| 212 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 213 content::SSLHostStateDelegate* state = profile->GetSSLHostStateDelegate(); |
| 214 |
| 215 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 42)); |
| 216 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191)); |
| 217 EXPECT_FALSE(state->DidHostRunInsecureContent("example.com", 42)); |
| 218 |
| 219 state->HostRanInsecureContent("www.google.com", 42); |
| 220 |
| 221 EXPECT_TRUE(state->DidHostRunInsecureContent("www.google.com", 42)); |
| 222 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191)); |
| 223 EXPECT_FALSE(state->DidHostRunInsecureContent("example.com", 42)); |
| 224 |
| 225 state->HostRanInsecureContent("example.com", 42); |
| 226 |
| 227 EXPECT_TRUE(state->DidHostRunInsecureContent("www.google.com", 42)); |
| 228 EXPECT_FALSE(state->DidHostRunInsecureContent("www.google.com", 191)); |
| 229 EXPECT_TRUE(state->DidHostRunInsecureContent("example.com", 42)); |
| 230 } |
| 231 |
205 // Tests the basic behavior of cert memory in incognito. | 232 // Tests the basic behavior of cert memory in incognito. |
206 class IncognitoSSLHostStateDelegateTest | 233 class IncognitoSSLHostStateDelegateTest |
207 : public ChromeSSLHostStateDelegateTest { | 234 : public ChromeSSLHostStateDelegateTest { |
208 protected: | 235 protected: |
209 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 236 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
210 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); | 237 ChromeSSLHostStateDelegateTest::SetUpCommandLine(command_line); |
211 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, | 238 command_line->AppendSwitchASCII(switches::kRememberCertErrorDecisions, |
212 kDeltaSecondsString); | 239 kDeltaSecondsString); |
213 } | 240 } |
214 }; | 241 }; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 | 468 |
442 // Add an exception for an invalid certificate. Then remove the last hour's | 469 // Add an exception for an invalid certificate. Then remove the last hour's |
443 // worth of browsing history and verify that the exception has been deleted. | 470 // worth of browsing history and verify that the exception has been deleted. |
444 state->AllowCert( | 471 state->AllowCert( |
445 kGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID); | 472 kGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID); |
446 RemoveAndWait(profile); | 473 RemoveAndWait(profile); |
447 EXPECT_EQ(net::CertPolicy::UNKNOWN, | 474 EXPECT_EQ(net::CertPolicy::UNKNOWN, |
448 state->QueryPolicy( | 475 state->QueryPolicy( |
449 kGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID)); | 476 kGoogleHost, google_cert.get(), net::CERT_STATUS_DATE_INVALID)); |
450 } | 477 } |
OLD | NEW |