| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| 30 #include "content/public/browser/interstitial_page.h" | 30 #include "content/public/browser/interstitial_page.h" |
| 31 #include "content/public/browser/navigation_controller.h" | 31 #include "content/public/browser/navigation_controller.h" |
| 32 #include "content/public/browser/navigation_entry.h" | 32 #include "content/public/browser/navigation_entry.h" |
| 33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/render_frame_host.h" | 34 #include "content/public/browser/render_frame_host.h" |
| 35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| 36 #include "content/public/browser/render_widget_host_view.h" | 36 #include "content/public/browser/render_widget_host_view.h" |
| 37 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
| 38 #include "content/public/browser/web_contents_observer.h" | 38 #include "content/public/browser/web_contents_observer.h" |
| 39 #include "content/public/common/content_switches.h" |
| 39 #include "content/public/common/security_style.h" | 40 #include "content/public/common/security_style.h" |
| 40 #include "content/public/common/ssl_status.h" | 41 #include "content/public/common/ssl_status.h" |
| 41 #include "content/public/test/browser_test_utils.h" | 42 #include "content/public/test/browser_test_utils.h" |
| 42 #include "content/public/test/download_test_observer.h" | 43 #include "content/public/test/download_test_observer.h" |
| 43 #include "content/public/test/test_renderer_host.h" | 44 #include "content/public/test/test_renderer_host.h" |
| 44 #include "net/base/net_errors.h" | 45 #include "net/base/net_errors.h" |
| 45 #include "net/base/test_data_directory.h" | 46 #include "net/base/test_data_directory.h" |
| 46 #include "net/cert/cert_status_flags.h" | 47 #include "net/cert/cert_status_flags.h" |
| 47 #include "net/test/spawned_test_server/spawned_test_server.h" | 48 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 48 | 49 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 class SSLUITestIgnoreCertErrors : public SSLUITest { | 374 class SSLUITestIgnoreCertErrors : public SSLUITest { |
| 374 public: | 375 public: |
| 375 SSLUITestIgnoreCertErrors() : SSLUITest() {} | 376 SSLUITestIgnoreCertErrors() : SSLUITest() {} |
| 376 | 377 |
| 377 void SetUpCommandLine(base::CommandLine* command_line) override { | 378 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 378 // Browser will ignore certificate errors. | 379 // Browser will ignore certificate errors. |
| 379 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); | 380 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); |
| 380 } | 381 } |
| 381 }; | 382 }; |
| 382 | 383 |
| 384 class SSLUITestIgnoreLocalhostCertErrors : public SSLUITest { |
| 385 public: |
| 386 SSLUITestIgnoreLocalhostCertErrors() : SSLUITest() {} |
| 387 |
| 388 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 389 // Browser will ignore certificate errors on localhost. |
| 390 command_line->AppendSwitch(switches::kAllowInsecureLocalhost); |
| 391 } |
| 392 }; |
| 393 |
| 383 // Visits a regular page over http. | 394 // Visits a regular page over http. |
| 384 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { | 395 IN_PROC_BROWSER_TEST_F(SSLUITest, TestHTTP) { |
| 385 ASSERT_TRUE(test_server()->Start()); | 396 ASSERT_TRUE(test_server()->Start()); |
| 386 | 397 |
| 387 ui_test_utils::NavigateToURL(browser(), | 398 ui_test_utils::NavigateToURL(browser(), |
| 388 test_server()->GetURL("files/ssl/google.html")); | 399 test_server()->GetURL("files/ssl/google.html")); |
| 389 | 400 |
| 390 CheckUnauthenticatedState( | 401 CheckUnauthenticatedState( |
| 391 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); | 402 browser()->tab_strip_model()->GetActiveWebContents(), AuthState::NONE); |
| 392 } | 403 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 537 |
| 527 // We should be back to the original good page. | 538 // We should be back to the original good page. |
| 528 CheckAuthenticatedState(tab, AuthState::NONE); | 539 CheckAuthenticatedState(tab, AuthState::NONE); |
| 529 | 540 |
| 530 // Try to navigate to a new page. (to make sure bug 5800 is fixed). | 541 // Try to navigate to a new page. (to make sure bug 5800 is fixed). |
| 531 ui_test_utils::NavigateToURL(browser(), | 542 ui_test_utils::NavigateToURL(browser(), |
| 532 test_server()->GetURL("files/ssl/google.html")); | 543 test_server()->GetURL("files/ssl/google.html")); |
| 533 CheckUnauthenticatedState(tab, AuthState::NONE); | 544 CheckUnauthenticatedState(tab, AuthState::NONE); |
| 534 } | 545 } |
| 535 | 546 |
| 547 // Test that localhost pages don't show an interstitial. |
| 548 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors, |
| 549 TestNoInterstitialOnLocalhost) { |
| 550 ASSERT_TRUE(https_server_.Start()); |
| 551 |
| 552 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 553 |
| 554 // Navigate to a localhost page. |
| 555 GURL url = https_server_.GetURL("files/ssl/page_with_subresource.html"); |
| 556 GURL::Replacements replacements; |
| 557 std::string new_host("localhost"); |
| 558 replacements.SetHostStr(new_host); |
| 559 url = url.ReplaceComponents(replacements); |
| 560 |
| 561 ui_test_utils::NavigateToURL(browser(), url); |
| 562 |
| 563 // We should see no interstitial, but we should have an error |
| 564 // (red-crossed-out-https) in the URL bar. |
| 565 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, |
| 566 AuthState::NONE); |
| 567 |
| 568 // We should see that the script tag in the page loaded and ran (and |
| 569 // wasn't blocked by the certificate error). |
| 570 base::string16 title; |
| 571 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); |
| 572 ui_test_utils::GetCurrentTabTitle(browser(), &title); |
| 573 EXPECT_EQ(title, expected_title); |
| 574 } |
| 575 |
| 536 // Visits a page with https error and then goes back using Browser::GoBack. | 576 // Visits a page with https error and then goes back using Browser::GoBack. |
| 537 IN_PROC_BROWSER_TEST_F(SSLUITest, | 577 IN_PROC_BROWSER_TEST_F(SSLUITest, |
| 538 TestHTTPSExpiredCertAndGoBackViaButton) { | 578 TestHTTPSExpiredCertAndGoBackViaButton) { |
| 539 ASSERT_TRUE(test_server()->Start()); | 579 ASSERT_TRUE(test_server()->Start()); |
| 540 ASSERT_TRUE(https_server_expired_.Start()); | 580 ASSERT_TRUE(https_server_expired_.Start()); |
| 541 | 581 |
| 542 // First navigate to an HTTP page. | 582 // First navigate to an HTTP page. |
| 543 ui_test_utils::NavigateToURL(browser(), | 583 ui_test_utils::NavigateToURL(browser(), |
| 544 test_server()->GetURL("files/ssl/google.html")); | 584 test_server()->GetURL("files/ssl/google.html")); |
| 545 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 585 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 | 1916 |
| 1877 // Visit a page over https that contains a frame with a redirect. | 1917 // Visit a page over https that contains a frame with a redirect. |
| 1878 | 1918 |
| 1879 // XMLHttpRequest insecure content in synchronous mode. | 1919 // XMLHttpRequest insecure content in synchronous mode. |
| 1880 | 1920 |
| 1881 // XMLHttpRequest insecure content in asynchronous mode. | 1921 // XMLHttpRequest insecure content in asynchronous mode. |
| 1882 | 1922 |
| 1883 // XMLHttpRequest over bad ssl in synchronous mode. | 1923 // XMLHttpRequest over bad ssl in synchronous mode. |
| 1884 | 1924 |
| 1885 // XMLHttpRequest over OK ssl in synchronous mode. | 1925 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |