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

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

Issue 1710283003: OOPIF: Handle cross-site frames being blocked by X-Frame-Options or CSP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split off the relaxed DCHECK in OnCrossSiteResponse into separate CL 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
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | 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 5360 matching lines...) Expand 10 before | Expand all | Expand 10 after
5371 observer->Wait(); 5371 observer->Wait();
5372 5372
5373 // Force the renderer to generate a new frame. 5373 // Force the renderer to generate a new frame.
5374 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5374 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5375 "document.body.style.background = 'black'")); 5375 "document.body.style.background = 'black'"));
5376 5376
5377 // Waits for the next frame. 5377 // Waits for the next frame.
5378 observer->Wait(); 5378 observer->Wait();
5379 } 5379 }
5380 5380
5381 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP
5382 // frame-ancestors.
5383 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5384 CrossSiteIframeBlockedByXFrameOptionsOrCSP) {
5385 GURL main_url(embedded_test_server()->GetURL(
5386 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5387 NavigateToURL(shell(), main_url);
5388
5389 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
5390 ->GetFrameTree()
5391 ->root();
5392 GURL frame_url(root->child_at(0)->current_url());
5393
5394 // Add a load event handler for the iframe element.
5395 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5396 "document.querySelector('iframe').onload = "
5397 " function() { document.title = 'loaded'; };"));
5398
5399 GURL blocked_urls[] = {
5400 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"),
5401 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html")
5402 };
5403
5404 for (size_t i = 0; i < arraysize(blocked_urls); ++i) {
5405 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5406 "document.title = 'not loaded';"));
5407 base::string16 expected_title(base::UTF8ToUTF16("loaded"));
5408 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
5409
5410 // Navigate the subframe to a blocked URL, and wait for navigation to fail.
5411 TestNavigationObserver load_observer(shell()->web_contents());
5412 EXPECT_TRUE(ExecuteScript(
5413 shell()->web_contents(),
5414 "frames[0].location.href = '" + blocked_urls[i].spec() + "';"));
5415 load_observer.Wait();
5416
5417 // Blocking the frame will result in a DidFailProvisionalLoad; i.e., the
5418 // last navigation should have failed.
5419 EXPECT_FALSE(load_observer.last_navigation_succeeded());
5420
5421 // The blocked frame's origin should become unique.
5422 EXPECT_EQ("null", root->child_at(0)->current_origin().Serialize());
5423
5424 // The blocked frame should still fire a load event in its parent's process.
5425 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
5426
5427 // Double-check that the current RenderFrameHost has stopped loading.
5428 EXPECT_FALSE(root->child_at(0)->current_frame_host()->is_loading());
5429
5430 // Navigate the subframe to another cross-origin page and ensure that this
5431 // navigation succeeds.
5432 GURL c_url(embedded_test_server()->GetURL("c.com", "/title1.html"));
5433 EXPECT_TRUE(NavigateIframeToURL(shell()->web_contents(), "child-0", c_url));
5434 EXPECT_EQ(c_url, root->child_at(0)->current_url());
5435
5436 // When a page gets blocked due to XFO or CSP, it is sandboxed with the
5437 // SandboxOrigin flag (i.e., its origin is set to be unique) in the
5438 // renderer to ensure that the blocked page is seen as cross-origin.
5439 // However, those flags shouldn't affect future navigations for a frame.
5440 // Verify this for the above navigation.
5441 EXPECT_EQ(c_url.GetOrigin().spec(),
5442 root->child_at(0)->current_origin().Serialize() + "/");
5443 EXPECT_EQ(blink::WebSandboxFlags::None,
5444 root->child_at(0)->effective_sandbox_flags());
5445 }
5446 }
5447
5381 } // namespace content 5448 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_impl.cc ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698