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

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

Issue 1550723003: Adapt MixedContentChecker for remote frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 10 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 SitePerProcessHighDPIBrowserTest() {} 595 SitePerProcessHighDPIBrowserTest() {}
596 596
597 protected: 597 protected:
598 void SetUpCommandLine(base::CommandLine* command_line) override { 598 void SetUpCommandLine(base::CommandLine* command_line) override {
599 SitePerProcessBrowserTest::SetUpCommandLine(command_line); 599 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
600 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, 600 command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor,
601 base::StringPrintf("2")); 601 base::StringPrintf("2"));
602 } 602 }
603 }; 603 };
604 604
605 // SitePerProcessIgnoreCertErrorsBrowserTest
606
607 class SitePerProcessIgnoreCertErrorsBrowserTest
608 : public SitePerProcessBrowserTest {
609 public:
610 SitePerProcessIgnoreCertErrorsBrowserTest() {}
611
612 protected:
613 void SetUpCommandLine(base::CommandLine* command_line) override {
614 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
615 command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
616 }
617 };
618
605 // Ensure that navigating subframes in --site-per-process mode works and the 619 // Ensure that navigating subframes in --site-per-process mode works and the
606 // correct documents are committed. 620 // correct documents are committed.
607 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { 621 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) {
608 GURL main_url(embedded_test_server()->GetURL( 622 GURL main_url(embedded_test_server()->GetURL(
609 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 623 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))"));
610 NavigateToURL(shell(), main_url); 624 NavigateToURL(shell(), main_url);
611 625
612 // It is safe to obtain the root frame tree node here, as it doesn't change. 626 // It is safe to obtain the root frame tree node here, as it doesn't change.
613 FrameTreeNode* root = 627 FrameTreeNode* root =
614 static_cast<WebContentsImpl*>(shell()->web_contents())-> 628 static_cast<WebContentsImpl*>(shell()->web_contents())->
(...skipping 4362 matching lines...) Expand 10 before | Expand all | Expand 10 after
4977 4991
4978 // The popup's origin should match |b_url|, since it's not sandboxed. 4992 // The popup's origin should match |b_url|, since it's not sandboxed.
4979 std::string popup_origin; 4993 std::string popup_origin;
4980 EXPECT_TRUE(ExecuteScriptAndExtractString( 4994 EXPECT_TRUE(ExecuteScriptAndExtractString(
4981 foo_root->current_frame_host(), 4995 foo_root->current_frame_host(),
4982 "domAutomationController.send(document.origin)", 4996 "domAutomationController.send(document.origin)",
4983 &popup_origin)); 4997 &popup_origin));
4984 EXPECT_EQ(b_url.GetOrigin().spec(), popup_origin + "/"); 4998 EXPECT_EQ(b_url.GetOrigin().spec(), popup_origin + "/");
4985 } 4999 }
4986 5000
5001 // Tests that the WebContents is notified when passive mixed content is
5002 // displayed in an OOPIF. The test ignores cert errors so that an HTTPS
5003 // iframe can be loaded from a site other than localhost (the
5004 // EmbeddedTestServer serves a certificate that is valid for localhost).
5005 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
5006 PassiveMixedContentInIframe) {
5007 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
5008 https_server.ServeFilesFromSourceDirectory("content/test/data");
5009 ASSERT_TRUE(https_server.Start());
5010 SetupCrossSiteRedirector(&https_server);
5011
5012 GURL iframe_url(
5013 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html"));
5014 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
5015 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent());
5016
5017 // When the subframe navigates, the WebContents should still be marked
5018 // as having displayed insecure content.
5019 GURL navigate_url(https_server.GetURL("/title1.html"));
5020 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
5021 ->GetFrameTree()
5022 ->root();
5023 NavigateFrameToURL(root->child_at(0), navigate_url);
5024 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent());
5025
5026 // When the main frame navigates, it should no longer be marked as
5027 // displaying insecure content.
5028 EXPECT_TRUE(
5029 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html")));
5030 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent());
5031 }
5032
5033 // Tests that, when a parent frame is set to strictly block mixed
5034 // content via Content Security Policy, child OOPIFs cannot display
5035 // mixed content.
5036 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
5037 PassiveMixedContentInIframeWithStrictBlocking) {
5038 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
5039 https_server.ServeFilesFromSourceDirectory("content/test/data");
5040 ASSERT_TRUE(https_server.Start());
5041 SetupCrossSiteRedirector(&https_server);
5042
5043 GURL iframe_url_with_strict_blocking(https_server.GetURL(
5044 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html"));
5045 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking));
5046 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent());
5047
5048 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
5049 ->GetFrameTree()
5050 ->root();
5051 EXPECT_TRUE(root->current_replication_state()
5052 .should_enforce_strict_mixed_content_checking);
5053 EXPECT_TRUE(root->child_at(0)
5054 ->current_replication_state()
5055 .should_enforce_strict_mixed_content_checking);
5056
5057 // When the subframe navigates, it should still be marked as enforcing
5058 // strict mixed content.
5059 GURL navigate_url(https_server.GetURL("/title1.html"));
5060 NavigateFrameToURL(root->child_at(0), navigate_url);
5061 EXPECT_TRUE(root->current_replication_state()
5062 .should_enforce_strict_mixed_content_checking);
5063 EXPECT_TRUE(root->child_at(0)
5064 ->current_replication_state()
5065 .should_enforce_strict_mixed_content_checking);
5066
5067 // When the main frame navigates, it should no longer be marked as
5068 // enforcing strict mixed content.
5069 EXPECT_TRUE(
5070 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html")));
5071 EXPECT_FALSE(root->current_replication_state()
5072 .should_enforce_strict_mixed_content_checking);
5073 }
5074
5075 // Tests that active mixed content is blocked in an OOPIF. The test
5076 // ignores cert errors so that an HTTPS iframe can be loaded from a site
5077 // other than localhost (the EmbeddedTestServer serves a certificate
5078 // that is valid for localhost).
5079 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
5080 ActiveMixedContentInIframe) {
5081 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
5082 https_server.ServeFilesFromSourceDirectory("content/test/data");
5083 ASSERT_TRUE(https_server.Start());
5084 SetupCrossSiteRedirector(&https_server);
5085
5086 GURL iframe_url(
5087 https_server.GetURL("/mixed-content/basic-active-in-iframe.html"));
5088 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
5089 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
5090 ->GetFrameTree()
5091 ->root();
5092 ASSERT_EQ(1U, root->child_count());
5093 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0);
5094 ASSERT_TRUE(mixed_child);
5095 // The child iframe attempted to create a mixed iframe; this should
5096 // have been blocked, so the mixed iframe should not have committed a
5097 // load.
5098 EXPECT_FALSE(mixed_child->has_committed_real_load());
5099 }
5100
4987 } // namespace content 5101 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/data/ssl/page_runs_insecure_content_in_iframe_with_strict_blocking.html ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698