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

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

Issue 1360123006: Introduce RenderFrame::IsMainFrame and clean up a few things. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed use-after-free. Created 5 years, 2 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
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/debug/leak_annotations.h" 6 #include "base/debug/leak_annotations.h"
7 #include "content/common/frame_messages.h" 7 #include "content/common/frame_messages.h"
8 #include "content/common/view_messages.h" 8 #include "content/common/view_messages.h"
9 #include "content/public/test/frame_load_waiter.h" 9 #include "content/public/test/frame_load_waiter.h"
10 #include "content/public/test/render_view_test.h" 10 #include "content/public/test/render_view_test.h"
(...skipping 15 matching lines...) Expand all
26 26
27 // RenderFrameImplTest creates a RenderFrameImpl that is a child of the 27 // RenderFrameImplTest creates a RenderFrameImpl that is a child of the
28 // main frame, and has its own RenderWidget. This behaves like an out 28 // main frame, and has its own RenderWidget. This behaves like an out
29 // of process frame even though it is in the same process as its parent. 29 // of process frame even though it is in the same process as its parent.
30 class RenderFrameImplTest : public RenderViewTest { 30 class RenderFrameImplTest : public RenderViewTest {
31 public: 31 public:
32 ~RenderFrameImplTest() override {} 32 ~RenderFrameImplTest() override {}
33 33
34 void SetUp() override { 34 void SetUp() override {
35 RenderViewTest::SetUp(); 35 RenderViewTest::SetUp();
36 EXPECT_FALSE(static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame()) 36 EXPECT_TRUE(static_cast<RenderFrameImpl*>(view_->GetMainRenderFrame())
37 ->is_subframe_); 37 ->is_main_frame_);
38 38
39 FrameMsg_NewFrame_WidgetParams widget_params; 39 FrameMsg_NewFrame_WidgetParams widget_params;
40 widget_params.routing_id = kSubframeWidgetRouteId; 40 widget_params.routing_id = kSubframeWidgetRouteId;
41 widget_params.hidden = false; 41 widget_params.hidden = false;
42 42
43 IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess()); 43 IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
44 44
45 LoadHTML("Parent frame <iframe name='frame'></iframe>"); 45 LoadHTML("Parent frame <iframe name='frame'></iframe>");
46 46
47 RenderFrameImpl::FromWebFrame( 47 RenderFrameImpl::FromWebFrame(
48 view_->GetMainRenderFrame()->GetWebFrame()->firstChild()) 48 view_->GetMainRenderFrame()->GetWebFrame()->firstChild())
49 ->OnSwapOut(kFrameProxyRouteId, false, FrameReplicationState()); 49 ->OnSwapOut(kFrameProxyRouteId, false, FrameReplicationState());
50 50
51 RenderFrameImpl::CreateFrame(kSubframeRouteId, MSG_ROUTING_NONE, 51 RenderFrameImpl::CreateFrame(kSubframeRouteId, MSG_ROUTING_NONE,
52 MSG_ROUTING_NONE, kFrameProxyRouteId, 52 MSG_ROUTING_NONE, kFrameProxyRouteId,
53 MSG_ROUTING_NONE, FrameReplicationState(), 53 MSG_ROUTING_NONE, FrameReplicationState(),
54 &compositor_deps_, widget_params); 54 &compositor_deps_, widget_params);
55 55
56 frame_ = RenderFrameImpl::FromRoutingID(kSubframeRouteId); 56 frame_ = RenderFrameImpl::FromRoutingID(kSubframeRouteId);
57 EXPECT_TRUE(frame_->is_subframe_); 57 EXPECT_FALSE(frame_->is_main_frame_);
58 } 58 }
59 59
60 void TearDown() override { 60 void TearDown() override {
61 #if defined(LEAK_SANITIZER) 61 #if defined(LEAK_SANITIZER)
62 // Do this before shutting down V8 in RenderViewTest::TearDown(). 62 // Do this before shutting down V8 in RenderViewTest::TearDown().
63 // http://crbug.com/328552 63 // http://crbug.com/328552
64 __lsan_do_leak_check(); 64 __lsan_do_leak_check();
65 #endif 65 #endif
66 RenderViewTest::TearDown(); 66 RenderViewTest::TearDown();
67 } 67 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 RenderFrameTestObserver observer(frame()); 148 RenderFrameTestObserver observer(frame());
149 149
150 ViewMsg_WasShown was_shown_message(0, true, ui::LatencyInfo()); 150 ViewMsg_WasShown was_shown_message(0, true, ui::LatencyInfo());
151 frame_widget()->OnMessageReceived(was_shown_message); 151 frame_widget()->OnMessageReceived(was_shown_message);
152 152
153 EXPECT_FALSE(frame_widget()->is_hidden()); 153 EXPECT_FALSE(frame_widget()->is_hidden());
154 EXPECT_TRUE(observer.visible()); 154 EXPECT_TRUE(observer.visible());
155 } 155 }
156 156
157 } // namespace 157 } // namespace
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698