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/chrome_security_state_model_client.h" | 5 #include "chrome/browser/ssl/chrome_security_state_model_client.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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 ui_test_utils::NavigateToURL(browser(), | 361 ui_test_utils::NavigateToURL(browser(), |
362 https_server_.GetURL(replacement_path)); | 362 https_server_.GetURL(replacement_path)); |
363 CheckSecurityInfoForSecure( | 363 CheckSecurityInfoForSecure( |
364 browser()->tab_strip_model()->GetActiveWebContents(), | 364 browser()->tab_strip_model()->GetActiveWebContents(), |
365 SecurityStateModel::SECURITY_ERROR, | 365 SecurityStateModel::SECURITY_ERROR, |
366 SecurityStateModel::DEPRECATED_SHA1_MAJOR, | 366 SecurityStateModel::DEPRECATED_SHA1_MAJOR, |
367 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT, | 367 SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT, |
368 false /* expect cert status error */); | 368 false /* expect cert status error */); |
369 } | 369 } |
370 | 370 |
| 371 // Tests that the Content Security Policy block-all-mixed-content |
| 372 // directive stops mixed content from running. |
| 373 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, |
| 374 MixedContentStrictBlocking) { |
| 375 ASSERT_TRUE(https_server_.Start()); |
| 376 SetUpMockCertVerifierForHttpsServer(0, net::OK); |
| 377 |
| 378 // Navigate to an HTTPS page that tries to run mixed content in an |
| 379 // iframe, with strict mixed content blocking. |
| 380 std::string replacement_path; |
| 381 net::HostPortPair host_port_pair = |
| 382 net::HostPortPair::FromURL(https_server_.GetURL("/")); |
| 383 host_port_pair.set_host("different-host.test"); |
| 384 host_resolver()->AddRule("different-host.test", |
| 385 https_server_.GetURL("/").host()); |
| 386 GetFilePathWithHostAndPortReplacement( |
| 387 "/ssl/page_runs_insecure_content_in_iframe_with_strict_blocking.html", |
| 388 host_port_pair, &replacement_path); |
| 389 ui_test_utils::NavigateToURL(browser(), |
| 390 https_server_.GetURL(replacement_path)); |
| 391 CheckSecurityInfoForSecure( |
| 392 browser()->tab_strip_model()->GetActiveWebContents(), |
| 393 SecurityStateModel::SECURE, SecurityStateModel::NO_DEPRECATED_SHA1, |
| 394 SecurityStateModel::NO_MIXED_CONTENT, |
| 395 false /* expect cert status error */); |
| 396 } |
| 397 |
371 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, BrokenHTTPS) { | 398 IN_PROC_BROWSER_TEST_F(ChromeSecurityStateModelClientTest, BrokenHTTPS) { |
372 ASSERT_TRUE(embedded_test_server()->Start()); | 399 ASSERT_TRUE(embedded_test_server()->Start()); |
373 ASSERT_TRUE(https_server_.Start()); | 400 ASSERT_TRUE(https_server_.Start()); |
374 SetUpMockCertVerifierForHttpsServer(net::CERT_STATUS_DATE_INVALID, | 401 SetUpMockCertVerifierForHttpsServer(net::CERT_STATUS_DATE_INVALID, |
375 net::ERR_CERT_DATE_INVALID); | 402 net::ERR_CERT_DATE_INVALID); |
376 | 403 |
377 ui_test_utils::NavigateToURL(browser(), | 404 ui_test_utils::NavigateToURL(browser(), |
378 https_server_.GetURL("/ssl/google.html")); | 405 https_server_.GetURL("/ssl/google.html")); |
379 CheckSecurityInfoForSecure( | 406 CheckSecurityInfoForSecure( |
380 browser()->tab_strip_model()->GetActiveWebContents(), | 407 browser()->tab_strip_model()->GetActiveWebContents(), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 529 |
503 browser()->tab_strip_model()->InsertWebContentsAt(0, new_contents, | 530 browser()->tab_strip_model()->InsertWebContentsAt(0, new_contents, |
504 TabStripModel::ADD_NONE); | 531 TabStripModel::ADD_NONE); |
505 CheckSecurityInfoForSecure(new_contents, SecurityStateModel::SECURE, | 532 CheckSecurityInfoForSecure(new_contents, SecurityStateModel::SECURE, |
506 SecurityStateModel::NO_DEPRECATED_SHA1, | 533 SecurityStateModel::NO_DEPRECATED_SHA1, |
507 SecurityStateModel::NO_MIXED_CONTENT, | 534 SecurityStateModel::NO_MIXED_CONTENT, |
508 false /* expect cert status error */); | 535 false /* expect cert status error */); |
509 } | 536 } |
510 | 537 |
511 } // namespace | 538 } // namespace |
OLD | NEW |