Chromium Code Reviews| 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..3957c62a06221f666e7ce495d92deb60f3b1e74e 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->AppendSwitch( |
| + switches::kEnableExperimentalWebPlatformFeatures); |
|
Mike West
2016/09/29 08:58:53
Hrm. This might be an argument for pushing the CSP
|
| }; |
| void SitePerProcessBrowserTest::SetUpOnMainThread() { |
| @@ -3026,12 +3031,13 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| } |
| } |
| -// Verify that "marginwidth" and "marginheight" properties on frame elements |
| +// Verify that "marginwidth","marginheight" and "csp" properties on frame |
| +// elements |
| // propagate to child frames correctly. |
| IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| - FrameOwnerPropertiesPropagationMargin) { |
| + FrameOwnerPropertiesPropagationMarginAndCSP) { |
| GURL main_url(embedded_test_server()->GetURL( |
| - "a.com", "/frame_owner_properties_margin.html")); |
| + "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. |
| @@ -3063,6 +3069,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| &margin_height)); |
| EXPECT_EQ("50", margin_height); |
| + 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. |
| @@ -3073,14 +3087,26 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| embedded_test_server()->GetURL("b.com", "/title2.html") |
| }; |
| - int current_margin_width = 15; |
| - int current_margin_height = 25; |
| + std::vector<std::string> csp_values = {"default-src a.com", |
| + "default-src b.com", "img-src none"}; |
| + std::string current_csp; |
| + int current_margin_width = 10; |
| + int current_margin_height = 50; |
|
Mike West
2016/09/29 08:58:53
Why did the margins change?
|
| - // Before each navigation, we change the marginwidth and marginheight |
| + // Before each navigation, we change the marginwidth, marginheight and csp |
|
Mike West
2016/09/29 08:58:53
Nit: Oxford comma (e.g. "x, y, and z")
|
| // properties of the frame. We then check whether those properties are applied |
| // correctly after the navigation has completed. |
| for (size_t i = 0; i < arraysize(urls); ++i) { |
| - // Change marginwidth and marginheight before navigating. |
| + current_csp = csp_values[i]; |
| + current_margin_width += 5; |
| + current_margin_height += 10; |
| + |
| + // Change marginwidth, marginheight, and csp before navigating. |
|
Mike West
2016/09/29 08:58:53
Nit: Move this before the assignments above.
|
| + EXPECT_TRUE(ExecuteScript( |
| + root, |
| + base::StringPrintf("document.getElementById('child-1').setAttribute(" |
| + " 'csp', '%s');", |
| + current_csp.c_str()))); |
| EXPECT_TRUE(ExecuteScript( |
| root, |
| base::StringPrintf("document.getElementById('child-1').setAttribute(" |
| @@ -3094,6 +3120,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| NavigateFrameToURL(child, urls[i]); |
| + EXPECT_EQ(current_csp, child->frame_owner_properties().csp); |
| + |
| std::string actual_margin_width; |
| EXPECT_TRUE(ExecuteScriptAndExtractString( |
| child, |
| @@ -3109,9 +3137,6 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| "document.body.getAttribute('marginheight'));", |
| &actual_margin_height)); |
| EXPECT_EQ(base::IntToString(current_margin_height), actual_margin_height); |
| - |
| - current_margin_width += 5; |
| - current_margin_height += 10; |
| } |
| } |