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

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: Rebase Created 3 years, 5 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 10317 matching lines...) Expand 10 before | Expand all | Expand 10 after
10328 10328
10329 // Verify that inertness was preserved across the navigation. 10329 // Verify that inertness was preserved across the navigation.
10330 EXPECT_TRUE(ExecuteScriptAndExtractString( 10330 EXPECT_TRUE(ExecuteScriptAndExtractString(
10331 iframe_node, 10331 iframe_node,
10332 "text2.focus();" 10332 "text2.focus();"
10333 "domAutomationController.send(document.activeElement.id);", 10333 "domAutomationController.send(document.activeElement.id);",
10334 &focused_element)); 10334 &focused_element));
10335 EXPECT_EQ("", focused_element); 10335 EXPECT_EQ("", focused_element);
10336 } 10336 }
10337 10337
10338 // Check that main frames for the same site rendering in unrelated tabs start
10339 // sharing processes that are already dedicated to that site when over process
10340 // limit. See https://crbug.com/513036.
10341 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
10342 MainFrameProcessReuseWhenOverLimit) {
10343 // Set the process limit to 1.
10344 RenderProcessHost::SetMaxRendererProcessCount(1);
10345
10346 GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
10347 ASSERT_TRUE(NavigateToURL(shell(), url_a));
10348
10349 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
10350
10351 // Create an unrelated shell window.
10352 GURL url_b(embedded_test_server()->GetURL("b.com", "/title2.html"));
10353 Shell* new_shell = CreateBrowser();
10354 EXPECT_TRUE(NavigateToURL(new_shell, url_b));
10355
10356 FrameTreeNode* new_shell_root =
10357 static_cast<WebContentsImpl*>(new_shell->web_contents())
10358 ->GetFrameTree()
10359 ->root();
10360
10361 // The new window's b.com root should not reuse the a.com process.
10362 EXPECT_NE(root->current_frame_host()->GetProcess(),
10363 new_shell_root->current_frame_host()->GetProcess());
10364
10365 // Navigating the new window to a.com should reuse the first window's
10366 // process.
10367 EXPECT_TRUE(NavigateToURL(new_shell, url_a));
10368 EXPECT_EQ(root->current_frame_host()->GetProcess(),
10369 new_shell_root->current_frame_host()->GetProcess());
10370 }
10371
10372 // Check that subframes for the same site rendering in unrelated tabs start
10373 // sharing processes that are already dedicated to that site when over process
10374 // limit. See https://crbug.com/513036.
10375 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
10376 SubframeProcessReuseWhenOverLimit) {
10377 // Set the process limit to 1.
10378 RenderProcessHost::SetMaxRendererProcessCount(1);
10379
10380 GURL first_url(embedded_test_server()->GetURL(
10381 "a.com", "/cross_site_iframe_factory.html?a(b,b(c))"));
10382 ASSERT_TRUE(NavigateToURL(shell(), first_url));
10383
10384 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
10385
10386 // Processes for dedicated sites should never be reused.
10387 EXPECT_NE(root->current_frame_host()->GetProcess(),
10388 root->child_at(0)->current_frame_host()->GetProcess());
10389 EXPECT_NE(root->current_frame_host()->GetProcess(),
10390 root->child_at(1)->current_frame_host()->GetProcess());
10391 EXPECT_NE(root->current_frame_host()->GetProcess(),
10392 root->child_at(1)->child_at(0)->current_frame_host()->GetProcess());
10393 EXPECT_NE(root->child_at(1)->current_frame_host()->GetProcess(),
10394 root->child_at(1)->child_at(0)->current_frame_host()->GetProcess());
10395 EXPECT_EQ(root->child_at(0)->current_frame_host()->GetProcess(),
10396 root->child_at(1)->current_frame_host()->GetProcess());
10397
10398 // Create an unrelated shell window.
10399 Shell* new_shell = CreateBrowser();
10400
10401 GURL new_shell_url(embedded_test_server()->GetURL(
10402 "d.com", "/cross_site_iframe_factory.html?d(a(b))"));
10403 ASSERT_TRUE(NavigateToURL(new_shell, new_shell_url));
10404
10405 FrameTreeNode* new_shell_root =
10406 static_cast<WebContentsImpl*>(new_shell->web_contents())
10407 ->GetFrameTree()
10408 ->root();
10409
10410 // New tab's root (d.com) should go into a separate process.
10411 EXPECT_NE(root->current_frame_host()->GetProcess(),
10412 new_shell_root->current_frame_host()->GetProcess());
10413 EXPECT_NE(root->child_at(0)->current_frame_host()->GetProcess(),
10414 new_shell_root->current_frame_host()->GetProcess());
10415 EXPECT_NE(root->child_at(1)->child_at(0)->current_frame_host()->GetProcess(),
10416 new_shell_root->current_frame_host()->GetProcess());
10417
10418 // The new tab's subframe should reuse the a.com process.
10419 EXPECT_EQ(root->current_frame_host()->GetProcess(),
10420 new_shell_root->child_at(0)->current_frame_host()->GetProcess());
10421
10422 // The new tab's grandchild frame should reuse the b.com process.
10423 EXPECT_EQ(root->child_at(0)->current_frame_host()->GetProcess(),
10424 new_shell_root->child_at(0)
10425 ->child_at(0)
10426 ->current_frame_host()
10427 ->GetProcess());
10428 }
10429
10338 } // namespace content 10430 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698