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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 | 538 |
528 // We should be back to the original good page. | 539 // We should be back to the original good page. |
529 CheckAuthenticatedState(tab, AuthState::NONE); | 540 CheckAuthenticatedState(tab, AuthState::NONE); |
530 | 541 |
531 // Try to navigate to a new page. (to make sure bug 5800 is fixed). | 542 // Try to navigate to a new page. (to make sure bug 5800 is fixed). |
532 ui_test_utils::NavigateToURL(browser(), | 543 ui_test_utils::NavigateToURL(browser(), |
533 test_server()->GetURL("files/ssl/google.html")); | 544 test_server()->GetURL("files/ssl/google.html")); |
534 CheckUnauthenticatedState(tab, AuthState::NONE); | 545 CheckUnauthenticatedState(tab, AuthState::NONE); |
535 } | 546 } |
536 | 547 |
548 // Test that localhost pages don't show an interstitial. | |
549 IN_PROC_BROWSER_TEST_F(SSLUITestIgnoreLocalhostCertErrors, | |
550 TestNoInterstitialOnLocalhost) { | |
551 ASSERT_TRUE(https_server_.Start()); | |
552 | |
553 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | |
554 | |
555 // Navigate to a localhost page. | |
556 GURL url = https_server_.GetURL("files/ssl/page_with_subresource.html"); | |
557 GURL::Replacements replacements; | |
558 std::string new_host("localhost"); | |
559 replacements.SetHostStr(new_host); | |
560 url = url.ReplaceComponents(replacements); | |
561 | |
562 ui_test_utils::NavigateToURL(browser(), url); | |
563 | |
564 // We should see no interstitial, but we should have an error | |
565 // (red-crossed-out-https) in the URL bar. | |
566 CheckAuthenticationBrokenState(tab, | |
567 net::CERT_STATUS_COMMON_NAME_INVALID, | |
568 AuthState::NONE); | |
569 | |
570 // We should see that the script tag in the page loaded and ran (and | |
571 // wasn't blocked by the certificate error). | |
Ryan Sleevi
2015/02/09 19:31:34
Prevailing code pattern wins here (meaning no chan
estark
2015/02/09 20:48:40
Interesting thread! This is going to be a tough ha
| |
572 base::string16 title; | |
573 base::string16 expected_title = base::ASCIIToUTF16("This script has loaded"); | |
574 ui_test_utils::GetCurrentTabTitle(browser(), &title); | |
575 EXPECT_EQ(title, expected_title); | |
576 } | |
577 | |
537 // Visits a page with https error and then goes back using Browser::GoBack. | 578 // Visits a page with https error and then goes back using Browser::GoBack. |
538 IN_PROC_BROWSER_TEST_F(SSLUITest, | 579 IN_PROC_BROWSER_TEST_F(SSLUITest, |
539 TestHTTPSExpiredCertAndGoBackViaButton) { | 580 TestHTTPSExpiredCertAndGoBackViaButton) { |
540 ASSERT_TRUE(test_server()->Start()); | 581 ASSERT_TRUE(test_server()->Start()); |
541 ASSERT_TRUE(https_server_expired_.Start()); | 582 ASSERT_TRUE(https_server_expired_.Start()); |
542 | 583 |
543 // First navigate to an HTTP page. | 584 // First navigate to an HTTP page. |
544 ui_test_utils::NavigateToURL(browser(), | 585 ui_test_utils::NavigateToURL(browser(), |
545 test_server()->GetURL("files/ssl/google.html")); | 586 test_server()->GetURL("files/ssl/google.html")); |
546 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 587 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1880 | 1921 |
1881 // Visit a page over https that contains a frame with a redirect. | 1922 // Visit a page over https that contains a frame with a redirect. |
1882 | 1923 |
1883 // XMLHttpRequest insecure content in synchronous mode. | 1924 // XMLHttpRequest insecure content in synchronous mode. |
1884 | 1925 |
1885 // XMLHttpRequest insecure content in asynchronous mode. | 1926 // XMLHttpRequest insecure content in asynchronous mode. |
1886 | 1927 |
1887 // XMLHttpRequest over bad ssl in synchronous mode. | 1928 // XMLHttpRequest over bad ssl in synchronous mode. |
1888 | 1929 |
1889 // XMLHttpRequest over OK ssl in synchronous mode. | 1930 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |