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

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

Issue 2408393003: Manage insecure content flags in SSLManager, not WebContentsImpl (Closed)
Patch Set: fix test failure Created 4 years, 2 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 6568 matching lines...) Expand 10 before | Expand all | Expand 10 after
6579 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6579 https_server.ServeFilesFromSourceDirectory("content/test/data");
6580 ASSERT_TRUE(https_server.Start()); 6580 ASSERT_TRUE(https_server.Start());
6581 SetupCrossSiteRedirector(&https_server); 6581 SetupCrossSiteRedirector(&https_server);
6582 6582
6583 WebContentsImpl* web_contents = 6583 WebContentsImpl* web_contents =
6584 static_cast<WebContentsImpl*>(shell()->web_contents()); 6584 static_cast<WebContentsImpl*>(shell()->web_contents());
6585 6585
6586 GURL iframe_url( 6586 GURL iframe_url(
6587 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html")); 6587 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html"));
6588 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); 6588 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
6589 EXPECT_TRUE(web_contents->DisplayedInsecureContent()); 6589 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry();
6590 EXPECT_TRUE(!!(entry->GetSSL().content_status &
6591 SSLStatus::DISPLAYED_INSECURE_CONTENT));
6590 6592
6591 // When the subframe navigates, the WebContents should still be marked 6593 // When the subframe navigates, the WebContents should still be marked
6592 // as having displayed insecure content. 6594 // as having displayed insecure content.
6593 GURL navigate_url(https_server.GetURL("/title1.html")); 6595 GURL navigate_url(https_server.GetURL("/title1.html"));
6594 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 6596 FrameTreeNode* root = web_contents->GetFrameTree()->root();
6595 NavigateFrameToURL(root->child_at(0), navigate_url); 6597 NavigateFrameToURL(root->child_at(0), navigate_url);
6596 EXPECT_TRUE(web_contents->DisplayedInsecureContent()); 6598 entry = web_contents->GetController().GetVisibleEntry();
6599 EXPECT_TRUE(!!(entry->GetSSL().content_status &
6600 SSLStatus::DISPLAYED_INSECURE_CONTENT));
6597 6601
6598 // When the main frame navigates, it should no longer be marked as 6602 // When the main frame navigates, it should no longer be marked as
6599 // displaying insecure content. 6603 // displaying insecure content.
6600 EXPECT_TRUE( 6604 EXPECT_TRUE(
6601 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); 6605 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html")));
6602 EXPECT_FALSE(web_contents->DisplayedInsecureContent()); 6606 entry = web_contents->GetController().GetVisibleEntry();
6607 EXPECT_FALSE(!!(entry->GetSSL().content_status &
6608 SSLStatus::DISPLAYED_INSECURE_CONTENT));
6603 } 6609 }
6604 6610
6605 // Tests that, when a parent frame is set to strictly block mixed 6611 // Tests that, when a parent frame is set to strictly block mixed
6606 // content via Content Security Policy, child OOPIFs cannot display 6612 // content via Content Security Policy, child OOPIFs cannot display
6607 // mixed content. 6613 // mixed content.
6608 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 6614 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6609 PassiveMixedContentInIframeWithStrictBlocking) { 6615 PassiveMixedContentInIframeWithStrictBlocking) {
6610 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 6616 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6611 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6617 https_server.ServeFilesFromSourceDirectory("content/test/data");
6612 ASSERT_TRUE(https_server.Start()); 6618 ASSERT_TRUE(https_server.Start());
6613 SetupCrossSiteRedirector(&https_server); 6619 SetupCrossSiteRedirector(&https_server);
6614 6620
6615 WebContentsImpl* web_contents = 6621 WebContentsImpl* web_contents =
6616 static_cast<WebContentsImpl*>(shell()->web_contents()); 6622 static_cast<WebContentsImpl*>(shell()->web_contents());
6617 6623
6618 GURL iframe_url_with_strict_blocking(https_server.GetURL( 6624 GURL iframe_url_with_strict_blocking(https_server.GetURL(
6619 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html")); 6625 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html"));
6620 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); 6626 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking));
6621 EXPECT_FALSE(web_contents->DisplayedInsecureContent()); 6627 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry();
6628 EXPECT_FALSE(!!(entry->GetSSL().content_status &
6629 SSLStatus::DISPLAYED_INSECURE_CONTENT));
6622 6630
6623 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 6631 FrameTreeNode* root = web_contents->GetFrameTree()->root();
6624 EXPECT_EQ(blink::kBlockAllMixedContent, 6632 EXPECT_EQ(blink::kBlockAllMixedContent,
6625 root->current_replication_state().insecure_request_policy); 6633 root->current_replication_state().insecure_request_policy);
6626 EXPECT_EQ( 6634 EXPECT_EQ(
6627 blink::kBlockAllMixedContent, 6635 blink::kBlockAllMixedContent,
6628 root->child_at(0)->current_replication_state().insecure_request_policy); 6636 root->child_at(0)->current_replication_state().insecure_request_policy);
6629 6637
6630 // When the subframe navigates, it should still be marked as enforcing 6638 // When the subframe navigates, it should still be marked as enforcing
6631 // strict mixed content. 6639 // strict mixed content.
(...skipping 21 matching lines...) Expand all
6653 https_server.ServeFilesFromSourceDirectory("content/test/data"); 6661 https_server.ServeFilesFromSourceDirectory("content/test/data");
6654 ASSERT_TRUE(https_server.Start()); 6662 ASSERT_TRUE(https_server.Start());
6655 SetupCrossSiteRedirector(&https_server); 6663 SetupCrossSiteRedirector(&https_server);
6656 6664
6657 WebContentsImpl* web_contents = 6665 WebContentsImpl* web_contents =
6658 static_cast<WebContentsImpl*>(shell()->web_contents()); 6666 static_cast<WebContentsImpl*>(shell()->web_contents());
6659 6667
6660 GURL iframe_url_with_upgrade(https_server.GetURL( 6668 GURL iframe_url_with_upgrade(https_server.GetURL(
6661 "/mixed-content/basic-passive-in-iframe-with-upgrade.html")); 6669 "/mixed-content/basic-passive-in-iframe-with-upgrade.html"));
6662 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_upgrade)); 6670 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_upgrade));
6663 EXPECT_FALSE(web_contents->DisplayedInsecureContent()); 6671 NavigationEntry* entry = web_contents->GetController().GetVisibleEntry();
6672 EXPECT_FALSE(!!(entry->GetSSL().content_status &
6673 SSLStatus::DISPLAYED_INSECURE_CONTENT));
6664 6674
6665 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 6675 FrameTreeNode* root = web_contents->GetFrameTree()->root();
6666 EXPECT_EQ(blink::kUpgradeInsecureRequests, 6676 EXPECT_EQ(blink::kUpgradeInsecureRequests,
6667 root->current_replication_state().insecure_request_policy); 6677 root->current_replication_state().insecure_request_policy);
6668 EXPECT_EQ( 6678 EXPECT_EQ(
6669 blink::kUpgradeInsecureRequests, 6679 blink::kUpgradeInsecureRequests,
6670 root->child_at(0)->current_replication_state().insecure_request_policy); 6680 root->child_at(0)->current_replication_state().insecure_request_policy);
6671 6681
6672 // When the subframe navigates, it should still be marked as upgrading 6682 // When the subframe navigates, it should still be marked as upgrading
6673 // insecure requests. 6683 // insecure requests.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
6731 NavigationEntry* entry = 6741 NavigationEntry* entry =
6732 shell()->web_contents()->GetController().GetLastCommittedEntry(); 6742 shell()->web_contents()->GetController().GetLastCommittedEntry();
6733 ASSERT_TRUE(entry); 6743 ASSERT_TRUE(entry);
6734 6744
6735 // The main page was loaded with certificate errors. 6745 // The main page was loaded with certificate errors.
6736 EXPECT_TRUE(net::IsCertStatusError(entry->GetSSL().cert_status)); 6746 EXPECT_TRUE(net::IsCertStatusError(entry->GetSSL().cert_status));
6737 6747
6738 // The image that the iframe loaded had certificate errors also, so 6748 // The image that the iframe loaded had certificate errors also, so
6739 // the page should be marked as having displayed subresources with 6749 // the page should be marked as having displayed subresources with
6740 // cert errors. 6750 // cert errors.
6741 EXPECT_TRUE(entry->GetSSL().content_status & 6751 EXPECT_TRUE(!!(entry->GetSSL().content_status &
6742 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS); 6752 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS));
6743 } 6753 }
6744 6754
6745 // Test setting a cross-origin iframe to display: none. 6755 // Test setting a cross-origin iframe to display: none.
6746 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { 6756 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) {
6747 GURL main_url(embedded_test_server()->GetURL( 6757 GURL main_url(embedded_test_server()->GetURL(
6748 "a.com", "/cross_site_iframe_factory.html?a(b)")); 6758 "a.com", "/cross_site_iframe_factory.html?a(b)"));
6749 NavigateToURL(shell(), main_url); 6759 NavigateToURL(shell(), main_url);
6750 6760
6751 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 6761 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6752 RenderWidgetHost* root_render_widget_host = 6762 RenderWidgetHost* root_render_widget_host =
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
8333 // Now have the cross-process navigation commit and mark the current RFH as 8343 // Now have the cross-process navigation commit and mark the current RFH as
8334 // pending deletion. 8344 // pending deletion.
8335 cross_site_manager.WaitForNavigationFinished(); 8345 cross_site_manager.WaitForNavigationFinished();
8336 8346
8337 // Resume the navigation in the previous RFH that has just been marked as 8347 // Resume the navigation in the previous RFH that has just been marked as
8338 // pending deletion. We should not crash. 8348 // pending deletion. We should not crash.
8339 transfer_manager.WaitForNavigationFinished(); 8349 transfer_manager.WaitForNavigationFinished();
8340 } 8350 }
8341 8351
8342 } // namespace content 8352 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698