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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1007123003: Clear RenderFrameImpl::frame_ pointer after deleting it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Verify OnMessageReceived returns false Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 713c9767eb504864ad86320215278d86685fe238..242b2b685e2dc1943adf37d4af32cd3881a3bd89 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -286,6 +286,31 @@ class RenderViewImplTest : public RenderViewTest {
scoped_ptr<MockKeyboard> mock_keyboard_;
};
+// Test for https://crbug.com/461191.
+TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) {
+ // Create a new main frame RenderFrame so that we don't interfere with the
+ // shutdown of frame() in RenderViewTest.TearDown.
+ blink::WebURLRequest popup_request(GURL("http://foo.com"));
+ blink::WebView* new_web_view = view()->createView(
+ GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo",
+ blink::WebNavigationPolicyNewForegroundTab, false);
+ RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
+ RenderFrameImpl* new_frame =
+ static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame());
+
+ // Detach the main frame.
+ new_view->Close();
+
+ // Before the frame is asynchronously deleted, it may receive a message.
+ // We should not crash here, and the message should not be processed.
+ scoped_ptr<const IPC::Message> msg(
+ new FrameMsg_Stop(frame()->GetRoutingID()));
+ EXPECT_FALSE(new_frame->OnMessageReceived(*msg));
+
+ // Clean up after the new view so we don't leak it.
+ new_view->Release();
+}
+
TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
ViewHostMsg_SaveImageFromDataURL::ID);
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698