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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2226363002: Track subresources with cert errors separately from mixed content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments 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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 15 matching lines...) Expand all
26 #include "content/browser/frame_host/interstitial_page_impl.h" 26 #include "content/browser/frame_host/interstitial_page_impl.h"
27 #include "content/browser/frame_host/navigator.h" 27 #include "content/browser/frame_host/navigator.h"
28 #include "content/browser/frame_host/render_frame_proxy_host.h" 28 #include "content/browser/frame_host/render_frame_proxy_host.h"
29 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 29 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
30 #include "content/browser/gpu/compositor_util.h" 30 #include "content/browser/gpu/compositor_util.h"
31 #include "content/browser/loader/resource_dispatcher_host_impl.h" 31 #include "content/browser/loader/resource_dispatcher_host_impl.h"
32 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" 32 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
33 #include "content/browser/renderer_host/render_view_host_impl.h" 33 #include "content/browser/renderer_host/render_view_host_impl.h"
34 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 34 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
35 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 35 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
36 #include "content/browser/web_contents/web_contents_impl.h"
36 #include "content/common/child_process_messages.h" 37 #include "content/common/child_process_messages.h"
37 #include "content/common/frame_messages.h" 38 #include "content/common/frame_messages.h"
38 #include "content/common/input/synthetic_tap_gesture_params.h" 39 #include "content/common/input/synthetic_tap_gesture_params.h"
39 #include "content/common/input_messages.h" 40 #include "content/common/input_messages.h"
40 #include "content/common/view_messages.h" 41 #include "content/common/view_messages.h"
41 #include "content/public/browser/cert_store.h" 42 #include "content/public/browser/cert_store.h"
42 #include "content/public/browser/interstitial_page_delegate.h" 43 #include "content/public/browser/interstitial_page_delegate.h"
43 #include "content/public/browser/notification_observer.h" 44 #include "content/public/browser/notification_observer.h"
44 #include "content/public/browser/notification_service.h" 45 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/notification_types.h" 46 #include "content/public/browser/notification_types.h"
(...skipping 6235 matching lines...) Expand 10 before | Expand all | Expand 10 after
6281 #else 6282 #else
6282 #define MAYBE_PassiveMixedContentInIframe PassiveMixedContentInIframe 6283 #define MAYBE_PassiveMixedContentInIframe PassiveMixedContentInIframe
6283 #endif 6284 #endif
6284 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 6285 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6285 MAYBE_PassiveMixedContentInIframe) { 6286 MAYBE_PassiveMixedContentInIframe) {
6286 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 6287 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6287 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6288 https_server.ServeFilesFromSourceDirectory("content/test/data");
6288 ASSERT_TRUE(https_server.Start()); 6289 ASSERT_TRUE(https_server.Start());
6289 SetupCrossSiteRedirector(&https_server); 6290 SetupCrossSiteRedirector(&https_server);
6290 6291
6292 WebContentsImpl* web_contents =
6293 static_cast<WebContentsImpl*>(shell()->web_contents());
6294
6291 GURL iframe_url( 6295 GURL iframe_url(
6292 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html")); 6296 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html"));
6293 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); 6297 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
6294 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); 6298 EXPECT_TRUE(web_contents->DisplayedInsecureContent());
6295 6299
6296 // When the subframe navigates, the WebContents should still be marked 6300 // When the subframe navigates, the WebContents should still be marked
6297 // as having displayed insecure content. 6301 // as having displayed insecure content.
6298 GURL navigate_url(https_server.GetURL("/title1.html")); 6302 GURL navigate_url(https_server.GetURL("/title1.html"));
6299 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6303 FrameTreeNode* root = web_contents->GetFrameTree()->root();
6300 NavigateFrameToURL(root->child_at(0), navigate_url); 6304 NavigateFrameToURL(root->child_at(0), navigate_url);
6301 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); 6305 EXPECT_TRUE(web_contents->DisplayedInsecureContent());
6302 6306
6303 // When the main frame navigates, it should no longer be marked as 6307 // When the main frame navigates, it should no longer be marked as
6304 // displaying insecure content. 6308 // displaying insecure content.
6305 EXPECT_TRUE( 6309 EXPECT_TRUE(
6306 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); 6310 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html")));
6307 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 6311 EXPECT_FALSE(web_contents->DisplayedInsecureContent());
6308 } 6312 }
6309 6313
6310 // Tests that, when a parent frame is set to strictly block mixed 6314 // Tests that, when a parent frame is set to strictly block mixed
6311 // content via Content Security Policy, child OOPIFs cannot display 6315 // content via Content Security Policy, child OOPIFs cannot display
6312 // mixed content. 6316 // mixed content.
6313 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 6317 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6314 PassiveMixedContentInIframeWithStrictBlocking) { 6318 PassiveMixedContentInIframeWithStrictBlocking) {
6315 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 6319 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6316 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6320 https_server.ServeFilesFromSourceDirectory("content/test/data");
6317 ASSERT_TRUE(https_server.Start()); 6321 ASSERT_TRUE(https_server.Start());
6318 SetupCrossSiteRedirector(&https_server); 6322 SetupCrossSiteRedirector(&https_server);
6319 6323
6324 WebContentsImpl* web_contents =
6325 static_cast<WebContentsImpl*>(shell()->web_contents());
6326
6320 GURL iframe_url_with_strict_blocking(https_server.GetURL( 6327 GURL iframe_url_with_strict_blocking(https_server.GetURL(
6321 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html")); 6328 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html"));
6322 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); 6329 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking));
6323 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 6330 EXPECT_FALSE(web_contents->DisplayedInsecureContent());
6324 6331
6325 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6332 FrameTreeNode* root = web_contents->GetFrameTree()->root();
6326 EXPECT_EQ(blink::kBlockAllMixedContent, 6333 EXPECT_EQ(blink::kBlockAllMixedContent,
6327 root->current_replication_state().insecure_request_policy); 6334 root->current_replication_state().insecure_request_policy);
6328 EXPECT_EQ( 6335 EXPECT_EQ(
6329 blink::kBlockAllMixedContent, 6336 blink::kBlockAllMixedContent,
6330 root->child_at(0)->current_replication_state().insecure_request_policy); 6337 root->child_at(0)->current_replication_state().insecure_request_policy);
6331 6338
6332 // When the subframe navigates, it should still be marked as enforcing 6339 // When the subframe navigates, it should still be marked as enforcing
6333 // strict mixed content. 6340 // strict mixed content.
6334 GURL navigate_url(https_server.GetURL("/title1.html")); 6341 GURL navigate_url(https_server.GetURL("/title1.html"));
6335 NavigateFrameToURL(root->child_at(0), navigate_url); 6342 NavigateFrameToURL(root->child_at(0), navigate_url);
(...skipping 13 matching lines...) Expand all
6349 6356
6350 // Tests that, when a parent frame is set to upgrade insecure requests 6357 // Tests that, when a parent frame is set to upgrade insecure requests
6351 // via Content Security Policy, child OOPIFs will upgrade as well. 6358 // via Content Security Policy, child OOPIFs will upgrade as well.
6352 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 6359 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6353 PassiveMixedContentInIframeWithUpgrade) { 6360 PassiveMixedContentInIframeWithUpgrade) {
6354 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 6361 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6355 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6362 https_server.ServeFilesFromSourceDirectory("content/test/data");
6356 ASSERT_TRUE(https_server.Start()); 6363 ASSERT_TRUE(https_server.Start());
6357 SetupCrossSiteRedirector(&https_server); 6364 SetupCrossSiteRedirector(&https_server);
6358 6365
6366 WebContentsImpl* web_contents =
6367 static_cast<WebContentsImpl*>(shell()->web_contents());
6368
6359 GURL iframe_url_with_upgrade(https_server.GetURL( 6369 GURL iframe_url_with_upgrade(https_server.GetURL(
6360 "/mixed-content/basic-passive-in-iframe-with-upgrade.html")); 6370 "/mixed-content/basic-passive-in-iframe-with-upgrade.html"));
6361 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_upgrade)); 6371 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_upgrade));
6362 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 6372 EXPECT_FALSE(web_contents->DisplayedInsecureContent());
6363 6373
6364 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6374 FrameTreeNode* root = web_contents->GetFrameTree()->root();
6365 EXPECT_EQ(blink::kUpgradeInsecureRequests, 6375 EXPECT_EQ(blink::kUpgradeInsecureRequests,
6366 root->current_replication_state().insecure_request_policy); 6376 root->current_replication_state().insecure_request_policy);
6367 EXPECT_EQ( 6377 EXPECT_EQ(
6368 blink::kUpgradeInsecureRequests, 6378 blink::kUpgradeInsecureRequests,
6369 root->child_at(0)->current_replication_state().insecure_request_policy); 6379 root->child_at(0)->current_replication_state().insecure_request_policy);
6370 6380
6371 // When the subframe navigates, it should still be marked as upgrading 6381 // When the subframe navigates, it should still be marked as upgrading
6372 // insecure requests. 6382 // insecure requests.
6373 GURL navigate_url(https_server.GetURL("/title1.html")); 6383 GURL navigate_url(https_server.GetURL("/title1.html"));
6374 NavigateFrameToURL(root->child_at(0), navigate_url); 6384 NavigateFrameToURL(root->child_at(0), navigate_url);
(...skipping 28 matching lines...) Expand all
6403 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6413 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6404 ASSERT_EQ(1U, root->child_count()); 6414 ASSERT_EQ(1U, root->child_count());
6405 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); 6415 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0);
6406 ASSERT_TRUE(mixed_child); 6416 ASSERT_TRUE(mixed_child);
6407 // The child iframe attempted to create a mixed iframe; this should 6417 // The child iframe attempted to create a mixed iframe; this should
6408 // have been blocked, so the mixed iframe should not have committed a 6418 // have been blocked, so the mixed iframe should not have committed a
6409 // load. 6419 // load.
6410 EXPECT_FALSE(mixed_child->has_committed_real_load()); 6420 EXPECT_FALSE(mixed_child->has_committed_real_load());
6411 } 6421 }
6412 6422
6413 // Test that subresources with certificate errors that are NOT redundant 6423 // Test that subresources with certificate errors get reported to the
6414 // with the main page DO get reported to the browser. That is, if 6424 // browser. That is, if https://example.test frames https://a.com which
6415 // https://nonredundant.test frames https://a.com which loads an image 6425 // loads an image with certificate errors, the browser should be
6416 // with certificate errors, the browser should be notified about the 6426 // notified about the subresource with certificate errors and downgrade
6417 // subresource with certificate errors and downgrade the UI 6427 // the UI appropriately.
6418 // appropriately.
6419 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 6428 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6420 SubresourceWithNonRedundantCertificateErrors) { 6429 SubresourceWithCertificateErrors) {
6421 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 6430 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6422 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6431 https_server.ServeFilesFromSourceDirectory("content/test/data");
6423 ASSERT_TRUE(https_server.Start()); 6432 ASSERT_TRUE(https_server.Start());
6424 SetupCrossSiteRedirector(&https_server); 6433 SetupCrossSiteRedirector(&https_server);
6425 6434
6426 GURL url(https_server.GetURL( 6435 GURL url(https_server.GetURL(
6427 "nonredundant.test", 6436 "example.test",
6428 "/mixed-content/non-redundant-cert-error-in-iframe.html")); 6437 "/mixed-content/non-redundant-cert-error-in-iframe.html"));
6429 EXPECT_TRUE(NavigateToURL(shell(), url)); 6438 EXPECT_TRUE(NavigateToURL(shell(), url));
6430 6439
6431 NavigationEntry* entry = 6440 NavigationEntry* entry =
6432 shell()->web_contents()->GetController().GetLastCommittedEntry(); 6441 shell()->web_contents()->GetController().GetLastCommittedEntry();
6433 ASSERT_TRUE(entry); 6442 ASSERT_TRUE(entry);
6434 6443
6435 // The main page was loaded with certificate errors. 6444 // The main page was loaded with certificate errors.
6436 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN, 6445 EXPECT_EQ(SECURITY_STYLE_AUTHENTICATION_BROKEN,
6437 entry->GetSSL().security_style); 6446 entry->GetSSL().security_style);
6438 6447
6439 // The image that the iframe loaded had certificate errors also, and 6448 // The image that the iframe loaded had certificate errors also, so
6440 // they were different than the certificate errors of the main 6449 // the page should be marked as having displayed subresources with
6441 // resource, so the page should be marked as having displayed insecure 6450 // cert errors.
6442 // content.
6443 EXPECT_TRUE(entry->GetSSL().content_status & 6451 EXPECT_TRUE(entry->GetSSL().content_status &
6444 SSLStatus::DISPLAYED_INSECURE_CONTENT); 6452 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS);
6445 } 6453 }
6446 6454
6447 // Test setting a cross-origin iframe to display: none. 6455 // Test setting a cross-origin iframe to display: none.
6448 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { 6456 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) {
6449 GURL main_url(embedded_test_server()->GetURL( 6457 GURL main_url(embedded_test_server()->GetURL(
6450 "a.com", "/cross_site_iframe_factory.html?a(b)")); 6458 "a.com", "/cross_site_iframe_factory.html?a(b)"));
6451 NavigateToURL(shell(), main_url); 6459 NavigateToURL(shell(), main_url);
6452 6460
6453 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6461 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6454 RenderWidgetHost* root_render_widget_host = 6462 RenderWidgetHost* root_render_widget_host =
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
7840 // Send a postMessage from the child to its parent. This verifies that the 7848 // Send a postMessage from the child to its parent. This verifies that the
7841 // parent's proxy in the child's SiteInstance was also restored. 7849 // parent's proxy in the child's SiteInstance was also restored.
7842 base::string16 expected_title(base::UTF8ToUTF16("I am alive!")); 7850 base::string16 expected_title(base::UTF8ToUTF16("I am alive!"));
7843 TitleWatcher title_watcher(shell()->web_contents(), expected_title); 7851 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
7844 EXPECT_TRUE(ExecuteScript(child->current_frame_host(), 7852 EXPECT_TRUE(ExecuteScript(child->current_frame_host(),
7845 "parent.postMessage('I am alive!', '*');")); 7853 "parent.postMessage('I am alive!', '*');"));
7846 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 7854 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
7847 } 7855 }
7848 7856
7849 } // namespace content 7857 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_browsertest.cc ('k') | content/browser/ssl/ssl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698