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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 2378643002: Propagating csp attribute changes on frameOwnerPropertiesChanged() (Closed)
Patch Set: Separating CSP test, addressing co commnets Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | content/common/frame_owner_properties.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 80c95ff99ac5d34d5842621b0052d0d123cde54d..7354fa5e21affc049548370681678d688f31c11a 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -549,6 +549,11 @@ std::string SitePerProcessBrowserTest::DepictFrameTree(FrameTreeNode* node) {
void SitePerProcessBrowserTest::SetUpCommandLine(
base::CommandLine* command_line) {
IsolateAllSitesForTesting(command_line);
+
+ // TODO(amalika): Remove this switch when
+ // the EmbedderCSPEnforcement becomes stable
+ command_line->AppendSwitchASCII(switches::kEnableBlinkFeatures,
+ "EmbedderCSPEnforcement");
};
void SitePerProcessBrowserTest::SetUpOnMainThread() {
@@ -3115,6 +3120,67 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
}
}
+// Verify that "csp" property on frame
+// elements ropagates to child frames correctly.
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
Mike West 2016/09/29 11:50:14 If you're going to split this out, I'd suggest mov
+ FrameOwnerPropertiesPropagationCSP) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "a.com", "/frame_owner_properties_margin_and_csp.html"));
+ NavigateToURL(shell(), main_url);
+
+ // It is safe to obtain the root frame tree node here, as it doesn't change.
+ FrameTreeNode* root = web_contents()->GetFrameTree()->root();
+ ASSERT_EQ(1u, root->child_count());
+
+ EXPECT_EQ(
+ " Site A ------------ proxies for B\n"
+ " +--Site B ------- proxies for A\n"
+ "Where A = http://a.com/\n"
+ " B = http://b.com/",
+ DepictFrameTree(root));
+
+ FrameTreeNode* child = root->child_at(0);
+
+ std::string csp;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ root,
+ "window.domAutomationController.send("
+ "document.getElementById('child-1').getAttribute('csp'));",
+ &csp));
+ EXPECT_EQ("object-src \'none\'", csp);
+
+ // Run the test over variety of parent/child cases.
+ GURL urls[] = {// Remote to remote.
+ embedded_test_server()->GetURL("c.com", "/title2.html"),
+ // Remote to local.
+ embedded_test_server()->GetURL("a.com", "/title1.html"),
+ // Local to remote.
+ embedded_test_server()->GetURL("b.com", "/title2.html")};
+
+ std::vector<base::string16> csp_values = {
+ base::ASCIIToUTF16("default-src a.com"),
+ base::ASCIIToUTF16("default-src b.com"),
+ base::ASCIIToUTF16("img-src c.com")};
+ base::string16 current_csp;
+
+ // Before each navigation, we change the csp property of the frame.
+ // We then check whether that property is applied
+ // correctly after the navigation has completed.
+ for (size_t i = 0; i < arraysize(urls); ++i) {
+ // Change csp before navigating.
+ current_csp = csp_values[i];
+ EXPECT_TRUE(ExecuteScript(
+ root,
+ base::StringPrintf("document.getElementById('child-1').setAttribute("
+ " 'csp', '%s');",
+ base::UTF16ToUTF8(current_csp).c_str())));
+
+ NavigateFrameToURL(child, urls[i]);
+
+ EXPECT_EQ(current_csp, child->frame_owner_properties().csp);
+ }
+}
+
// Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy.
IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
GURL main_url(embedded_test_server()->GetURL(
« no previous file with comments | « no previous file | content/common/frame_messages.h » ('j') | content/common/frame_owner_properties.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698