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

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

Issue 2378643002: Propagating csp attribute changes on frameOwnerPropertiesChanged() (Closed)
Patch Set: rebasing on master 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
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 public: 586 public:
587 SitePerProcessIgnoreCertErrorsBrowserTest() {} 587 SitePerProcessIgnoreCertErrorsBrowserTest() {}
588 588
589 protected: 589 protected:
590 void SetUpCommandLine(base::CommandLine* command_line) override { 590 void SetUpCommandLine(base::CommandLine* command_line) override {
591 SitePerProcessBrowserTest::SetUpCommandLine(command_line); 591 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
592 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); 592 command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
593 } 593 }
594 }; 594 };
595 595
596 // SitePerProcessEmbedderCSPEnforcementBrowserTest
597
598 class SitePerProcessEmbedderCSPEnforcementBrowserTest
599 : public SitePerProcessBrowserTest {
600 public:
601 SitePerProcessEmbedderCSPEnforcementBrowserTest() {}
602
603 protected:
604 void SetUpCommandLine(base::CommandLine* command_line) override {
605 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
606 // TODO(amalika): Remove this switch when the EmbedderCSPEnforcement becomes
607 // stable
608 command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
609 "EmbedderCSPEnforcement");
610 }
611 };
612
596 double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) { 613 double GetFrameDeviceScaleFactor(const ToRenderFrameHost& adapter) {
597 double device_scale_factor; 614 double device_scale_factor;
598 const char kGetFrameDeviceScaleFactor[] = 615 const char kGetFrameDeviceScaleFactor[] =
599 "window.domAutomationController.send(window.devicePixelRatio);"; 616 "window.domAutomationController.send(window.devicePixelRatio);";
600 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor, 617 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor,
601 &device_scale_factor)); 618 &device_scale_factor));
602 return device_scale_factor; 619 return device_scale_factor;
603 } 620 }
604 621
605 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest, 622 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
(...skipping 2504 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 "window.domAutomationController.send(" 3127 "window.domAutomationController.send("
3111 "document.body.getAttribute('marginheight'));", 3128 "document.body.getAttribute('marginheight'));",
3112 &actual_margin_height)); 3129 &actual_margin_height));
3113 EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height); 3130 EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height);
3114 3131
3115 current_margin_width += 5; 3132 current_margin_width += 5;
3116 current_margin_height += 10; 3133 current_margin_height += 10;
3117 } 3134 }
3118 } 3135 }
3119 3136
3137 // Verify that "csp" property on frame elements propagates to child frames
3138 // correctly. See https://crbug.com/647588
3139 IN_PROC_BROWSER_TEST_F(SitePerProcessEmbedderCSPEnforcementBrowserTest,
3140 FrameOwnerPropertiesPropagationCSP) {
3141 GURL main_url(embedded_test_server()->GetURL(
3142 "a.com", "/frame_owner_properties_csp.html"));
3143 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3144
3145 // It is safe to obtain the root frame tree node here, as it doesn't change.
3146 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
3147 ASSERT_EQ(1u, root->child_count());
3148
3149 EXPECT_EQ(
3150 " Site A ------------ proxies for B\n"
3151 " +--Site B ------- proxies for A\n"
3152 "Where A = http://a.com/\n"
3153 " B = http://b.com/",
3154 DepictFrameTree(root));
3155
3156 FrameTreeNode* child = root->child_at(0);
3157
3158 std::string csp;
3159 EXPECT_TRUE(ExecuteScriptAndExtractString(
3160 root,
3161 "window.domAutomationController.send("
3162 "document.getElementById('child-1').getAttribute('csp'));",
3163 &csp));
3164 EXPECT_EQ("object-src \'none\'", csp);
3165
3166 // Run the test over variety of parent/child cases.
3167 GURL urls[] = {// Remote to remote.
3168 embedded_test_server()->GetURL("c.com", "/title2.html"),
3169 // Remote to local.
3170 embedded_test_server()->GetURL("a.com", "/title1.html"),
3171 // Local to remote.
3172 embedded_test_server()->GetURL("b.com", "/title2.html")};
3173
3174 std::vector<std::string> csp_values = {"default-src a.com",
3175 "default-src b.com", "img-src c.com"};
3176
3177 // Before each navigation, we change the csp property of the frame.
3178 // We then check whether that property is applied
3179 // correctly after the navigation has completed.
3180 for (size_t i = 0; i < arraysize(urls); ++i) {
3181 // Change csp before navigating.
3182 EXPECT_TRUE(ExecuteScript(
3183 root,
3184 base::StringPrintf("document.getElementById('child-1').setAttribute("
3185 " 'csp', '%s');",
3186 csp_values[i].c_str())));
3187
3188 NavigateFrameToURL(child, urls[i]);
3189 EXPECT_EQ(csp_values[i], child->frame_owner_properties().required_csp);
3190 // TODO(amalika): add checks that the CSP replication takes effect
3191 }
3192 }
3193
3120 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. 3194 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy.
3121 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { 3195 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
3122 GURL main_url(embedded_test_server()->GetURL( 3196 GURL main_url(embedded_test_server()->GetURL(
3123 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); 3197 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)"));
3124 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3198 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3125 3199
3126 // It is safe to obtain the root frame tree node here, as it doesn't change. 3200 // It is safe to obtain the root frame tree node here, as it doesn't change.
3127 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 3201 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
3128 3202
3129 EXPECT_EQ( 3203 EXPECT_EQ(
(...skipping 5136 matching lines...) Expand 10 before | Expand all | Expand 10 after
8266 // Now have the cross-process navigation commit and mark the current RFH as 8340 // Now have the cross-process navigation commit and mark the current RFH as
8267 // pending deletion. 8341 // pending deletion.
8268 cross_site_manager.WaitForNavigationFinished(); 8342 cross_site_manager.WaitForNavigationFinished();
8269 8343
8270 // Resume the navigation in the previous RFH that has just been marked as 8344 // Resume the navigation in the previous RFH that has just been marked as
8271 // pending deletion. We should not crash. 8345 // pending deletion. We should not crash.
8272 transfer_manager.WaitForNavigationFinished(); 8346 transfer_manager.WaitForNavigationFinished();
8273 } 8347 }
8274 8348
8275 } // namespace content 8349 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698