Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 1415923015: Downgrade lock icon for broken-HTTPS subresources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary includes Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 page_with_unsafe_worker_path)); 2110 page_with_unsafe_worker_path));
2111 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2111 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2112 // Expect Worker not to load insecure content. 2112 // Expect Worker not to load insecure content.
2113 CheckWorkerLoadResult(tab, false); 2113 CheckWorkerLoadResult(tab, false);
2114 // The bad content is filtered, expect the state to be authenticated. 2114 // The bad content is filtered, expect the state to be authenticated.
2115 CheckAuthenticatedState(tab, AuthState::NONE); 2115 CheckAuthenticatedState(tab, AuthState::NONE);
2116 } 2116 }
2117 2117
2118 // This test, and the related test TestUnsafeContentsWithUserException, verify 2118 // This test, and the related test TestUnsafeContentsWithUserException, verify
2119 // that if unsafe content is loaded but the host of that unsafe content has a 2119 // that if unsafe content is loaded but the host of that unsafe content has a
2120 // user exception, the content runs and the security style remains 2120 // user exception, the content runs and the security style is downgraded.
2121 // authenticated. This is not necessarily the behavior that should exist, but it
2122 // is verification that it does behave that way. See https://crbug.com/477868
2123 // for more inforamtion on this.
2124 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) { 2121 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) {
2125 ASSERT_TRUE(https_server_.Start()); 2122 ASSERT_TRUE(https_server_.Start());
2126 // Note that it is necessary to user https_server_mismatched_ here over the 2123 // Note that it is necessary to user https_server_mismatched_ here over the
2127 // other invalid cert servers. This is because the test relies on the two 2124 // other invalid cert servers. This is because the test relies on the two
2128 // servers having different hosts since SSL exceptions are per-host, not per 2125 // servers having different hosts since SSL exceptions are per-host, not per
2129 // origin, and https_server_mismatched_ uses 'localhost' rather than 2126 // origin, and https_server_mismatched_ uses 'localhost' rather than
2130 // '127.0.0.1'. 2127 // '127.0.0.1'.
2131 ASSERT_TRUE(https_server_mismatched_.Start()); 2128 ASSERT_TRUE(https_server_mismatched_.Start());
2132 2129
2133 // Navigate to an unsafe site. Proceed with interstitial page to indicate 2130 // Navigate to an unsafe site. Proceed with interstitial page to indicate
2134 // the user approves the bad certificate. 2131 // the user approves the bad certificate.
2135 ui_test_utils::NavigateToURL( 2132 ui_test_utils::NavigateToURL(
2136 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html")); 2133 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html"));
2137 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2134 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2138 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2135 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2139 AuthState::SHOWING_INTERSTITIAL); 2136 AuthState::SHOWING_INTERSTITIAL);
2140 ProceedThroughInterstitial(tab); 2137 ProceedThroughInterstitial(tab);
2141 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2138 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2142 AuthState::NONE); 2139 AuthState::NONE);
2143 2140
2144 // Navigate to safe page that has Worker loading unsafe content. 2141 // Navigate to safe page that has Worker loading unsafe content.
2145 // Expect content to load but be marked as auth broken due to running insecure 2142 // Expect content to load but be marked as auth broken due to running insecure
2146 // content. 2143 // content.
2147 std::string page_with_unsafe_worker_path; 2144 std::string page_with_unsafe_worker_path;
2148 GetPageWithUnsafeWorkerPath(https_server_mismatched_, 2145 GetPageWithUnsafeWorkerPath(https_server_mismatched_,
2149 &page_with_unsafe_worker_path); 2146 &page_with_unsafe_worker_path);
2150 ui_test_utils::NavigateToURL( 2147 ui_test_utils::NavigateToURL(
2151 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); 2148 browser(), https_server_.GetURL(page_with_unsafe_worker_path));
2152 CheckWorkerLoadResult(tab, true); // Worker loads insecure content 2149 CheckWorkerLoadResult(tab, true); // Worker loads insecure content
2153 CheckAuthenticatedState(tab, CertError::NONE); 2150 CheckAuthenticationBrokenState(tab, CertError::NONE,
2151 AuthState::RAN_INSECURE_CONTENT);
2154 } 2152 }
2155 2153
2156 // Visits a page with unsafe content and makes sure that if a user exception to 2154 // Visits a page with unsafe content and makes sure that if a user exception to
2157 // the certificate error is present, the image is loaded and script executes. 2155 // the certificate error is present, the image is loaded and script executes.
2158 //
2159 // See the comment above SSLUITest.TestUnsafeContentsInWorkerWithUserException
2160 // for a discussion about the desired behavior.
2161 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { 2156 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) {
2162 ASSERT_TRUE(https_server_.Start()); 2157 ASSERT_TRUE(https_server_.Start());
2163 // Note that it is necessary to user https_server_mismatched_ here over the 2158 // Note that it is necessary to user https_server_mismatched_ here over the
2164 // other invalid cert servers. This is because the test relies on the two 2159 // other invalid cert servers. This is because the test relies on the two
2165 // servers having different hosts since SSL exceptions are per-host, not per 2160 // servers having different hosts since SSL exceptions are per-host, not per
2166 // origin, and https_server_mismatched_ uses 'localhost' rather than 2161 // origin, and https_server_mismatched_ uses 'localhost' rather than
2167 // '127.0.0.1'. 2162 // '127.0.0.1'.
2168 ASSERT_TRUE(https_server_mismatched_.Start()); 2163 ASSERT_TRUE(https_server_mismatched_.Start());
2169 2164
2170 // Navigate to an unsafe site. Proceed with interstitial page to indicate 2165 // Navigate to an unsafe site. Proceed with interstitial page to indicate
2171 // the user approves the bad certificate. 2166 // the user approves the bad certificate.
2172 ui_test_utils::NavigateToURL( 2167 ui_test_utils::NavigateToURL(
2173 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html")); 2168 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html"));
2174 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2169 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2175 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2170 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2176 AuthState::SHOWING_INTERSTITIAL); 2171 AuthState::SHOWING_INTERSTITIAL);
2177 ProceedThroughInterstitial(tab); 2172 ProceedThroughInterstitial(tab);
2178 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID, 2173 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2179 AuthState::NONE); 2174 AuthState::NONE);
2180 2175
2181 std::string replacement_path; 2176 std::string replacement_path;
2182 GetFilePathWithHostAndPortReplacement( 2177 GetFilePathWithHostAndPortReplacement(
2183 "/ssl/page_with_unsafe_contents.html", 2178 "/ssl/page_with_unsafe_contents.html",
2184 https_server_mismatched_.host_port_pair(), &replacement_path); 2179 https_server_mismatched_.host_port_pair(), &replacement_path);
2185 ui_test_utils::NavigateToURL(browser(), 2180 ui_test_utils::NavigateToURL(browser(),
2186 https_server_.GetURL(replacement_path)); 2181 https_server_.GetURL(replacement_path));
2187 2182
2188 // When the bad content is filtered, the state is expected to be 2183 CheckAuthenticationBrokenState(
2189 // authenticated. 2184 tab, CertError::NONE,
2190 CheckAuthenticatedState(tab, AuthState::NONE); 2185 AuthState::RAN_INSECURE_CONTENT | AuthState::DISPLAYED_INSECURE_CONTENT);
2191 2186
2192 int img_width; 2187 int img_width;
2193 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2188 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2194 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2189 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2195 // In order to check that the image was loaded, we check its width. 2190 // In order to check that the image was loaded, we check its width.
2196 // The actual image (Google logo) is 114 pixels wide, so we assume a good 2191 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2197 // image is greater than 100. 2192 // image is greater than 100.
2198 EXPECT_GT(img_width, 100); 2193 EXPECT_GT(img_width, 100);
2199 2194
2200 bool js_result = false; 2195 bool js_result = false;
2201 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 2196 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
2202 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); 2197 tab, "window.domAutomationController.send(IsFooSet());", &js_result));
2203 EXPECT_TRUE(js_result); 2198 EXPECT_TRUE(js_result);
2204 CheckAuthenticatedState(tab, CertError::NONE); 2199
2200 // Test that subresources with the same certificate errors as the main
2201 // resources don't cause mixed content UI downgrades. (Such errors
2202 // would be confusing and duplicative.)
jww 2015/11/20 01:25:08 Mention that this is testing *active* content?
estark 2015/11/23 23:40:24 Done.
2203 ui_test_utils::NavigateToURL(
2204 browser(), https_server_mismatched_.GetURL(replacement_path));
2205 js_result = false;
2206 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
2207 tab, "window.domAutomationController.send(IsFooSet());", &js_result));
2208 EXPECT_TRUE(js_result);
2209 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2210 AuthState::NONE);
2211 }
2212
2213 // Like the test above, but only displaying an image.
jww 2015/11/20 01:25:08 Mention that this is testing *inactive* content?
estark 2015/11/23 23:40:24 Done.
2214 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) {
2215 ASSERT_TRUE(https_server_.Start());
2216 // Note that it is necessary to user https_server_mismatched_ here over the
2217 // other invalid cert servers. This is because the test relies on the two
2218 // servers having different hosts since SSL exceptions are per-host, not per
2219 // origin, and https_server_mismatched_ uses 'localhost' rather than
2220 // '127.0.0.1'.
2221 ASSERT_TRUE(https_server_mismatched_.Start());
jww 2015/11/20 01:25:08 It seems like a lot of this is similar/identical b
estark 2015/11/23 23:40:24 Done.
2222
2223 // Navigate to an unsafe site. Proceed with interstitial page to indicate
2224 // the user approves the bad certificate.
2225 ui_test_utils::NavigateToURL(
2226 browser(), https_server_mismatched_.GetURL("/ssl/blank_page.html"));
2227 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2228 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2229 AuthState::SHOWING_INTERSTITIAL);
2230 ProceedThroughInterstitial(tab);
2231 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2232 AuthState::NONE);
2233
2234 std::string replacement_path;
2235 GetFilePathWithHostAndPortReplacement(
2236 "/ssl/page_with_unsafe_image.html",
2237 https_server_mismatched_.host_port_pair(), &replacement_path);
2238 ui_test_utils::NavigateToURL(browser(),
2239 https_server_.GetURL(replacement_path));
2240
2241 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT);
2242
2243 int img_width;
2244 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2245 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2246 // In order to check that the image was loaded, we check its width.
2247 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2248 // image is greater than 100.
2249 EXPECT_GT(img_width, 100);
2205 } 2250 }
2206 2251
2207 // Test that when the browser blocks displaying insecure content (images), the 2252 // Test that when the browser blocks displaying insecure content (images), the
2208 // indicator shows a secure page, because the blocking made the otherwise 2253 // indicator shows a secure page, because the blocking made the otherwise
2209 // unsafe page safe (the notification of this state is handled by other means). 2254 // unsafe page safe (the notification of this state is handled by other means).
2210 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureImage) { 2255 IN_PROC_BROWSER_TEST_F(SSLUITestBlock, TestBlockDisplayingInsecureImage) {
2211 ASSERT_TRUE(embedded_test_server()->Start()); 2256 ASSERT_TRUE(embedded_test_server()->Start());
2212 ASSERT_TRUE(https_server_.Start()); 2257 ASSERT_TRUE(https_server_.Start());
2213 2258
2214 std::string replacement_path; 2259 std::string replacement_path;
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 2921
2877 // Visit a page over https that contains a frame with a redirect. 2922 // Visit a page over https that contains a frame with a redirect.
2878 2923
2879 // XMLHttpRequest insecure content in synchronous mode. 2924 // XMLHttpRequest insecure content in synchronous mode.
2880 2925
2881 // XMLHttpRequest insecure content in asynchronous mode. 2926 // XMLHttpRequest insecure content in asynchronous mode.
2882 2927
2883 // XMLHttpRequest over bad ssl in synchronous mode. 2928 // XMLHttpRequest over bad ssl in synchronous mode.
2884 2929
2885 // XMLHttpRequest over OK ssl in synchronous mode. 2930 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/ssl/page_with_dynamic_unsafe_image.html » ('j') | content/browser/loader/resource_loader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698