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

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

Issue 1756483004: Fix use-after-free when navigating a subframe to about:blank. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 4721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4732 4732
4733 // Make sure the a.com renderer does not crash. 4733 // Make sure the a.com renderer does not crash.
4734 int child_count = 0; 4734 int child_count = 0;
4735 EXPECT_TRUE(ExecuteScriptAndExtractInt( 4735 EXPECT_TRUE(ExecuteScriptAndExtractInt(
4736 root->current_frame_host(), 4736 root->current_frame_host(),
4737 "domAutomationController.send(frames.length)", 4737 "domAutomationController.send(frames.length)",
4738 &child_count)); 4738 &child_count));
4739 EXPECT_EQ(1, child_count); 4739 EXPECT_EQ(1, child_count);
4740 } 4740 }
4741 4741
4742 // Similar to NavigateProxyAndDetachBeforeCommit, but uses a synchronous
4743 // navigation to about:blank and the parent removes the child frame in a load
4744 // event handler for the subframe.
4745 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateAboutBlankAndDetach) {
4746 GURL main_url(
4747 embedded_test_server()->GetURL("a.com", "/remove_frame_on_load.html"));
4748 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4749
4750 WebContents* contents = shell()->web_contents();
4751 FrameTreeNode* root =
4752 static_cast<WebContentsImpl*>(contents)->GetFrameTree()->root();
4753 EXPECT_EQ(1U, root->child_count());
4754 FrameTreeNode* child = root->child_at(0);
4755 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
4756 child->current_frame_host()->GetSiteInstance());
4757
4758 // Navigate the child frame to "about:blank" from the parent document.
4759 TestNavigationObserver observer(shell()->web_contents());
4760 EXPECT_TRUE(
4761 ExecuteScript(root->current_frame_host(),
4762 base::StringPrintf("f.src = '%s'", url::kAboutBlankURL)));
dcheng 2016/03/03 00:46:59 So this navigation is sync?
nasko 2016/03/03 16:59:17 Yes, otherwise it won't repro. I don't think the s
4763 observer.Wait();
4764
4765 // Make sure the a.com renderer does not crash and the frame is removed.
4766 int child_count = 0;
4767 EXPECT_TRUE(ExecuteScriptAndExtractInt(
4768 root->current_frame_host(), "domAutomationController.send(frames.length)",
4769 &child_count));
4770 EXPECT_EQ(0, child_count);
4771 }
4772
4742 // Test for https://crbug.com/568670. In A-embed-B, simultaneously have B 4773 // Test for https://crbug.com/568670. In A-embed-B, simultaneously have B
4743 // create a new (local) child frame, and have A detach B's proxy. The child 4774 // create a new (local) child frame, and have A detach B's proxy. The child
4744 // frame creation sends an IPC to create a new proxy in A's process, and if 4775 // frame creation sends an IPC to create a new proxy in A's process, and if
4745 // that IPC arrives after the detach, the new frame's parent (a proxy) won't be 4776 // that IPC arrives after the detach, the new frame's parent (a proxy) won't be
4746 // available, and this shouldn't cause RenderFrameProxy::CreateFrameProxy to 4777 // available, and this shouldn't cause RenderFrameProxy::CreateFrameProxy to
4747 // crash. 4778 // crash.
4748 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4779 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4749 RaceBetweenCreateChildFrameAndDetachParentProxy) { 4780 RaceBetweenCreateChildFrameAndDetachParentProxy) {
4750 GURL main_url(embedded_test_server()->GetURL( 4781 GURL main_url(embedded_test_server()->GetURL(
4751 "a.com", "/cross_site_iframe_factory.html?a(b)")); 4782 "a.com", "/cross_site_iframe_factory.html?a(b)"));
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
5344 5375
5345 // Force the renderer to generate a new frame. 5376 // Force the renderer to generate a new frame.
5346 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5377 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5347 "document.body.style.background = 'black'")); 5378 "document.body.style.background = 'black'"));
5348 5379
5349 // Waits for the next frame. 5380 // Waits for the next frame.
5350 observer->Wait(); 5381 observer->Wait();
5351 } 5382 }
5352 5383
5353 } // namespace content 5384 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | content/renderer/render_frame_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698