| OLD | NEW | 
|---|
| 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/command_line.h" | 5 #include "base/command_line.h" | 
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" | 
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" | 
| 8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" | 
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" | 
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 413   std::string host_str("A.com");  // Must stay in scope with replace_host. | 413   std::string host_str("A.com");  // Must stay in scope with replace_host. | 
| 414   replace_host.SetHostStr(host_str); | 414   replace_host.SetHostStr(host_str); | 
| 415   base_url = base_url.ReplaceComponents(replace_host); | 415   base_url = base_url.ReplaceComponents(replace_host); | 
| 416 | 416 | 
| 417   // Load doc without iframes. Verify FrameTree just has root. | 417   // Load doc without iframes. Verify FrameTree just has root. | 
| 418   // Frame tree: | 418   // Frame tree: | 
| 419   //   Site-A Root | 419   //   Site-A Root | 
| 420   NavigateToURL(shell(), base_url.Resolve("blank.html")); | 420   NavigateToURL(shell(), base_url.Resolve("blank.html")); | 
| 421   FrameTreeNode* root = | 421   FrameTreeNode* root = | 
| 422       static_cast<WebContentsImpl*>(shell()->web_contents())-> | 422       static_cast<WebContentsImpl*>(shell()->web_contents())-> | 
| 423       GetFrameTree()->GetRootForTesting(); | 423       GetFrameTree()->root(); | 
| 424   EXPECT_EQ(0U, root->child_count()); | 424   EXPECT_EQ(0U, root->child_count()); | 
| 425 | 425 | 
| 426   // Add 2 same-site frames. Verify 3 nodes in tree with proper names. | 426   // Add 2 same-site frames. Verify 3 nodes in tree with proper names. | 
| 427   // Frame tree: | 427   // Frame tree: | 
| 428   //   Site-A Root -- Site-A frame1 | 428   //   Site-A Root -- Site-A frame1 | 
| 429   //              \-- Site-A frame2 | 429   //              \-- Site-A frame2 | 
| 430   WindowedNotificationObserver observer1( | 430   WindowedNotificationObserver observer1( | 
| 431       content::NOTIFICATION_LOAD_STOP, | 431       content::NOTIFICATION_LOAD_STOP, | 
| 432       content::Source<NavigationController>( | 432       content::Source<NavigationController>( | 
| 433           &shell()->web_contents()->GetController())); | 433           &shell()->web_contents()->GetController())); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 444                        FrameTreeShape2) { | 444                        FrameTreeShape2) { | 
| 445   host_resolver()->AddRule("*", "127.0.0.1"); | 445   host_resolver()->AddRule("*", "127.0.0.1"); | 
| 446   ASSERT_TRUE(test_server()->Start()); | 446   ASSERT_TRUE(test_server()->Start()); | 
| 447 | 447 | 
| 448   NavigateToURL(shell(), | 448   NavigateToURL(shell(), | 
| 449                 test_server()->GetURL("files/frame_tree/top.html")); | 449                 test_server()->GetURL("files/frame_tree/top.html")); | 
| 450 | 450 | 
| 451   WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); | 451   WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); | 
| 452   RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 452   RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 
| 453       wc->GetRenderViewHost()); | 453       wc->GetRenderViewHost()); | 
| 454   FrameTreeNode* root = wc->GetFrameTree()->GetRootForTesting(); | 454   FrameTreeNode* root = wc->GetFrameTree()->root(); | 
| 455 | 455 | 
| 456   // Check that the root node is properly created with the frame id of the | 456   // Check that the root node is properly created with the frame id of the | 
| 457   // initial navigation. | 457   // initial navigation. | 
| 458   ASSERT_EQ(3UL, root->child_count()); | 458   ASSERT_EQ(3UL, root->child_count()); | 
| 459   EXPECT_EQ(std::string(), root->frame_name()); | 459   EXPECT_EQ(std::string(), root->frame_name()); | 
| 460   EXPECT_EQ(rvh->main_frame_id(), root->frame_id()); | 460   EXPECT_EQ(rvh->main_frame_id(), root->frame_id()); | 
| 461 | 461 | 
| 462   ASSERT_EQ(2UL, root->child_at(0)->child_count()); | 462   ASSERT_EQ(2UL, root->child_at(0)->child_count()); | 
| 463   EXPECT_STREQ("1-1-name", root->child_at(0)->frame_name().c_str()); | 463   EXPECT_STREQ("1-1-name", root->child_at(0)->frame_name().c_str()); | 
| 464 | 464 | 
| 465   // Verify the deepest node exists and has the right name. | 465   // Verify the deepest node exists and has the right name. | 
| 466   ASSERT_EQ(2UL, root->child_at(2)->child_count()); | 466   ASSERT_EQ(2UL, root->child_at(2)->child_count()); | 
| 467   EXPECT_EQ(1UL, root->child_at(2)->child_at(1)->child_count()); | 467   EXPECT_EQ(1UL, root->child_at(2)->child_at(1)->child_count()); | 
| 468   EXPECT_EQ(0UL, root->child_at(2)->child_at(1)->child_at(0)->child_count()); | 468   EXPECT_EQ(0UL, root->child_at(2)->child_at(1)->child_at(0)->child_count()); | 
| 469   EXPECT_STREQ("3-1-id", | 469   EXPECT_STREQ("3-1-id", | 
| 470       root->child_at(2)->child_at(1)->child_at(0)->frame_name().c_str()); | 470       root->child_at(2)->child_at(1)->child_at(0)->frame_name().c_str()); | 
| 471 | 471 | 
| 472   // Navigate to about:blank, which should leave only the root node of the frame | 472   // Navigate to about:blank, which should leave only the root node of the frame | 
| 473   // tree in the browser process. | 473   // tree in the browser process. | 
| 474   NavigateToURL(shell(), test_server()->GetURL("files/title1.html")); | 474   NavigateToURL(shell(), test_server()->GetURL("files/title1.html")); | 
| 475 | 475 | 
| 476   root = wc->GetFrameTree()->GetRootForTesting(); | 476   root = wc->GetFrameTree()->root(); | 
| 477   EXPECT_EQ(0UL, root->child_count()); | 477   EXPECT_EQ(0UL, root->child_count()); | 
| 478   EXPECT_EQ(std::string(), root->frame_name()); | 478   EXPECT_EQ(std::string(), root->frame_name()); | 
| 479   EXPECT_EQ(rvh->main_frame_id(), root->frame_id()); | 479   EXPECT_EQ(rvh->main_frame_id(), root->frame_id()); | 
| 480 } | 480 } | 
| 481 | 481 | 
| 482 }  // namespace content | 482 }  // namespace content | 
| OLD | NEW | 
|---|