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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 "267 'node with deep subtree': " | 225 "267 'node with deep subtree': " |
226 "[365: [455: []]], 268: []]]", | 226 "[365: [455: []]], 268: []]]", |
227 GetTreeState(frame_tree)); | 227 GetTreeState(frame_tree)); |
228 } | 228 } |
229 | 229 |
230 // Ensure frames can be found by frame_tree_node_id, routing ID, or name. | 230 // Ensure frames can be found by frame_tree_node_id, routing ID, or name. |
231 TEST_F(FrameTreeTest, FindFrames) { | 231 TEST_F(FrameTreeTest, FindFrames) { |
232 // Add a few child frames to the main frame. | 232 // Add a few child frames to the main frame. |
233 FrameTree* frame_tree = contents()->GetFrameTree(); | 233 FrameTree* frame_tree = contents()->GetFrameTree(); |
234 FrameTreeNode* root = frame_tree->root(); | 234 FrameTreeNode* root = frame_tree->root(); |
235 | |
236 test_rvh()->CreateRenderView(base::string16(), MSG_ROUTING_NONE, | |
nasko
2015/06/05 21:23:43
nit: main_test_rfh()->InitializeRenderFrameIfNeede
| |
237 MSG_ROUTING_NONE, -1, FrameReplicationState(), | |
238 false); | |
239 | |
235 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, | 240 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, |
236 "child0", blink::WebSandboxFlags::None); | 241 "child0", blink::WebSandboxFlags::None); |
237 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, | 242 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, |
238 "child1", blink::WebSandboxFlags::None); | 243 "child1", blink::WebSandboxFlags::None); |
239 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document, | 244 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document, |
240 std::string(), | 245 std::string(), |
241 blink::WebSandboxFlags::None); | 246 blink::WebSandboxFlags::None); |
242 FrameTreeNode* child0 = root->child_at(0); | 247 FrameTreeNode* child0 = root->child_at(0); |
243 FrameTreeNode* child1 = root->child_at(1); | 248 FrameTreeNode* child1 = root->child_at(1); |
244 | 249 |
(...skipping 29 matching lines...) Expand all Loading... | |
274 EXPECT_EQ(child1, frame_tree->FindByName("child1")); | 279 EXPECT_EQ(child1, frame_tree->FindByName("child1")); |
275 EXPECT_EQ(grandchild, frame_tree->FindByName("grandchild")); | 280 EXPECT_EQ(grandchild, frame_tree->FindByName("grandchild")); |
276 EXPECT_EQ(nullptr, frame_tree->FindByName("no such frame")); | 281 EXPECT_EQ(nullptr, frame_tree->FindByName("no such frame")); |
277 } | 282 } |
278 | 283 |
279 // Check that PreviousSibling() is retrieved correctly. | 284 // Check that PreviousSibling() is retrieved correctly. |
280 TEST_F(FrameTreeTest, PreviousSibling) { | 285 TEST_F(FrameTreeTest, PreviousSibling) { |
281 // Add a few child frames to the main frame. | 286 // Add a few child frames to the main frame. |
282 FrameTree* frame_tree = contents()->GetFrameTree(); | 287 FrameTree* frame_tree = contents()->GetFrameTree(); |
283 FrameTreeNode* root = frame_tree->root(); | 288 FrameTreeNode* root = frame_tree->root(); |
289 test_rvh()->CreateRenderView(base::string16(), MSG_ROUTING_NONE, | |
290 MSG_ROUTING_NONE, -1, FrameReplicationState(), | |
291 false); | |
284 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, | 292 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, |
285 "child0", blink::WebSandboxFlags::None); | 293 "child0", blink::WebSandboxFlags::None); |
286 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, | 294 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, |
287 "child1", blink::WebSandboxFlags::None); | 295 "child1", blink::WebSandboxFlags::None); |
288 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document, | 296 main_test_rfh()->OnCreateChildFrame(24, blink::WebTreeScopeType::Document, |
289 "child2", blink::WebSandboxFlags::None); | 297 "child2", blink::WebSandboxFlags::None); |
290 FrameTreeNode* child0 = root->child_at(0); | 298 FrameTreeNode* child0 = root->child_at(0); |
291 FrameTreeNode* child1 = root->child_at(1); | 299 FrameTreeNode* child1 = root->child_at(1); |
292 FrameTreeNode* child2 = root->child_at(2); | 300 FrameTreeNode* child2 = root->child_at(2); |
293 | 301 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 blink::WebSandboxFlags::None)); | 391 blink::WebSandboxFlags::None)); |
384 ASSERT_EQ("1: []", GetTreeState(frame_tree)); | 392 ASSERT_EQ("1: []", GetTreeState(frame_tree)); |
385 } | 393 } |
386 | 394 |
387 // Ensure that frames removed while a process has crashed are not preserved in | 395 // Ensure that frames removed while a process has crashed are not preserved in |
388 // the global map of id->frame. | 396 // the global map of id->frame. |
389 TEST_F(FrameTreeTest, ProcessCrashClearsGlobalMap) { | 397 TEST_F(FrameTreeTest, ProcessCrashClearsGlobalMap) { |
390 // Add a couple child frames to the main frame. | 398 // Add a couple child frames to the main frame. |
391 FrameTreeNode* root = contents()->GetFrameTree()->root(); | 399 FrameTreeNode* root = contents()->GetFrameTree()->root(); |
392 | 400 |
401 test_rvh()->CreateRenderView(base::string16(), MSG_ROUTING_NONE, | |
402 MSG_ROUTING_NONE, -1, FrameReplicationState(), | |
403 false); | |
404 | |
393 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, | 405 main_test_rfh()->OnCreateChildFrame(22, blink::WebTreeScopeType::Document, |
394 std::string(), | 406 std::string(), |
395 blink::WebSandboxFlags::None); | 407 blink::WebSandboxFlags::None); |
396 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, | 408 main_test_rfh()->OnCreateChildFrame(23, blink::WebTreeScopeType::Document, |
397 std::string(), | 409 std::string(), |
398 blink::WebSandboxFlags::None); | 410 blink::WebSandboxFlags::None); |
399 | 411 |
400 // Add one grandchild frame. | 412 // Add one grandchild frame. |
401 RenderFrameHostImpl* child1_rfh = root->child_at(0)->current_frame_host(); | 413 RenderFrameHostImpl* child1_rfh = root->child_at(0)->current_frame_host(); |
402 child1_rfh->OnCreateChildFrame(33, blink::WebTreeScopeType::Document, | 414 child1_rfh->OnCreateChildFrame(33, blink::WebTreeScopeType::Document, |
(...skipping 10 matching lines...) Expand all Loading... | |
413 // Crash the renderer. | 425 // Crash the renderer. |
414 main_test_rfh()->GetProcess()->SimulateCrash(); | 426 main_test_rfh()->GetProcess()->SimulateCrash(); |
415 | 427 |
416 // Ensure they cannot be found by id after the process has crashed. | 428 // Ensure they cannot be found by id after the process has crashed. |
417 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id1)); | 429 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id1)); |
418 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id2)); | 430 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id2)); |
419 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id3)); | 431 EXPECT_FALSE(FrameTreeNode::GloballyFindByID(id3)); |
420 } | 432 } |
421 | 433 |
422 } // namespace content | 434 } // namespace content |
OLD | NEW |