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

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

Issue 2378643002: Propagating csp attribute changes on frameOwnerPropertiesChanged() (Closed)
Patch Set: Changing the test class to move the switch 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') | content/common/frame_owner_properties.h » ('J')
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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 const double kDeviceScaleFactor = 2.0; 567 const double kDeviceScaleFactor = 2.0;
568 568
569 SitePerProcessHighDPIBrowserTest() {} 569 SitePerProcessHighDPIBrowserTest() {}
570 570
571 protected: 571 protected:
572 void SetUpCommandLine(base::CommandLine* command_line) override { 572 void SetUpCommandLine(base::CommandLine* command_line) override {
573 SitePerProcessBrowserTest::SetUpCommandLine(command_line); 573 SitePerProcessBrowserTest::SetUpCommandLine(command_line);
574 command_line->AppendSwitchASCII( 574 command_line->AppendSwitchASCII(
575 switches::kForceDeviceScaleFactor, 575 switches::kForceDeviceScaleFactor,
576 base::StringPrintf("%f", kDeviceScaleFactor)); 576 base::StringPrintf("%f", kDeviceScaleFactor));
577 // TODO(amalika): Remove this switch when
578 // the EmbedderCSPEnforcement becomes stable
alexmos 2016/09/30 06:20:42 nit: wrap comments at 80 chars (this is fewer than
579 command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
alexmos 2016/09/30 06:20:42 Instead of doing this here, let's define a new cla
580 "EmbedderCSPEnforcement");
577 } 581 }
578 }; 582 };
579 583
580 // SitePerProcessIgnoreCertErrorsBrowserTest 584 // SitePerProcessIgnoreCertErrorsBrowserTest
581 585
582 class SitePerProcessIgnoreCertErrorsBrowserTest 586 class SitePerProcessIgnoreCertErrorsBrowserTest
583 : public SitePerProcessBrowserTest { 587 : public SitePerProcessBrowserTest {
584 public: 588 public:
585 SitePerProcessIgnoreCertErrorsBrowserTest() {} 589 SitePerProcessIgnoreCertErrorsBrowserTest() {}
586 590
(...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 EXPECT_EQ(expect_scrollbar, has_scrollbar(child->current_frame_host())); 3028 EXPECT_EQ(expect_scrollbar, has_scrollbar(child->current_frame_host()));
3025 } 3029 }
3026 } 3030 }
3027 } 3031 }
3028 3032
3029 // Verify that "marginwidth" and "marginheight" properties on frame elements 3033 // Verify that "marginwidth" and "marginheight" properties on frame elements
3030 // propagate to child frames correctly. 3034 // propagate to child frames correctly.
3031 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3035 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3032 FrameOwnerPropertiesPropagationMargin) { 3036 FrameOwnerPropertiesPropagationMargin) {
3033 GURL main_url(embedded_test_server()->GetURL( 3037 GURL main_url(embedded_test_server()->GetURL(
3034 "a.com", "/frame_owner_properties_margin.html")); 3038 "a.com", "/frame_owner_properties_margin_and_csp.html"));
3035 NavigateToURL(shell(), main_url); 3039 NavigateToURL(shell(), main_url);
3036 3040
3037 // It is safe to obtain the root frame tree node here, as it doesn't change. 3041 // It is safe to obtain the root frame tree node here, as it doesn't change.
3038 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 3042 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
3039 ASSERT_EQ(1u, root->child_count()); 3043 ASSERT_EQ(1u, root->child_count());
3040 3044
3041 EXPECT_EQ( 3045 EXPECT_EQ(
3042 " Site A ------------ proxies for B\n" 3046 " Site A ------------ proxies for B\n"
3043 " +--Site B ------- proxies for A\n" 3047 " +--Site B ------- proxies for A\n"
3044 "Where A = http://a.com/\n" 3048 "Where A = http://a.com/\n"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 "window.domAutomationController.send(" 3112 "window.domAutomationController.send("
3109 "document.body.getAttribute('marginheight'));", 3113 "document.body.getAttribute('marginheight'));",
3110 &actual_margin_height)); 3114 &actual_margin_height));
3111 EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height); 3115 EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height);
3112 3116
3113 current_margin_width += 5; 3117 current_margin_width += 5;
3114 current_margin_height += 10; 3118 current_margin_height += 10;
3115 } 3119 }
3116 } 3120 }
3117 3121
3122 // Verify that "csp" property on frame
3123 // elements ropagates to child frames correctly.
alexmos 2016/09/30 06:20:42 nits: s/ropagates/propagates/ Please fix the wrap
3124 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
3125 FrameOwnerPropertiesPropagationCSP) {
3126 GURL main_url(embedded_test_server()->GetURL(
3127 "a.com", "/frame_owner_properties_margin_and_csp.html"));
alexmos 2016/09/30 06:20:42 Instead of reusing the file, it might be cleaner t
3128 NavigateToURL(shell(), main_url);
alexmos 2016/09/30 06:20:42 nit: EXPECT_TRUE
3129
3130 // It is safe to obtain the root frame tree node here, as it doesn't change.
3131 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
3132 ASSERT_EQ(1u, root->child_count());
3133
3134 EXPECT_EQ(
3135 " Site A ------------ proxies for B\n"
3136 " +--Site B ------- proxies for A\n"
3137 "Where A = http://a.com/\n"
3138 " B = http://b.com/",
3139 DepictFrameTree(root));
3140
3141 FrameTreeNode* child = root->child_at(0);
3142
3143 std::string csp;
3144 EXPECT_TRUE(ExecuteScriptAndExtractString(
3145 root,
3146 "window.domAutomationController.send("
3147 "document.getElementById('child-1').getAttribute('csp'));",
3148 &csp));
3149 EXPECT_EQ("object-src \'none\'", csp);
3150
3151 // Run the test over variety of parent/child cases.
3152 GURL urls[] = {// Remote to remote.
3153 embedded_test_server()->GetURL("c.com", "/title2.html"),
3154 // Remote to local.
3155 embedded_test_server()->GetURL("a.com", "/title1.html"),
3156 // Local to remote.
3157 embedded_test_server()->GetURL("b.com", "/title2.html")};
3158
3159 std::vector<base::string16> csp_values = {
alexmos 2016/09/30 06:20:42 why not just std::string and avoid all conversions
3160 base::ASCIIToUTF16("default-src a.com"),
3161 base::ASCIIToUTF16("default-src b.com"),
3162 base::ASCIIToUTF16("img-src c.com")};
3163 base::string16 current_csp;
3164
3165 // Before each navigation, we change the csp property of the frame.
3166 // We then check whether that property is applied
3167 // correctly after the navigation has completed.
3168 for (size_t i = 0; i < arraysize(urls); ++i) {
3169 // Change csp before navigating.
3170 current_csp = csp_values[i];
3171 EXPECT_TRUE(ExecuteScript(
3172 root,
3173 base::StringPrintf("document.getElementById('child-1').setAttribute("
3174 " 'csp', '%s');",
3175 base::UTF16ToUTF8(current_csp).c_str())));
alexmos 2016/09/30 06:20:42 nit: could just use csp_values[i] directly (here a
3176
3177 NavigateFrameToURL(child, urls[i]);
3178
3179 EXPECT_EQ(current_csp, child->frame_owner_properties().csp);
alexmos 2016/09/30 06:20:42 Is it possible to observe that the passed CSP attr
amalika 2016/09/30 07:48:51 The deserialization and the algorithms have not be
3180 }
3181 }
3182
3118 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. 3183 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy.
3119 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { 3184 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
3120 GURL main_url(embedded_test_server()->GetURL( 3185 GURL main_url(embedded_test_server()->GetURL(
3121 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); 3186 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)"));
3122 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3187 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3123 3188
3124 // It is safe to obtain the root frame tree node here, as it doesn't change. 3189 // It is safe to obtain the root frame tree node here, as it doesn't change.
3125 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); 3190 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
3126 3191
3127 EXPECT_EQ( 3192 EXPECT_EQ(
(...skipping 5096 matching lines...) Expand 10 before | Expand all | Expand 10 after
8224 " Site A ------------ proxies for B C\n" 8289 " Site A ------------ proxies for B C\n"
8225 " +--Site B ------- proxies for A C\n" 8290 " +--Site B ------- proxies for A C\n"
8226 " +--Site C -- proxies for A B\n" 8291 " +--Site C -- proxies for A B\n"
8227 "Where A = http://a.com/\n" 8292 "Where A = http://a.com/\n"
8228 " B = http://b.com/\n" 8293 " B = http://b.com/\n"
8229 " C = http://c.com/", 8294 " C = http://c.com/",
8230 DepictFrameTree(root)); 8295 DepictFrameTree(root));
8231 } 8296 }
8232 8297
8233 } // namespace content 8298 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | content/common/frame_owner_properties.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698