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