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

Side by Side 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: Add test 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 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 279 }
280 280
281 void SetZoomLevel(double level) { 281 void SetZoomLevel(double level) {
282 view()->OnSetZoomLevelForView(false, level); 282 view()->OnSetZoomLevelForView(false, level);
283 } 283 }
284 284
285 private: 285 private:
286 scoped_ptr<MockKeyboard> mock_keyboard_; 286 scoped_ptr<MockKeyboard> mock_keyboard_;
287 }; 287 };
288 288
289 // Test for https://crbug.com/461191.
290 TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) {
291 // Create a new main frame RenderFrame so that we don't interfere with the
292 // shutdown of frame() in RenderViewTest.TearDown.
293 blink::WebURLRequest popup_request(GURL("http://foo.com"));
294 blink::WebView* new_web_view = view()->createView(
295 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo",
296 blink::WebNavigationPolicyNewForegroundTab, false);
297 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
298 RenderFrameImpl* new_frame =
299 static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame());
300
301 // Detach the main frame.
302 new_view->Close();
303
304 // Before the frame is asynchronously deleted, it may receive a message.
305 // We should not crash here.
306 const IPC::Message* msg = new FrameMsg_Stop(frame()->GetRoutingID());
307 new_frame->OnMessageReceived(*msg);
308
309 // Clean up after the new view so we don't leak it.
310 new_view->Release();
311 }
312
289 TEST_F(RenderViewImplTest, SaveImageFromDataURL) { 313 TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
290 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( 314 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
291 ViewHostMsg_SaveImageFromDataURL::ID); 315 ViewHostMsg_SaveImageFromDataURL::ID);
292 EXPECT_FALSE(msg1); 316 EXPECT_FALSE(msg1);
293 render_thread_->sink().ClearMessages(); 317 render_thread_->sink().ClearMessages();
294 318
295 const std::string image_data_url = 319 const std::string image_data_url =
296 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; 320 "data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
297 321
298 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url)); 322 view()->saveImageFromDataURL(WebString::fromUTF8(image_data_url));
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), 2333 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(),
2310 CommitNavigationParams(), history_params); 2334 CommitNavigationParams(), history_params);
2311 2335
2312 // The history list in RenderView should have been updated. 2336 // The history list in RenderView should have been updated.
2313 EXPECT_EQ(1, view()->historyBackListCount()); 2337 EXPECT_EQ(1, view()->historyBackListCount());
2314 EXPECT_EQ(2, view()->historyBackListCount() + 2338 EXPECT_EQ(2, view()->historyBackListCount() +
2315 view()->historyForwardListCount() + 1); 2339 view()->historyForwardListCount() + 1);
2316 } 2340 }
2317 2341
2318 } // namespace content 2342 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698