OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/frame_tree.h" | 5 #include "content/browser/frame_host/frame_tree.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "content/browser/frame_host/navigator_impl.h" | 9 #include "content/browser/frame_host/navigator_impl.h" |
10 #include "content/browser/frame_host/render_frame_host_factory.h" | 10 #include "content/browser/frame_host/render_frame_host_factory.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Do some simple manipulations of the frame tree, making sure that | 201 // Do some simple manipulations of the frame tree, making sure that |
202 // WebContentsObservers see a consistent view of the tree as we go. | 202 // WebContentsObservers see a consistent view of the tree as we go. |
203 TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) { | 203 TEST_F(FrameTreeTest, ObserverWalksTreeDuringFrameCreation) { |
204 TreeWalkingWebContentsLogger activity(contents()); | 204 TreeWalkingWebContentsLogger activity(contents()); |
205 FrameTree* frame_tree = contents()->GetFrameTree(); | 205 FrameTree* frame_tree = contents()->GetFrameTree(); |
206 FrameTreeNode* root = frame_tree->root(); | 206 FrameTreeNode* root = frame_tree->root(); |
207 | 207 |
208 EXPECT_EQ("", activity.GetLog()); | 208 EXPECT_EQ("", activity.GetLog()); |
209 | 209 |
210 // Simulate attaching a series of frames to build the frame tree. | 210 // Simulate attaching a series of frames to build the frame tree. |
211 main_test_rfh()->OnCreateChildFrame(14, std::string()); | 211 main_test_rfh()->OnCreateChildFrame(14, std::string(), SandboxFlags::NONE); |
212 EXPECT_EQ("RenderFrameCreated(14) -> 1: [14: []]", activity.GetLog()); | 212 EXPECT_EQ("RenderFrameCreated(14) -> 1: [14: []]", activity.GetLog()); |
213 main_test_rfh()->OnCreateChildFrame(18, std::string()); | 213 main_test_rfh()->OnCreateChildFrame(18, std::string(), SandboxFlags::NONE); |
214 EXPECT_EQ("RenderFrameCreated(18) -> 1: [14: [], 18: []]", activity.GetLog()); | 214 EXPECT_EQ("RenderFrameCreated(18) -> 1: [14: [], 18: []]", activity.GetLog()); |
215 frame_tree->RemoveFrame(root->child_at(0)); | 215 frame_tree->RemoveFrame(root->child_at(0)); |
216 EXPECT_EQ("RenderFrameDeleted(14) -> 1: [18: []]", activity.GetLog()); | 216 EXPECT_EQ("RenderFrameDeleted(14) -> 1: [18: []]", activity.GetLog()); |
217 frame_tree->RemoveFrame(root->child_at(0)); | 217 frame_tree->RemoveFrame(root->child_at(0)); |
218 EXPECT_EQ("RenderFrameDeleted(18) -> 1: []", activity.GetLog()); | 218 EXPECT_EQ("RenderFrameDeleted(18) -> 1: []", activity.GetLog()); |
219 } | 219 } |
220 | 220 |
221 // Make sure that WebContentsObservers see a consistent view of the tree after | 221 // Make sure that WebContentsObservers see a consistent view of the tree after |
222 // recovery from a render process crash. | 222 // recovery from a render process crash. |
223 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { | 223 TEST_F(FrameTreeTest, ObserverWalksTreeAfterCrash) { |
224 TreeWalkingWebContentsLogger activity(contents()); | 224 TreeWalkingWebContentsLogger activity(contents()); |
225 | 225 |
226 main_test_rfh()->OnCreateChildFrame(22, std::string()); | 226 main_test_rfh()->OnCreateChildFrame(22, std::string(), SandboxFlags::NONE); |
227 EXPECT_EQ("RenderFrameCreated(22) -> 1: [22: []]", activity.GetLog()); | 227 EXPECT_EQ("RenderFrameCreated(22) -> 1: [22: []]", activity.GetLog()); |
228 main_test_rfh()->OnCreateChildFrame(23, std::string()); | 228 main_test_rfh()->OnCreateChildFrame(23, std::string(), SandboxFlags::NONE); |
229 EXPECT_EQ("RenderFrameCreated(23) -> 1: [22: [], 23: []]", activity.GetLog()); | 229 EXPECT_EQ("RenderFrameCreated(23) -> 1: [22: [], 23: []]", activity.GetLog()); |
230 | 230 |
231 // Crash the renderer | 231 // Crash the renderer |
232 test_rvh()->OnMessageReceived(ViewHostMsg_RenderProcessGone( | 232 test_rvh()->OnMessageReceived(ViewHostMsg_RenderProcessGone( |
233 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); | 233 0, base::TERMINATION_STATUS_PROCESS_CRASHED, -1)); |
234 EXPECT_EQ( | 234 EXPECT_EQ( |
235 "RenderFrameDeleted(22) -> 1: []\n" | 235 "RenderFrameDeleted(22) -> 1: []\n" |
236 "RenderFrameDeleted(23) -> 1: []\n" | 236 "RenderFrameDeleted(23) -> 1: []\n" |
237 "RenderProcessGone -> 1: []", | 237 "RenderProcessGone -> 1: []", |
238 activity.GetLog()); | 238 activity.GetLog()); |
239 } | 239 } |
240 | 240 |
241 // Ensure that frames are not added to the tree, if the process passed in | 241 // Ensure that frames are not added to the tree, if the process passed in |
242 // is different than the process of the parent node. | 242 // is different than the process of the parent node. |
243 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) { | 243 TEST_F(FrameTreeTest, FailAddFrameWithWrongProcessId) { |
244 FrameTree* frame_tree = contents()->GetFrameTree(); | 244 FrameTree* frame_tree = contents()->GetFrameTree(); |
245 FrameTreeNode* root = frame_tree->root(); | 245 FrameTreeNode* root = frame_tree->root(); |
246 int process_id = root->current_frame_host()->GetProcess()->GetID(); | 246 int process_id = root->current_frame_host()->GetProcess()->GetID(); |
247 | 247 |
248 ASSERT_EQ("1: []", GetTreeState(frame_tree)); | 248 ASSERT_EQ("1: []", GetTreeState(frame_tree)); |
249 | 249 |
250 // Simulate attaching a frame from mismatched process id. | 250 // Simulate attaching a frame from mismatched process id. |
251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string())); | 251 ASSERT_FALSE(frame_tree->AddFrame(root, process_id + 1, 1, std::string())); |
252 ASSERT_EQ("1: []", GetTreeState(frame_tree)); | 252 ASSERT_EQ("1: []", GetTreeState(frame_tree)); |
253 } | 253 } |
254 | 254 |
255 } // namespace content | 255 } // namespace content |
OLD | NEW |