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

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: Changes based on Charlie's review. 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.
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), 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), 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 = child->current_frame_host()->GetSiteInstance();
235 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
236 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
237 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
238 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
239 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
240
241 // Load another cross-site page into the same iframe.
242 cross_site_url = test_server()->GetURL("files/title3.html");
243 std::string bar_com("bar.com");
244 replace_host.SetHostStr(bar_com);
245 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
246 NavigateFrameToURL(root->child_at(0), cross_site_url);
247 EXPECT_EQ(cross_site_url, observer.navigation_url());
248 EXPECT_TRUE(observer.navigation_succeeded());
249
250 // Check again that a new process is created and is different from the
251 // top level one and the previous one.
252 ASSERT_EQ(1U, root->child_count());
253 child = root->child_at(0);
234 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), 254 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(),
235 child->current_frame_host()->render_view_host()); 255 child->current_frame_host()->render_view_host());
256 EXPECT_NE(rvh, child->current_frame_host()->render_view_host());
236 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 257 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
237 child->current_frame_host()->render_view_host()->GetSiteInstance()); 258 child->current_frame_host()->GetSiteInstance());
259 EXPECT_NE(site_instance,
260 child->current_frame_host()->GetSiteInstance());
238 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), 261 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(),
239 child->current_frame_host()->GetProcess()); 262 child->current_frame_host()->GetProcess());
263 EXPECT_NE(rph, child->current_frame_host()->GetProcess());
264
240 } 265 }
241 266
242 // Crash a subframe and ensures its children are cleared from the FrameTree. 267 // Crash a subframe and ensures its children are cleared from the FrameTree.
243 // See http://crbug.com/338508. 268 // See http://crbug.com/338508.
244 // TODO(creis): Enable this on Android when we can kill the process there. 269 // TODO(creis): Enable this on Android when we can kill the process there.
245 #if defined(OS_ANDROID) 270 #if defined(OS_ANDROID)
246 #define MAYBE_CrashSubframe DISABLED_CrashSubframe 271 #define MAYBE_CrashSubframe DISABLED_CrashSubframe
247 #else 272 #else
248 #define MAYBE_CrashSubframe CrashSubframe 273 #define MAYBE_CrashSubframe CrashSubframe
249 #endif 274 #endif
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 "server-redirect?" + client_redirect_http_url.spec())); 531 "server-redirect?" + client_redirect_http_url.spec()));
507 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 532 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
508 533
509 // DidFailProvisionalLoad when navigating to client_redirect_http_url. 534 // DidFailProvisionalLoad when navigating to client_redirect_http_url.
510 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 535 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
511 EXPECT_FALSE(observer.navigation_succeeded()); 536 EXPECT_FALSE(observer.navigation_succeeded());
512 } 537 }
513 } 538 }
514 539
515 } // namespace content 540 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698