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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1130233002: Convert main_render_frame_ to raw pointer in RenderViewImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address lfg@'s review comments. Created 5 years, 7 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 EXPECT_TRUE(IsPaused()); 360 EXPECT_TRUE(IsPaused());
361 view()->NotifyOnClose(); 361 view()->NotifyOnClose();
362 } 362 }
363 363
364 private: 364 private:
365 DevToolsAgent* agent() { 365 DevToolsAgent* agent() {
366 return frame()->devtools_agent(); 366 return frame()->devtools_agent();
367 } 367 }
368 }; 368 };
369 369
370 // Test for https://crbug.com/461191. 370 // Ensure that the main RenderFrame is deleted and cleared from the RenderView
371 TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) { 371 // after closing it.
372 TEST_F(RenderViewImplTest, RenderFrameClearedAfterClose) {
372 // Create a new main frame RenderFrame so that we don't interfere with the 373 // Create a new main frame RenderFrame so that we don't interfere with the
373 // shutdown of frame() in RenderViewTest.TearDown. 374 // shutdown of frame() in RenderViewTest.TearDown.
374 blink::WebURLRequest popup_request(GURL("http://foo.com")); 375 blink::WebURLRequest popup_request(GURL("http://foo.com"));
375 blink::WebView* new_web_view = view()->createView( 376 blink::WebView* new_web_view = view()->createView(
376 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", 377 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo",
377 blink::WebNavigationPolicyNewForegroundTab, false); 378 blink::WebNavigationPolicyNewForegroundTab, false);
378 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); 379 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
379 RenderFrameImpl* new_frame =
380 static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame());
381 380
382 // Detach the main frame. 381 // Close the view, causing the main RenderFrame to be detached and deleted.
383 new_view->Close(); 382 new_view->Close();
384 383 EXPECT_FALSE(new_view->GetMainRenderFrame());
385 // Before the frame is asynchronously deleted, it may receive a message.
386 // We should not crash here, and the message should not be processed.
387 scoped_ptr<const IPC::Message> msg(
388 new FrameMsg_Stop(frame()->GetRoutingID()));
389 EXPECT_FALSE(new_frame->OnMessageReceived(*msg));
390 384
391 // Clean up after the new view so we don't leak it. 385 // Clean up after the new view so we don't leak it.
392 new_view->Release(); 386 new_view->Release();
393 } 387 }
394 388
395 TEST_F(RenderViewImplTest, SaveImageFromDataURL) { 389 TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
396 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( 390 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
397 ViewHostMsg_SaveImageFromDataURL::ID); 391 ViewHostMsg_SaveImageFromDataURL::ID);
398 EXPECT_FALSE(msg1); 392 EXPECT_FALSE(msg1);
399 render_thread_->sink().ClearMessages(); 393 render_thread_->sink().ClearMessages();
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 // expected result. 2001 // expected result.
2008 const int kMaxOutputCharacters = 256; 2002 const int kMaxOutputCharacters = 256;
2009 std::string output = base::UTF16ToUTF8( 2003 std::string output = base::UTF16ToUTF8(
2010 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 2004 GetMainFrame()->contentAsText(kMaxOutputCharacters));
2011 EXPECT_EQ(output, "hello \n\nworld"); 2005 EXPECT_EQ(output, "hello \n\nworld");
2012 } 2006 }
2013 2007
2014 // This test ensures that a RenderFrame object is created for the top level 2008 // This test ensures that a RenderFrame object is created for the top level
2015 // frame in the RenderView. 2009 // frame in the RenderView.
2016 TEST_F(RenderViewImplTest, BasicRenderFrame) { 2010 TEST_F(RenderViewImplTest, BasicRenderFrame) {
2017 EXPECT_TRUE(view()->main_render_frame_.get()); 2011 EXPECT_TRUE(view()->main_render_frame_);
2018 } 2012 }
2019 2013
2020 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { 2014 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) {
2021 LoadHTML("<!DOCTYPE html><html><body></body></html>"); 2015 LoadHTML("<!DOCTYPE html><html><body></body></html>");
2022 2016
2023 WebLocalFrame* frame = GetMainFrame(); 2017 WebLocalFrame* frame = GetMainFrame();
2024 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame); 2018 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame);
2025 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); 2019 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status));
2026 2020
2027 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()). 2021 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()).
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 2428 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
2435 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2429 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2436 ExecuteJavaScript("debugger;"); 2430 ExecuteJavaScript("debugger;");
2437 2431
2438 // CloseWhilePaused should resume execution and continue here. 2432 // CloseWhilePaused should resume execution and continue here.
2439 EXPECT_FALSE(IsPaused()); 2433 EXPECT_FALSE(IsPaused());
2440 Detach(); 2434 Detach();
2441 } 2435 }
2442 2436
2443 } // namespace content 2437 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698