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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 345823002: Move ownership of ChildFrameCompositingHelper from frame to proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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
OLDNEW
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 "content/browser/frame_host/cross_process_frame_connector.h"
7 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/render_frame_proxy_host.h"
10 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 11 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
15 #include "content/public/test/browser_test_utils.h" 18 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/content_browser_test.h" 19 #include "content/public/test/content_browser_test.h"
17 #include "content/public/test/content_browser_test_utils.h" 20 #include "content/public/test/content_browser_test_utils.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 NavigateToURL(shell(), main_url); 208 NavigateToURL(shell(), main_url);
206 209
207 // It is safe to obtain the root frame tree node here, as it doesn't change. 210 // It is safe to obtain the root frame tree node here, as it doesn't change.
208 FrameTreeNode* root = 211 FrameTreeNode* root =
209 static_cast<WebContentsImpl*>(shell()->web_contents())-> 212 static_cast<WebContentsImpl*>(shell()->web_contents())->
210 GetFrameTree()->root(); 213 GetFrameTree()->root();
211 214
212 SitePerProcessWebContentsObserver observer(shell()->web_contents()); 215 SitePerProcessWebContentsObserver observer(shell()->web_contents());
213 216
214 // Load same-site page into iframe. 217 // Load same-site page into iframe.
218 FrameTreeNode* child = root->child_at(0);
215 GURL http_url(test_server()->GetURL("files/title1.html")); 219 GURL http_url(test_server()->GetURL("files/title1.html"));
216 NavigateFrameToURL(root->child_at(0), http_url); 220 NavigateFrameToURL(child, http_url);
217 EXPECT_EQ(http_url, observer.navigation_url()); 221 EXPECT_EQ(http_url, observer.navigation_url());
218 EXPECT_TRUE(observer.navigation_succeeded()); 222 EXPECT_TRUE(observer.navigation_succeeded());
219 { 223 {
220 // There should be only one RenderWidgetHost when there are no 224 // There should be only one RenderWidgetHost when there are no
221 // cross-process iframes. 225 // cross-process iframes.
222 std::set<RenderWidgetHostView*> views_set = 226 std::set<RenderWidgetHostView*> views_set =
223 static_cast<WebContentsImpl*>(shell()->web_contents()) 227 static_cast<WebContentsImpl*>(shell()->web_contents())
224 ->GetRenderWidgetHostViewsInTree(); 228 ->GetRenderWidgetHostViewsInTree();
225 EXPECT_EQ(1U, views_set.size()); 229 EXPECT_EQ(1U, views_set.size());
226 } 230 }
231 RenderFrameProxyHost* proxy_to_parent =
232 child->render_manager()->GetRenderFrameProxyHost(
233 shell()->web_contents()->GetSiteInstance());
234 EXPECT_FALSE(proxy_to_parent);
227 235
228 // These must stay in scope with replace_host. 236 // These must stay in scope with replace_host.
229 GURL::Replacements replace_host; 237 GURL::Replacements replace_host;
230 std::string foo_com("foo.com"); 238 std::string foo_com("foo.com");
231 239
232 // Load cross-site page into iframe. 240 // Load cross-site page into iframe.
233 GURL cross_site_url(test_server()->GetURL("files/title2.html")); 241 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
234 replace_host.SetHostStr(foo_com); 242 replace_host.SetHostStr(foo_com);
235 cross_site_url = cross_site_url.ReplaceComponents(replace_host); 243 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
236 NavigateFrameToURL(root->child_at(0), cross_site_url); 244 NavigateFrameToURL(root->child_at(0), cross_site_url);
237 EXPECT_EQ(cross_site_url, observer.navigation_url()); 245 EXPECT_EQ(cross_site_url, observer.navigation_url());
238 EXPECT_TRUE(observer.navigation_succeeded()); 246 EXPECT_TRUE(observer.navigation_succeeded());
239 247
240 // Ensure that we have created a new process for the subframe. 248 // Ensure that we have created a new process for the subframe.
241 ASSERT_EQ(1U, root->child_count()); 249 ASSERT_EQ(1U, root->child_count());
242 FrameTreeNode* child = root->child_at(0);
243 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); 250 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
244 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); 251 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
245 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); 252 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
246 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); 253 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
247 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); 254 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
248 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); 255 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
249 { 256 {
250 // There should be now two RenderWidgetHosts, one for each process 257 // There should be now two RenderWidgetHosts, one for each process
251 // rendering a frame. 258 // rendering a frame.
252 std::set<RenderWidgetHostView*> views_set = 259 std::set<RenderWidgetHostView*> views_set =
253 static_cast<WebContentsImpl*>(shell()->web_contents()) 260 static_cast<WebContentsImpl*>(shell()->web_contents())
254 ->GetRenderWidgetHostViewsInTree(); 261 ->GetRenderWidgetHostViewsInTree();
255 EXPECT_EQ(2U, views_set.size()); 262 EXPECT_EQ(2U, views_set.size());
256 } 263 }
264 proxy_to_parent = child->render_manager()->GetProxyToParent();
265 EXPECT_TRUE(proxy_to_parent);
266 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
267 EXPECT_EQ(
268 rvh->GetView(),
269 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
257 270
258 // Load another cross-site page into the same iframe. 271 // Load another cross-site page into the same iframe.
259 cross_site_url = test_server()->GetURL("files/title3.html"); 272 cross_site_url = test_server()->GetURL("files/title3.html");
260 std::string bar_com("bar.com"); 273 std::string bar_com("bar.com");
261 replace_host.SetHostStr(bar_com); 274 replace_host.SetHostStr(bar_com);
262 cross_site_url = cross_site_url.ReplaceComponents(replace_host); 275 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
263 NavigateFrameToURL(root->child_at(0), cross_site_url); 276 NavigateFrameToURL(root->child_at(0), cross_site_url);
264 EXPECT_EQ(cross_site_url, observer.navigation_url()); 277 EXPECT_EQ(cross_site_url, observer.navigation_url());
265 EXPECT_TRUE(observer.navigation_succeeded()); 278 EXPECT_TRUE(observer.navigation_succeeded());
266 279
(...skipping 10 matching lines...) Expand all
277 child->current_frame_host()->GetSiteInstance()); 290 child->current_frame_host()->GetSiteInstance());
278 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), 291 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(),
279 child->current_frame_host()->GetProcess()); 292 child->current_frame_host()->GetProcess());
280 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); 293 EXPECT_NE(rph, child->current_frame_host()->GetProcess());
281 { 294 {
282 std::set<RenderWidgetHostView*> views_set = 295 std::set<RenderWidgetHostView*> views_set =
283 static_cast<WebContentsImpl*>(shell()->web_contents()) 296 static_cast<WebContentsImpl*>(shell()->web_contents())
284 ->GetRenderWidgetHostViewsInTree(); 297 ->GetRenderWidgetHostViewsInTree();
285 EXPECT_EQ(2U, views_set.size()); 298 EXPECT_EQ(2U, views_set.size());
286 } 299 }
300 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent());
301 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
302 EXPECT_EQ(
303 child->current_frame_host()->render_view_host()->GetView(),
304 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
287 } 305 }
288 306
289 // Crash a subframe and ensures its children are cleared from the FrameTree. 307 // Crash a subframe and ensures its children are cleared from the FrameTree.
290 // See http://crbug.com/338508. 308 // See http://crbug.com/338508.
291 // TODO(creis): Enable this on Android when we can kill the process there. 309 // TODO(creis): Enable this on Android when we can kill the process there.
292 #if defined(OS_ANDROID) 310 #if defined(OS_ANDROID)
293 #define MAYBE_CrashSubframe DISABLED_CrashSubframe 311 #define MAYBE_CrashSubframe DISABLED_CrashSubframe
294 #else 312 #else
295 #define MAYBE_CrashSubframe CrashSubframe 313 #define MAYBE_CrashSubframe CrashSubframe
296 #endif 314 #endif
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 "server-redirect?" + client_redirect_http_url.spec())); 571 "server-redirect?" + client_redirect_http_url.spec()));
554 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 572 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
555 573
556 // DidFailProvisionalLoad when navigating to client_redirect_http_url. 574 // DidFailProvisionalLoad when navigating to client_redirect_http_url.
557 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 575 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
558 EXPECT_FALSE(observer.navigation_succeeded()); 576 EXPECT_FALSE(observer.navigation_succeeded());
559 } 577 }
560 } 578 }
561 579
562 } // namespace content 580 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698