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

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

Issue 248963007: Perform navigation policy check on UI thread for --site-per-process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some minor cleanup. Created 6 years, 8 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/frame_tree.h" 7 #include "content/browser/frame_host/frame_tree.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/notification_observer.h" 10 #include "content/public/browser/notification_observer.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 }; 197 };
198 198
199 // Ensure that we can complete a cross-process subframe navigation. 199 // Ensure that we can complete a cross-process subframe navigation.
200 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { 200 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) {
201 host_resolver()->AddRule("*", "127.0.0.1"); 201 host_resolver()->AddRule("*", "127.0.0.1");
202 ASSERT_TRUE(test_server()->Start()); 202 ASSERT_TRUE(test_server()->Start());
203 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); 203 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
204 NavigateToURL(shell(), main_url); 204 NavigateToURL(shell(), main_url);
205 205
206 StartFrameAtDataURL(); 206 // It is safe to obtain the root frame tree node here, as it doesn't change.
Charlie Reis 2014/04/24 20:37:50 Interesting. This isn't required anymore? Is tha
nasko 2014/04/24 22:31:12 It isn't needed since we don't listen for NavEntry
207 FrameTreeNode* root =
208 static_cast<WebContentsImpl*>(shell()->web_contents())->
209 GetFrameTree()->root();
207 210
208 SitePerProcessWebContentsObserver observer(shell()->web_contents()); 211 SitePerProcessWebContentsObserver observer(shell()->web_contents());
209 212
210 // Load same-site page into iframe. 213 // Load same-site page into iframe.
211 GURL http_url(test_server()->GetURL("files/title1.html")); 214 GURL http_url(test_server()->GetURL("files/title1.html"));
212 EXPECT_TRUE(NavigateIframeToURL(shell(), http_url, "test")); 215 NavigateFrameToURL(root->child_at(0)->current_frame_host(), http_url);
213 EXPECT_EQ(http_url, observer.navigation_url()); 216 EXPECT_EQ(http_url, observer.navigation_url());
214 EXPECT_TRUE(observer.navigation_succeeded()); 217 EXPECT_TRUE(observer.navigation_succeeded());
215 218
216 // These must stay in scope with replace_host. 219 // These must stay in scope with replace_host.
217 GURL::Replacements replace_host; 220 GURL::Replacements replace_host;
218 std::string foo_com("foo.com"); 221 std::string foo_com("foo.com");
219 222
220 // Load cross-site page into iframe. 223 // Load cross-site page into iframe.
221 GURL cross_site_url(test_server()->GetURL("files/title2.html")); 224 GURL cross_site_url(test_server()->GetURL("files/title2.html"));
222 replace_host.SetHostStr(foo_com); 225 replace_host.SetHostStr(foo_com);
223 cross_site_url = cross_site_url.ReplaceComponents(replace_host); 226 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
224 EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); 227 NavigateFrameToURL(root->child_at(0)->current_frame_host(), cross_site_url);
225 EXPECT_EQ(cross_site_url, observer.navigation_url()); 228 EXPECT_EQ(cross_site_url, observer.navigation_url());
226 EXPECT_TRUE(observer.navigation_succeeded()); 229 EXPECT_TRUE(observer.navigation_succeeded());
227 230
228 // Ensure that we have created a new process for the subframe. 231 // Ensure that we have created a new process for the subframe.
229 FrameTreeNode* root =
230 static_cast<WebContentsImpl*>(shell()->web_contents())->
231 GetFrameTree()->root();
232 ASSERT_EQ(1U, root->child_count()); 232 ASSERT_EQ(1U, root->child_count());
233 FrameTreeNode* child = root->child_at(0); 233 FrameTreeNode* child = root->child_at(0);
234 SiteInstance* site_instance =
235 child->current_frame_host()->render_view_host()->GetSiteInstance();
Charlie Reis 2014/04/24 20:37:50 nit: Wrong indent. Also, RenderFrameHostImpl has
nasko 2014/04/24 22:31:12 Done.
236 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
237 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
238 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
239 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
240 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
241
242 // Load another cross-site page into the same iframe.
243 cross_site_url = test_server()->GetURL("files/title3.html");
244 std::string bar_com("bar.com");
245 replace_host.SetHostStr(bar_com);
246 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
247 NavigateFrameToURL(root->child_at(0)->current_frame_host(), cross_site_url);
248 EXPECT_EQ(cross_site_url, observer.navigation_url());
249 EXPECT_TRUE(observer.navigation_succeeded());
250
251 // Check again that a new process is created and is different from the
252 // top level one and the previous one.
253 ASSERT_EQ(1U, root->child_count());
254 child = root->child_at(0);
234 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), 255 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(),
235 child->current_frame_host()->render_view_host()); 256 child->current_frame_host()->render_view_host());
257 EXPECT_NE(rvh, child->current_frame_host()->render_view_host());
236 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 258 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
237 child->current_frame_host()->render_view_host()->GetSiteInstance()); 259 child->current_frame_host()->render_view_host()->GetSiteInstance());
260 EXPECT_NE(site_instance,
261 child->current_frame_host()->render_view_host()->GetSiteInstance());
Charlie Reis 2014/04/24 20:37:50 nit: Drop render_view_host()
nasko 2014/04/24 22:31:12 Done.
238 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), 262 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(),
239 child->current_frame_host()->GetProcess()); 263 child->current_frame_host()->GetProcess());
264 EXPECT_NE(rph, child->current_frame_host()->GetProcess());
265
240 } 266 }
241 267
242 // Crash a subframe and ensures its children are cleared from the FrameTree. 268 // Crash a subframe and ensures its children are cleared from the FrameTree.
243 // See http://crbug.com/338508. 269 // See http://crbug.com/338508.
244 // TODO(creis): Enable this on Android when we can kill the process there. 270 // TODO(creis): Enable this on Android when we can kill the process there.
245 #if defined(OS_ANDROID) 271 #if defined(OS_ANDROID)
246 #define MAYBE_CrashSubframe DISABLED_CrashSubframe 272 #define MAYBE_CrashSubframe DISABLED_CrashSubframe
247 #else 273 #else
248 #define MAYBE_CrashSubframe CrashSubframe 274 #define MAYBE_CrashSubframe CrashSubframe
249 #endif 275 #endif
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 "server-redirect?" + client_redirect_http_url.spec())); 532 "server-redirect?" + client_redirect_http_url.spec()));
507 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 533 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
508 534
509 // DidFailProvisionalLoad when navigating to client_redirect_http_url. 535 // DidFailProvisionalLoad when navigating to client_redirect_http_url.
510 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 536 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
511 EXPECT_FALSE(observer.navigation_succeeded()); 537 EXPECT_FALSE(observer.navigation_succeeded());
512 } 538 }
513 } 539 }
514 540
515 } // namespace content 541 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698