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

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: Rebased and cleaned up. 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Test for https://crbug.com/461191.
371 TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) { 371 TEST_F(RenderViewImplTest, RenderFrameMessageAfterDetach) {
lfg 2015/05/08 19:42:27 After the changes the test is not testing for the
nasko 2015/05/11 16:12:33 I was looking around for a way to rewrite the test
372 // Create a new main frame RenderFrame so that we don't interfere with the 372 // Create a new main frame RenderFrame so that we don't interfere with the
373 // shutdown of frame() in RenderViewTest.TearDown. 373 // shutdown of frame() in RenderViewTest.TearDown.
374 blink::WebURLRequest popup_request(GURL("http://foo.com")); 374 blink::WebURLRequest popup_request(GURL("http://foo.com"));
375 blink::WebView* new_web_view = view()->createView( 375 blink::WebView* new_web_view = view()->createView(
376 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo", 376 GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo",
377 blink::WebNavigationPolicyNewForegroundTab, false); 377 blink::WebNavigationPolicyNewForegroundTab, false);
378 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view); 378 RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
379 RenderFrameImpl* new_frame =
380 static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame());
381 379
382 // Detach the main frame. 380 // Detach the main frame.
383 new_view->Close(); 381 new_view->Close();
384 382
385 // Before the frame is asynchronously deleted, it may receive a message. 383 // Deleted RenderFrame cannot receive IPCs.
386 // We should not crash here, and the message should not be processed. 384 EXPECT_FALSE(new_view->GetMainRenderFrame());
387 scoped_ptr<const IPC::Message> msg(
388 new FrameMsg_Stop(frame()->GetRoutingID()));
389 EXPECT_FALSE(new_frame->OnMessageReceived(*msg));
390 385
391 // Clean up after the new view so we don't leak it. 386 // Clean up after the new view so we don't leak it.
392 new_view->Release(); 387 new_view->Release();
393 } 388 }
394 389
395 TEST_F(RenderViewImplTest, SaveImageFromDataURL) { 390 TEST_F(RenderViewImplTest, SaveImageFromDataURL) {
396 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching( 391 const IPC::Message* msg1 = render_thread_->sink().GetFirstMessageMatching(
397 ViewHostMsg_SaveImageFromDataURL::ID); 392 ViewHostMsg_SaveImageFromDataURL::ID);
398 EXPECT_FALSE(msg1); 393 EXPECT_FALSE(msg1);
399 render_thread_->sink().ClearMessages(); 394 render_thread_->sink().ClearMessages();
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 // expected result. 2002 // expected result.
2008 const int kMaxOutputCharacters = 256; 2003 const int kMaxOutputCharacters = 256;
2009 std::string output = base::UTF16ToUTF8( 2004 std::string output = base::UTF16ToUTF8(
2010 GetMainFrame()->contentAsText(kMaxOutputCharacters)); 2005 GetMainFrame()->contentAsText(kMaxOutputCharacters));
2011 EXPECT_EQ(output, "hello \n\nworld"); 2006 EXPECT_EQ(output, "hello \n\nworld");
2012 } 2007 }
2013 2008
2014 // This test ensures that a RenderFrame object is created for the top level 2009 // This test ensures that a RenderFrame object is created for the top level
2015 // frame in the RenderView. 2010 // frame in the RenderView.
2016 TEST_F(RenderViewImplTest, BasicRenderFrame) { 2011 TEST_F(RenderViewImplTest, BasicRenderFrame) {
2017 EXPECT_TRUE(view()->main_render_frame_.get()); 2012 EXPECT_TRUE(view()->main_render_frame_);
2018 } 2013 }
2019 2014
2020 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) { 2015 TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) {
2021 LoadHTML("<!DOCTYPE html><html><body></body></html>"); 2016 LoadHTML("<!DOCTYPE html><html><body></body></html>");
2022 2017
2023 WebLocalFrame* frame = GetMainFrame(); 2018 WebLocalFrame* frame = GetMainFrame();
2024 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame); 2019 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame);
2025 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); 2020 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status));
2026 2021
2027 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()). 2022 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( 2429 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
2435 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2430 &DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2436 ExecuteJavaScript("debugger;"); 2431 ExecuteJavaScript("debugger;");
2437 2432
2438 // CloseWhilePaused should resume execution and continue here. 2433 // CloseWhilePaused should resume execution and continue here.
2439 EXPECT_FALSE(IsPaused()); 2434 EXPECT_FALSE(IsPaused());
2440 Detach(); 2435 Detach();
2441 } 2436 }
2442 2437
2443 } // namespace content 2438 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698