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

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

Issue 2921063003: Fix process reuse for dedicated processes when over process limit. (Closed)
Patch Set: Fix IsSuitableHost for sites that require a dedicated process but don't set an origin lock Created 3 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
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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 10179 matching lines...) Expand 10 before | Expand all | Expand 10 after
10190 10190
10191 // Go back again. This should go to foo.com. 10191 // Go back again. This should go to foo.com.
10192 { 10192 {
10193 TestNavigationObserver back_observer(web_contents()); 10193 TestNavigationObserver back_observer(web_contents());
10194 web_contents()->GetController().GoBack(); 10194 web_contents()->GetController().GoBack();
10195 back_observer.Wait(); 10195 back_observer.Wait();
10196 } 10196 }
10197 EXPECT_EQ(foo_url, web_contents()->GetMainFrame()->GetLastCommittedURL()); 10197 EXPECT_EQ(foo_url, web_contents()->GetMainFrame()->GetLastCommittedURL());
10198 } 10198 }
10199 10199
10200 // Check that main frames for the same site rendering in unrelated tabs start
10201 // sharing processes that are already dedicated to that site when over process
10202 // limit. See https://crbug.com/513036.
10203 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
10204 MainFrameProcessReuseWhenOverLimit) {
10205 // Set the process limit to 1.
10206 RenderProcessHost::SetMaxRendererProcessCount(1);
10207
10208 GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
10209 ASSERT_TRUE(NavigateToURL(shell(), url_a));
10210
10211 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
10212
10213 // Create an unrelated shell window.
10214 GURL url_b(embedded_test_server()->GetURL("b.com", "/title2.html"));
10215 Shell* new_shell = CreateBrowser();
10216 EXPECT_TRUE(NavigateToURL(new_shell, url_b));
10217
10218 FrameTreeNode* new_shell_root =
10219 static_cast<WebContentsImpl*>(new_shell->web_contents())
10220 ->GetFrameTree()
10221 ->root();
10222
10223 // The new window's b.com root should not reuse the a.com process.
10224 EXPECT_NE(root->current_frame_host()->GetProcess(),
10225 new_shell_root->current_frame_host()->GetProcess());
10226
10227 // Navigating the new window to a.com should reuse the first window's
10228 // process.
10229 EXPECT_TRUE(NavigateToURL(new_shell, url_a));
10230 EXPECT_EQ(root->current_frame_host()->GetProcess(),
10231 new_shell_root->current_frame_host()->GetProcess());
10232 }
10233
10234 // Check that subframes for the same site rendering in unrelated tabs start
10235 // sharing processes that are already dedicated to that site when over process
10236 // limit. See https://crbug.com/513036.
10237 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
10238 SubframeProcessReuseWhenOverLimit) {
10239 // Set the process limit to 1.
10240 RenderProcessHost::SetMaxRendererProcessCount(1);
10241
10242 GURL first_url(embedded_test_server()->GetURL(
10243 "a.com", "/cross_site_iframe_factory.html?a(b,b(c))"));
10244 ASSERT_TRUE(NavigateToURL(shell(), first_url));
10245
10246 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
10247
10248 // Processes for dedicated sites should never be reused.
10249 EXPECT_NE(root->current_frame_host()->GetProcess(),
10250 root->child_at(0)->current_frame_host()->GetProcess());
10251 EXPECT_NE(root->current_frame_host()->GetProcess(),
10252 root->child_at(1)->current_frame_host()->GetProcess());
10253 EXPECT_NE(root->current_frame_host()->GetProcess(),
10254 root->child_at(1)->child_at(0)->current_frame_host()->GetProcess());
10255 EXPECT_NE(root->child_at(1)->current_frame_host()->GetProcess(),
10256 root->child_at(1)->child_at(0)->current_frame_host()->GetProcess());
10257 EXPECT_EQ(root->child_at(0)->current_frame_host()->GetProcess(),
10258 root->child_at(1)->current_frame_host()->GetProcess());
10259
10260 // Create an unrelated shell window.
10261 Shell* new_shell = CreateBrowser();
10262
10263 GURL new_shell_url(embedded_test_server()->GetURL(
10264 "d.com", "/cross_site_iframe_factory.html?d(a(b))"));
10265 ASSERT_TRUE(NavigateToURL(new_shell, new_shell_url));
10266
10267 FrameTreeNode* new_shell_root =
10268 static_cast<WebContentsImpl*>(new_shell->web_contents())
10269 ->GetFrameTree()
10270 ->root();
10271
10272 // New tab's root (d.com) should go into a separate process.
10273 EXPECT_NE(root->current_frame_host()->GetProcess(),
10274 new_shell_root->current_frame_host()->GetProcess());
10275 EXPECT_NE(root->child_at(0)->current_frame_host()->GetProcess(),
10276 new_shell_root->current_frame_host()->GetProcess());
10277 EXPECT_NE(root->child_at(1)->child_at(0)->current_frame_host()->GetProcess(),
10278 new_shell_root->current_frame_host()->GetProcess());
10279
10280 // The new tab's subframe should reuse the a.com process.
10281 EXPECT_EQ(root->current_frame_host()->GetProcess(),
10282 new_shell_root->child_at(0)->current_frame_host()->GetProcess());
10283
10284 // The new tab's grandchild frame should reuse the b.com process.
10285 EXPECT_EQ(root->child_at(0)->current_frame_host()->GetProcess(),
10286 new_shell_root->child_at(0)
10287 ->child_at(0)
10288 ->current_frame_host()
10289 ->GetProcess());
10290 }
10291
10200 } // namespace content 10292 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698