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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "components/content_settings/core/browser/host_content_settings_map.h" | 54 #include "components/content_settings/core/browser/host_content_settings_map.h" |
55 #include "components/network_time/network_time_test_utils.h" | 55 #include "components/network_time/network_time_test_utils.h" |
56 #include "components/network_time/network_time_tracker.h" | 56 #include "components/network_time/network_time_tracker.h" |
57 #include "components/prefs/testing_pref_service.h" | 57 #include "components/prefs/testing_pref_service.h" |
58 #include "components/security_interstitials/core/controller_client.h" | 58 #include "components/security_interstitials/core/controller_client.h" |
59 #include "components/security_interstitials/core/metrics_helper.h" | 59 #include "components/security_interstitials/core/metrics_helper.h" |
60 #include "components/security_state/core/security_state.h" | 60 #include "components/security_state/core/security_state.h" |
61 #include "components/security_state/core/switches.h" | 61 #include "components/security_state/core/switches.h" |
62 #include "components/ssl_errors/error_classification.h" | 62 #include "components/ssl_errors/error_classification.h" |
63 #include "components/variations/variations_associated_data.h" | 63 #include "components/variations/variations_associated_data.h" |
| 64 #include "components/variations/variations_switches.h" |
64 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 65 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
65 #include "content/public/browser/browser_context.h" | 66 #include "content/public/browser/browser_context.h" |
66 #include "content/public/browser/interstitial_page.h" | 67 #include "content/public/browser/interstitial_page.h" |
67 #include "content/public/browser/navigation_controller.h" | 68 #include "content/public/browser/navigation_controller.h" |
68 #include "content/public/browser/navigation_entry.h" | 69 #include "content/public/browser/navigation_entry.h" |
69 #include "content/public/browser/notification_details.h" | 70 #include "content/public/browser/notification_details.h" |
70 #include "content/public/browser/notification_service.h" | 71 #include "content/public/browser/notification_service.h" |
71 #include "content/public/browser/render_frame_host.h" | 72 #include "content/public/browser/render_frame_host.h" |
72 #include "content/public/browser/render_view_host.h" | 73 #include "content/public/browser/render_view_host.h" |
73 #include "content/public/browser/render_widget_host_view.h" | 74 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 20 matching lines...) Expand all Loading... |
94 #include "net/ssl/ssl_info.h" | 95 #include "net/ssl/ssl_info.h" |
95 #include "net/test/cert_test_util.h" | 96 #include "net/test/cert_test_util.h" |
96 #include "net/test/embedded_test_server/embedded_test_server.h" | 97 #include "net/test/embedded_test_server/embedded_test_server.h" |
97 #include "net/test/embedded_test_server/request_handler_util.h" | 98 #include "net/test/embedded_test_server/request_handler_util.h" |
98 #include "net/test/spawned_test_server/spawned_test_server.h" | 99 #include "net/test/spawned_test_server/spawned_test_server.h" |
99 #include "net/test/test_certificate_data.h" | 100 #include "net/test/test_certificate_data.h" |
100 #include "net/test/test_data_directory.h" | 101 #include "net/test/test_data_directory.h" |
101 #include "net/url_request/url_request_context.h" | 102 #include "net/url_request/url_request_context.h" |
102 #include "net/url_request/url_request_filter.h" | 103 #include "net/url_request/url_request_filter.h" |
103 #include "net/url_request/url_request_job.h" | 104 #include "net/url_request/url_request_job.h" |
| 105 #include "net/url_request/url_request_test_util.h" |
104 | 106 |
105 #if defined(USE_NSS_CERTS) | 107 #if defined(USE_NSS_CERTS) |
106 #include "chrome/browser/net/nss_context.h" | 108 #include "chrome/browser/net/nss_context.h" |
107 #include "net/base/crypto_module.h" | 109 #include "net/base/crypto_module.h" |
108 #include "net/cert/nss_cert_database.h" | 110 #include "net/cert/nss_cert_database.h" |
109 #endif // defined(USE_NSS_CERTS) | 111 #endif // defined(USE_NSS_CERTS) |
110 | 112 |
111 using base::ASCIIToUTF16; | 113 using base::ASCIIToUTF16; |
112 using chrome_browser_interstitials::SecurityInterstitialIDNTest; | 114 using chrome_browser_interstitials::SecurityInterstitialIDNTest; |
113 using content::InterstitialPage; | 115 using content::InterstitialPage; |
(...skipping 2887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3001 net::URLRequestFilter::GetInstance()->ClearHandlers(); | 3003 net::URLRequestFilter::GetInstance()->ClearHandlers(); |
3002 } | 3004 } |
3003 | 3005 |
3004 // A fixture for testing on-demand network time queries on SSL | 3006 // A fixture for testing on-demand network time queries on SSL |
3005 // certificate date errors. It can simulate a delayed network time | 3007 // certificate date errors. It can simulate a delayed network time |
3006 // request, and it allows the user to configure the experimental | 3008 // request, and it allows the user to configure the experimental |
3007 // parameters of the NetworkTimeTracker. Expects only one network time | 3009 // parameters of the NetworkTimeTracker. Expects only one network time |
3008 // request to be issued during the test. | 3010 // request to be issued during the test. |
3009 class SSLNetworkTimeBrowserTest : public SSLUITest { | 3011 class SSLNetworkTimeBrowserTest : public SSLUITest { |
3010 public: | 3012 public: |
3011 SSLNetworkTimeBrowserTest() | 3013 SSLNetworkTimeBrowserTest() : SSLUITest(), interceptor_(nullptr) {} |
3012 : SSLUITest(), | |
3013 field_trial_test_(network_time::FieldTrialTest::CreateForBrowserTest()), | |
3014 interceptor_(nullptr) {} | |
3015 ~SSLNetworkTimeBrowserTest() override {} | 3014 ~SSLNetworkTimeBrowserTest() override {} |
3016 | 3015 |
| 3016 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 3017 command_line->AppendSwitchASCII( |
| 3018 switches::kEnableFeatures, |
| 3019 std::string(network_time::kNetworkTimeServiceQuerying.name) + |
| 3020 "<SSLNetworkTimeBrowserTestFieldTrial"); |
| 3021 command_line->AppendSwitchASCII( |
| 3022 switches::kForceFieldTrials, |
| 3023 "SSLNetworkTimeBrowserTestFieldTrial/Enabled/"); |
| 3024 command_line->AppendSwitchASCII( |
| 3025 variations::switches::kForceFieldTrialParams, |
| 3026 "SSLNetworkTimeBrowserTestFieldTrial.Enabled:FetchBehavior/" |
| 3027 "on-demand-only"); |
| 3028 } |
| 3029 |
3017 void SetUpOnMainThread() override { SetUpNetworkTimeServer(); } | 3030 void SetUpOnMainThread() override { SetUpNetworkTimeServer(); } |
3018 | 3031 |
3019 void TearDownOnMainThread() override { | 3032 void TearDownOnMainThread() override { |
3020 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 3033 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
3021 base::Bind(&CleanUpOnIOThread)); | 3034 base::Bind(&CleanUpOnIOThread)); |
3022 } | 3035 } |
3023 | 3036 |
3024 protected: | 3037 protected: |
3025 network_time::FieldTrialTest* field_trial_test() const { | |
3026 return field_trial_test_.get(); | |
3027 } | |
3028 | |
3029 void SetUpNetworkTimeServer() { | 3038 void SetUpNetworkTimeServer() { |
3030 field_trial_test()->SetNetworkQueriesWithVariationsService( | 3039 // Install the URL interceptor that serves delayed network time responses. |
3031 true, 0.0, network_time::NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY); | |
3032 | |
3033 // Install the URL interceptor that serves delayed network time | |
3034 // responses. | |
3035 interceptor_ = new DelayedNetworkTimeInterceptor(); | 3040 interceptor_ = new DelayedNetworkTimeInterceptor(); |
3036 content::BrowserThread::PostTask( | 3041 content::BrowserThread::PostTask( |
3037 content::BrowserThread::IO, FROM_HERE, | 3042 content::BrowserThread::IO, FROM_HERE, |
3038 base::Bind(&SetUpNetworkTimeInterceptorOnIOThread, | 3043 base::Bind(&SetUpNetworkTimeInterceptorOnIOThread, |
3039 base::Unretained(interceptor_), | 3044 base::Unretained(interceptor_), |
3040 g_browser_process->network_time_tracker() | 3045 g_browser_process->network_time_tracker() |
3041 ->GetTimeServerURLForTesting())); | 3046 ->GetTimeServerURLForTesting())); |
3042 } | 3047 } |
3043 | 3048 |
3044 void TriggerTimeResponse() { | 3049 void TriggerTimeResponse() { |
3045 content::BrowserThread::PostTask( | 3050 content::BrowserThread::PostTask( |
3046 content::BrowserThread::IO, FROM_HERE, | 3051 content::BrowserThread::IO, FROM_HERE, |
3047 base::Bind(&ResumeDelayedNetworkTimeRequest, | 3052 base::Bind(&ResumeDelayedNetworkTimeRequest, |
3048 base::Unretained(interceptor_))); | 3053 base::Unretained(interceptor_))); |
3049 } | 3054 } |
3050 | 3055 |
3051 // Asserts that the first time request to the server is currently pending. | 3056 // Asserts that the first time request to the server is currently pending. |
3052 void CheckTimeQueryPending() { | 3057 void CheckTimeQueryPending() { |
3053 base::Time unused_time; | 3058 base::Time unused_time; |
3054 base::TimeDelta unused_uncertainty; | 3059 base::TimeDelta unused_uncertainty; |
3055 ASSERT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_FIRST_SYNC_PENDING, | 3060 ASSERT_EQ(network_time::NetworkTimeTracker::NETWORK_TIME_FIRST_SYNC_PENDING, |
3056 g_browser_process->network_time_tracker()->GetNetworkTime( | 3061 g_browser_process->network_time_tracker()->GetNetworkTime( |
3057 &unused_time, &unused_uncertainty)); | 3062 &unused_time, &unused_uncertainty)); |
3058 } | 3063 } |
3059 | 3064 |
3060 private: | 3065 private: |
3061 std::unique_ptr<network_time::FieldTrialTest> field_trial_test_; | |
3062 DelayedNetworkTimeInterceptor* interceptor_; | 3066 DelayedNetworkTimeInterceptor* interceptor_; |
3063 | 3067 |
3064 DISALLOW_COPY_AND_ASSIGN(SSLNetworkTimeBrowserTest); | 3068 DISALLOW_COPY_AND_ASSIGN(SSLNetworkTimeBrowserTest); |
3065 }; | 3069 }; |
3066 | 3070 |
3067 // Tests that if an on-demand network time fetch returns that the clock | 3071 // Tests that if an on-demand network time fetch returns that the clock |
3068 // is okay, a normal SSL interstitial is shown. | 3072 // is okay, a normal SSL interstitial is shown. |
3069 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, OnDemandFetchClockOk) { | 3073 IN_PROC_BROWSER_TEST_F(SSLNetworkTimeBrowserTest, OnDemandFetchClockOk) { |
3070 ASSERT_TRUE(https_server_expired_.Start()); | 3074 ASSERT_TRUE(https_server_expired_.Start()); |
3071 // Use a testing clock set to the time that GoodTimeResponseHandler | 3075 // Use a testing clock set to the time that GoodTimeResponseHandler |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3888 | 3892 |
3889 // Visit a page over https that contains a frame with a redirect. | 3893 // Visit a page over https that contains a frame with a redirect. |
3890 | 3894 |
3891 // XMLHttpRequest insecure content in synchronous mode. | 3895 // XMLHttpRequest insecure content in synchronous mode. |
3892 | 3896 |
3893 // XMLHttpRequest insecure content in asynchronous mode. | 3897 // XMLHttpRequest insecure content in asynchronous mode. |
3894 | 3898 |
3895 // XMLHttpRequest over bad ssl in synchronous mode. | 3899 // XMLHttpRequest over bad ssl in synchronous mode. |
3896 | 3900 |
3897 // XMLHttpRequest over OK ssl in synchronous mode. | 3901 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |