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

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

Issue 2226523002: Add separate plumbing for subresources with certificate errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 4 years, 4 months 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 <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 2272 matching lines...) Expand 10 before | Expand all | Expand 10 after
2283 2283
2284 // Navigate to safe page that has Worker loading unsafe content. 2284 // Navigate to safe page that has Worker loading unsafe content.
2285 // Expect content to load but be marked as auth broken due to running insecure 2285 // Expect content to load but be marked as auth broken due to running insecure
2286 // content. 2286 // content.
2287 std::string page_with_unsafe_worker_path; 2287 std::string page_with_unsafe_worker_path;
2288 GetPageWithUnsafeWorkerPath(https_server_mismatched_, 2288 GetPageWithUnsafeWorkerPath(https_server_mismatched_,
2289 &page_with_unsafe_worker_path); 2289 &page_with_unsafe_worker_path);
2290 ui_test_utils::NavigateToURL( 2290 ui_test_utils::NavigateToURL(
2291 browser(), https_server_.GetURL(page_with_unsafe_worker_path)); 2291 browser(), https_server_.GetURL(page_with_unsafe_worker_path));
2292 CheckWorkerLoadResult(tab, true); // Worker loads insecure content 2292 CheckWorkerLoadResult(tab, true); // Worker loads insecure content
2293 CheckAuthenticationBrokenState(tab, CertError::NONE, 2293 CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE);
2294 AuthState::RAN_INSECURE_CONTENT); 2294
2295 ChromeSecurityStateModelClient* model_client =
2296 ChromeSecurityStateModelClient::FromWebContents(tab);
2297 ASSERT_TRUE(model_client);
2298
2299 EXPECT_EQ(security_state::SecurityStateModel::SECURITY_ERROR,
2300 model_client->GetSecurityInfo().security_level);
2301 EXPECT_EQ(
2302 security_state::SecurityStateModel::RAN_CONTENT_WITH_CERTIFICATE_ERRORS,
2303 model_client->GetSecurityInfo().content_with_cert_errors_status);
2295 } 2304 }
2296 2305
2297 // Visits a page with unsafe content and makes sure that if a user exception to 2306 // Visits a page with unsafe content and makes sure that if a user exception to
2298 // the certificate error is present, the image is loaded and script executes. 2307 // the certificate error is present, the image is loaded and script executes.
2299 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) { 2308 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) {
2300 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2309 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2301 ASSERT_NO_FATAL_FAILURE(SetUpUnsafeContentsWithUserException( 2310 ASSERT_NO_FATAL_FAILURE(SetUpUnsafeContentsWithUserException(
2302 "/ssl/page_with_unsafe_contents.html")); 2311 "/ssl/page_with_unsafe_contents.html"));
2303 CheckAuthenticationBrokenState( 2312 CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE);
2304 tab, CertError::NONE, 2313
2305 AuthState::RAN_INSECURE_CONTENT | AuthState::DISPLAYED_INSECURE_CONTENT); 2314 ChromeSecurityStateModelClient* model_client =
2315 ChromeSecurityStateModelClient::FromWebContents(tab);
2316 ASSERT_TRUE(model_client);
2317
2318 EXPECT_EQ(security_state::SecurityStateModel::SECURITY_ERROR,
2319 model_client->GetSecurityInfo().security_level);
2320 EXPECT_EQ(security_state::SecurityStateModel::
2321 RAN_AND_DISPLAYED_CONTENT_WITH_CERTIFICATE_ERRORS,
2322 model_client->GetSecurityInfo().content_with_cert_errors_status);
2306 2323
2307 int img_width; 2324 int img_width;
2308 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2325 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2309 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2326 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2310 // In order to check that the image was loaded, we check its width. 2327 // In order to check that the image was loaded, we check its width.
2311 // The actual image (Google logo) is 114 pixels wide, so we assume a good 2328 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2312 // image is greater than 100. 2329 // image is greater than 100.
2313 EXPECT_GT(img_width, 100); 2330 EXPECT_GT(img_width, 100);
2314 2331
2315 bool js_result = false; 2332 bool js_result = false;
2316 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 2333 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
2317 tab, "window.domAutomationController.send(IsFooSet());", &js_result)); 2334 tab, "window.domAutomationController.send(IsFooSet());", &js_result));
2318 EXPECT_TRUE(js_result); 2335 EXPECT_TRUE(js_result);
2319
2320 // Test that active subresources with the same certificate errors as
2321 // the main resources don't cause mixed content UI downgrades. (Such
2322 // errors would be confusing and duplicative.)
2323 std::string replacement_path;
2324 GetFilePathWithHostAndPortReplacement(
2325 "/ssl/page_with_unsafe_contents.html",
2326 https_server_mismatched_.host_port_pair(), &replacement_path);
2327 ui_test_utils::NavigateToURL(
2328 browser(), https_server_mismatched_.GetURL(replacement_path));
2329 js_result = false;
2330 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
2331 tab, "window.domAutomationController.send(IsFooSet());", &js_result));
2332 EXPECT_TRUE(js_result);
2333 CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
2334 AuthState::NONE);
2335 } 2336 }
2336 2337
2337 // Like the test above, but only displaying inactive content (an image). 2338 // Like the test above, but only displaying inactive content (an image).
2338 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) { 2339 IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) {
2339 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 2340 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
2340 ASSERT_NO_FATAL_FAILURE( 2341 ASSERT_NO_FATAL_FAILURE(
2341 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html")); 2342 SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html"));
2342 CheckAuthenticatedState(tab, AuthState::DISPLAYED_INSECURE_CONTENT); 2343 CheckAuthenticatedState(tab, AuthState::NONE);
2344
2345 ChromeSecurityStateModelClient* model_client =
2346 ChromeSecurityStateModelClient::FromWebContents(tab);
2347 ASSERT_TRUE(model_client);
2348
2349 EXPECT_EQ(security_state::SecurityStateModel::NONE,
2350 model_client->GetSecurityInfo().security_level);
2351 EXPECT_EQ(security_state::SecurityStateModel::
2352 DISPLAYED_CONTENT_WITH_CERTIFICATE_ERRORS,
2353 model_client->GetSecurityInfo().content_with_cert_errors_status);
2343 2354
2344 int img_width; 2355 int img_width;
2345 EXPECT_TRUE(content::ExecuteScriptAndExtractInt( 2356 EXPECT_TRUE(content::ExecuteScriptAndExtractInt(
2346 tab, "window.domAutomationController.send(ImageWidth());", &img_width)); 2357 tab, "window.domAutomationController.send(ImageWidth());", &img_width));
2347 // In order to check that the image was loaded, we check its width. 2358 // In order to check that the image was loaded, we check its width.
2348 // The actual image (Google logo) is 114 pixels wide, so we assume a good 2359 // The actual image (Google logo) is 114 pixels wide, so we assume a good
2349 // image is greater than 100. 2360 // image is greater than 100.
2350 EXPECT_GT(img_width, 100); 2361 EXPECT_GT(img_width, 100);
2351 } 2362 }
2352 2363
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 3016
3006 // Visit a page over https that contains a frame with a redirect. 3017 // Visit a page over https that contains a frame with a redirect.
3007 3018
3008 // XMLHttpRequest insecure content in synchronous mode. 3019 // XMLHttpRequest insecure content in synchronous mode.
3009 3020
3010 // XMLHttpRequest insecure content in asynchronous mode. 3021 // XMLHttpRequest insecure content in asynchronous mode.
3011 3022
3012 // XMLHttpRequest over bad ssl in synchronous mode. 3023 // XMLHttpRequest over bad ssl in synchronous mode.
3013 3024
3014 // XMLHttpRequest over OK ssl in synchronous mode. 3025 // XMLHttpRequest over OK ssl in synchronous mode.
OLDNEW
« no previous file with comments | « chrome/browser/ssl/chrome_ssl_host_state_delegate.cc ('k') | components/security_state/security_state_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698