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

Side by Side Diff: content/browser/frame_host/frame_tree_browsertest.cc

Issue 172063002: Unify frame IDs with RenderFrameHost routing IDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix type Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/frame_host/frame_tree.cc ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/browser/frame_host/frame_tree_node.h" 6 #include "content/browser/frame_host/frame_tree_node.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 7 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 10 #include "content/public/browser/notification_types.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 63 }
64 64
65 // TODO(ajwong): Talk with nasko and merge this functionality with 65 // TODO(ajwong): Talk with nasko and merge this functionality with
66 // FrameTreeShape. 66 // FrameTreeShape.
67 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, FrameTreeShape2) { 67 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, FrameTreeShape2) {
68 ASSERT_TRUE(test_server()->Start()); 68 ASSERT_TRUE(test_server()->Start());
69 NavigateToURL(shell(), 69 NavigateToURL(shell(),
70 test_server()->GetURL("files/frame_tree/top.html")); 70 test_server()->GetURL("files/frame_tree/top.html"));
71 71
72 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); 72 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
73 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
74 wc->GetRenderViewHost());
75 FrameTreeNode* root = wc->GetFrameTree()->root(); 73 FrameTreeNode* root = wc->GetFrameTree()->root();
76 74
77 // Check that the root node is properly created with the frame id of the 75 // Check that the root node is properly created.
78 // initial navigation.
79 ASSERT_EQ(3UL, root->child_count()); 76 ASSERT_EQ(3UL, root->child_count());
80 EXPECT_EQ(std::string(), root->frame_name()); 77 EXPECT_EQ(std::string(), root->frame_name());
81 EXPECT_EQ(rvh->main_frame_id(), root->frame_id());
82 78
83 ASSERT_EQ(2UL, root->child_at(0)->child_count()); 79 ASSERT_EQ(2UL, root->child_at(0)->child_count());
84 EXPECT_STREQ("1-1-name", root->child_at(0)->frame_name().c_str()); 80 EXPECT_STREQ("1-1-name", root->child_at(0)->frame_name().c_str());
85 81
86 // Verify the deepest node exists and has the right name. 82 // Verify the deepest node exists and has the right name.
87 ASSERT_EQ(2UL, root->child_at(2)->child_count()); 83 ASSERT_EQ(2UL, root->child_at(2)->child_count());
88 EXPECT_EQ(1UL, root->child_at(2)->child_at(1)->child_count()); 84 EXPECT_EQ(1UL, root->child_at(2)->child_at(1)->child_count());
89 EXPECT_EQ(0UL, root->child_at(2)->child_at(1)->child_at(0)->child_count()); 85 EXPECT_EQ(0UL, root->child_at(2)->child_at(1)->child_at(0)->child_count());
90 EXPECT_STREQ("3-1-id", 86 EXPECT_STREQ("3-1-id",
91 root->child_at(2)->child_at(1)->child_at(0)->frame_name().c_str()); 87 root->child_at(2)->child_at(1)->child_at(0)->frame_name().c_str());
92 88
93 // Navigate to about:blank, which should leave only the root node of the frame 89 // Navigate to about:blank, which should leave only the root node of the frame
94 // tree in the browser process. 90 // tree in the browser process.
95 NavigateToURL(shell(), test_server()->GetURL("files/title1.html")); 91 NavigateToURL(shell(), test_server()->GetURL("files/title1.html"));
96 92
97 root = wc->GetFrameTree()->root(); 93 root = wc->GetFrameTree()->root();
98 EXPECT_EQ(0UL, root->child_count()); 94 EXPECT_EQ(0UL, root->child_count());
99 EXPECT_EQ(std::string(), root->frame_name()); 95 EXPECT_EQ(std::string(), root->frame_name());
100 EXPECT_EQ(rvh->main_frame_id(), root->frame_id());
101 } 96 }
102 97
103 // Test that we can navigate away if the previous renderer doesn't clean up its 98 // Test that we can navigate away if the previous renderer doesn't clean up its
104 // child frames. 99 // child frames.
105 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, FrameTreeAfterCrash) { 100 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, FrameTreeAfterCrash) {
106 ASSERT_TRUE(test_server()->Start()); 101 ASSERT_TRUE(test_server()->Start());
107 NavigateToURL(shell(), 102 NavigateToURL(shell(),
108 test_server()->GetURL("files/frame_tree/top.html")); 103 test_server()->GetURL("files/frame_tree/top.html"));
109 104
110 // Crash the renderer so that it doesn't send any FrameDetached messages. 105 // Crash the renderer so that it doesn't send any FrameDetached messages.
111 RenderProcessHostWatcher crash_observer( 106 RenderProcessHostWatcher crash_observer(
112 shell()->web_contents(), 107 shell()->web_contents(),
113 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 108 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
114 NavigateToURL(shell(), GURL(kChromeUICrashURL)); 109 NavigateToURL(shell(), GURL(kChromeUICrashURL));
115 crash_observer.Wait(); 110 crash_observer.Wait();
116 111
117 // The frame tree should be cleared, and the frame ID should be reset. 112 // The frame tree should be cleared.
118 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); 113 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
119 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
120 wc->GetRenderViewHost());
121 FrameTreeNode* root = wc->GetFrameTree()->root(); 114 FrameTreeNode* root = wc->GetFrameTree()->root();
122 EXPECT_EQ(0UL, root->child_count()); 115 EXPECT_EQ(0UL, root->child_count());
123 EXPECT_EQ(FrameTreeNode::kInvalidFrameId, root->frame_id());
124 EXPECT_EQ(rvh->main_frame_id(), root->frame_id());
125 116
126 // Navigate to a new URL. 117 // Navigate to a new URL.
127 NavigateToURL(shell(), test_server()->GetURL("files/title1.html")); 118 GURL url(test_server()->GetURL("files/title1.html"));
128 119 NavigateToURL(shell(), url);
129 // The frame ID should now be set.
130 EXPECT_EQ(0UL, root->child_count()); 120 EXPECT_EQ(0UL, root->child_count());
131 EXPECT_NE(FrameTreeNode::kInvalidFrameId, root->frame_id()); 121 EXPECT_EQ(url, root->current_url());
132 EXPECT_EQ(rvh->main_frame_id(), root->frame_id());
133 } 122 }
134 123
135 // Test that we can navigate away if the previous renderer doesn't clean up its 124 // Test that we can navigate away if the previous renderer doesn't clean up its
136 // child frames. 125 // child frames.
137 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, NavigateWithLeftoverFrames) { 126 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, NavigateWithLeftoverFrames) {
138 host_resolver()->AddRule("*", "127.0.0.1"); 127 host_resolver()->AddRule("*", "127.0.0.1");
139 ASSERT_TRUE(test_server()->Start()); 128 ASSERT_TRUE(test_server()->Start());
140 129
141 GURL base_url = test_server()->GetURL("files/site_isolation/"); 130 GURL base_url = test_server()->GetURL("files/site_isolation/");
142 GURL::Replacements replace_host; 131 GURL::Replacements replace_host;
(...skipping 12 matching lines...) Expand all
155 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents()); 144 WebContentsImpl* wc = static_cast<WebContentsImpl*>(shell()->web_contents());
156 FrameTreeNode* root = wc->GetFrameTree()->root(); 145 FrameTreeNode* root = wc->GetFrameTree()->root();
157 ASSERT_EQ(3UL, root->child_count()); 146 ASSERT_EQ(3UL, root->child_count());
158 147
159 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to 148 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to
160 // wait for the previous navigation to stop. 149 // wait for the previous navigation to stop.
161 TestNavigationObserver tab_observer(wc, 1); 150 TestNavigationObserver tab_observer(wc, 1);
162 shell()->LoadURL(base_url.Resolve("blank.html")); 151 shell()->LoadURL(base_url.Resolve("blank.html"));
163 tab_observer.Wait(); 152 tab_observer.Wait();
164 153
165 // The frame tree should now be cleared, and the frame ID should be valid. 154 // The frame tree should now be cleared.
166 EXPECT_EQ(0UL, root->child_count()); 155 EXPECT_EQ(0UL, root->child_count());
167 EXPECT_NE(FrameTreeNode::kInvalidFrameId, root->frame_id());
168 } 156 }
169 157
170 } // namespace content 158 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.cc ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698