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

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

Issue 444503002: Start using RenderFrameProxyHost objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create view IFF frame is main frame Created 6 years, 4 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
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 "base/command_line.h"
5 #include "content/browser/frame_host/frame_tree.h" 6 #include "content/browser/frame_host/frame_tree.h"
6 #include "content/browser/frame_host/frame_tree_node.h" 7 #include "content/browser/frame_host/frame_tree_node.h"
7 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 11 #include "content/public/browser/notification_types.h"
12 #include "content/public/common/content_switches.h"
11 #include "content/public/common/url_constants.h" 13 #include "content/public/common/url_constants.h"
12 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
16 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
17 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
20 #include "content/test/content_browser_test_utils_internal.h"
18 #include "net/dns/mock_host_resolver.h" 21 #include "net/dns/mock_host_resolver.h"
19 22
20 namespace content { 23 namespace content {
21 24
22 class FrameTreeBrowserTest : public ContentBrowserTest { 25 class FrameTreeBrowserTest : public ContentBrowserTest {
23 public: 26 public:
24 FrameTreeBrowserTest() {} 27 FrameTreeBrowserTest() {}
25 28
26 private: 29 private:
27 DISALLOW_COPY_AND_ASSIGN(FrameTreeBrowserTest); 30 DISALLOW_COPY_AND_ASSIGN(FrameTreeBrowserTest);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to 151 // Navigate to a new URL. We use LoadURL because NavigateToURL will try to
149 // wait for the previous navigation to stop. 152 // wait for the previous navigation to stop.
150 TestNavigationObserver tab_observer(wc, 1); 153 TestNavigationObserver tab_observer(wc, 1);
151 shell()->LoadURL(base_url.Resolve("blank.html")); 154 shell()->LoadURL(base_url.Resolve("blank.html"));
152 tab_observer.Wait(); 155 tab_observer.Wait();
153 156
154 // The frame tree should now be cleared. 157 // The frame tree should now be cleared.
155 EXPECT_EQ(0UL, root->child_count()); 158 EXPECT_EQ(0UL, root->child_count());
156 } 159 }
157 160
161 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest {
162 public:
163 CrossProcessFrameTreeBrowserTest() {}
164
165 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE {
166 command_line->AppendSwitch(switches::kSitePerProcess);
167 }
168
169 private:
170 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest);
171 };
172
173 // Ensure that we can complete a cross-process subframe navigation.
174 #if defined(OS_ANDROID)
175 #define MAYBE_CreateCrossProcessSubframeProxies DISABLED_CreateCrossProcessSubfr ameProxies
176 #else
177 #define MAYBE_CreateCrossProcessSubframeProxies CreateCrossProcessSubframeProxie s
178 #endif
179 IN_PROC_BROWSER_TEST_F(CrossProcessFrameTreeBrowserTest,
180 MAYBE_CreateCrossProcessSubframeProxies) {
181 host_resolver()->AddRule("*", "127.0.0.1");
182 ASSERT_TRUE(test_server()->Start());
183 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
184 NavigateToURL(shell(), main_url);
185
186 // It is safe to obtain the root frame tree node here, as it doesn't change.
187 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
188 ->GetFrameTree()->root();
189
190 // Load same-site page into iframe.
191 GURL http_url(test_server()->GetURL("files/title1.html"));
192 NavigateFrameToURL(root->child_at(0), http_url);
193
194 // These must stay in scope with replace_host.
195 GURL::Replacements replace_host;
196 std::string foo_com("foo.com");
197
198 // Load cross-site page into iframe.
199 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
200 replace_host.SetHostStr(foo_com);
201 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
202 NavigateFrameToURL(root->child_at(0), cross_site_url);
203
204 // Ensure that we have created a new process for the subframe.
205 ASSERT_EQ(1U, root->child_count());
206 FrameTreeNode* child = root->child_at(0);
207 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
208 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
209 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
210
211 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
212 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
213 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
214
215 // Ensure that the root node has a proxy for the child node's SiteInstance.
216 EXPECT_TRUE(root->render_manager()->proxy_hosts_[site_instance->GetId()]);
217
218 // Also ensure that the child has a proxy for the root node's SiteInstance.
219 EXPECT_TRUE(child->render_manager()->proxy_hosts_[
220 root->current_frame_host()->GetSiteInstance()->GetId()]);
221 }
222
158 } // namespace content 223 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree.cc ('k') | content/browser/frame_host/navigation_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698