| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/debugger/devtools_manager.h" | 6 #include "chrome/browser/debugger/devtools_manager.h" |
| 7 #include "chrome/browser/renderer_host/site_instance.h" | 7 #include "chrome/browser/renderer_host/site_instance.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents.h" | 8 #include "chrome/browser/tab_contents/tab_contents.h" |
| 9 #include "chrome/browser/renderer_host/render_process_host.h" | 9 #include "chrome/browser/renderer_host/render_process_host.h" |
| 10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { | 63 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { |
| 64 // Set max renderers to 1 to force running out of processes. | 64 // Set max renderers to 1 to force running out of processes. |
| 65 RenderProcessHost::SetMaxRendererProcessCount(1); | 65 RenderProcessHost::SetMaxRendererProcessCount(1); |
| 66 | 66 |
| 67 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 67 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 68 parsed_command_line.AppendSwitch(switches::kProcessPerTab); | 68 parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| 69 | 69 |
| 70 int tab_count = 1; | 70 int tab_count = 1; |
| 71 int host_count = 1; | 71 int host_count = 1; |
| 72 | 72 |
| 73 // Change the first tab to be the new tab page (TYPE_DOMUI). | 73 // Change the first tab to be the new tab page (TYPE_WEBUI). |
| 74 GURL newtab(chrome::kChromeUINewTabURL); | 74 GURL newtab(chrome::kChromeUINewTabURL); |
| 75 ui_test_utils::NavigateToURL(browser(), newtab); | 75 ui_test_utils::NavigateToURL(browser(), newtab); |
| 76 EXPECT_EQ(tab_count, browser()->tab_count()); | 76 EXPECT_EQ(tab_count, browser()->tab_count()); |
| 77 EXPECT_EQ(host_count, RenderProcessHostCount()); | 77 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 78 | 78 |
| 79 // Create a new TYPE_NORMAL tab. It should be in its own process. | 79 // Create a new TYPE_NORMAL tab. It should be in its own process. |
| 80 GURL page1("data:text/html,hello world1"); | 80 GURL page1("data:text/html,hello world1"); |
| 81 browser()->ShowSingletonTab(page1, false); | 81 browser()->ShowSingletonTab(page1, false); |
| 82 if (browser()->tab_count() == tab_count) | 82 if (browser()->tab_count() == tab_count) |
| 83 ui_test_utils::WaitForNewTab(browser()); | 83 ui_test_utils::WaitForNewTab(browser()); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 RenderProcessHost::SetMaxRendererProcessCount(1); | 190 RenderProcessHost::SetMaxRendererProcessCount(1); |
| 191 | 191 |
| 192 int tab_count = 1; | 192 int tab_count = 1; |
| 193 int host_count = 1; | 193 int host_count = 1; |
| 194 TabContents* tab1 = NULL; | 194 TabContents* tab1 = NULL; |
| 195 TabContents* tab2 = NULL; | 195 TabContents* tab2 = NULL; |
| 196 RenderProcessHost* rph1 = NULL; | 196 RenderProcessHost* rph1 = NULL; |
| 197 RenderProcessHost* rph2 = NULL; | 197 RenderProcessHost* rph2 = NULL; |
| 198 RenderProcessHost* rph3 = NULL; | 198 RenderProcessHost* rph3 = NULL; |
| 199 | 199 |
| 200 // Change the first tab to be the new tab page (TYPE_DOMUI). | 200 // Change the first tab to be the new tab page (TYPE_WEBUI). |
| 201 GURL newtab(chrome::kChromeUINewTabURL); | 201 GURL newtab(chrome::kChromeUINewTabURL); |
| 202 ui_test_utils::NavigateToURL(browser(), newtab); | 202 ui_test_utils::NavigateToURL(browser(), newtab); |
| 203 EXPECT_EQ(tab_count, browser()->tab_count()); | 203 EXPECT_EQ(tab_count, browser()->tab_count()); |
| 204 tab1 = browser()->GetTabContentsAt(tab_count - 1); | 204 tab1 = browser()->GetTabContentsAt(tab_count - 1); |
| 205 rph1 = tab1->GetRenderProcessHost(); | 205 rph1 = tab1->GetRenderProcessHost(); |
| 206 EXPECT_EQ(tab1->GetURL(), newtab); | 206 EXPECT_EQ(tab1->GetURL(), newtab); |
| 207 EXPECT_EQ(host_count, RenderProcessHostCount()); | 207 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 208 | 208 |
| 209 // Create a new TYPE_NORMAL tab. It should be in its own process. | 209 // Create a new TYPE_NORMAL tab. It should be in its own process. |
| 210 GURL page1("data:text/html,hello world1"); | 210 GURL page1("data:text/html,hello world1"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 225 browser()->ShowSingletonTab(page2, false); | 225 browser()->ShowSingletonTab(page2, false); |
| 226 if (browser()->tab_count() == tab_count) | 226 if (browser()->tab_count() == tab_count) |
| 227 ui_test_utils::WaitForNewTab(browser()); | 227 ui_test_utils::WaitForNewTab(browser()); |
| 228 tab_count++; | 228 tab_count++; |
| 229 EXPECT_EQ(tab_count, browser()->tab_count()); | 229 EXPECT_EQ(tab_count, browser()->tab_count()); |
| 230 tab2 = browser()->GetTabContentsAt(tab_count - 1); | 230 tab2 = browser()->GetTabContentsAt(tab_count - 1); |
| 231 EXPECT_EQ(tab2->GetURL(), page2); | 231 EXPECT_EQ(tab2->GetURL(), page2); |
| 232 EXPECT_EQ(host_count, RenderProcessHostCount()); | 232 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 233 EXPECT_EQ(tab2->GetRenderProcessHost(), rph2); | 233 EXPECT_EQ(tab2->GetRenderProcessHost(), rph2); |
| 234 | 234 |
| 235 // Create another TYPE_DOMUI tab. It should share the process with newtab. | 235 // Create another TYPE_WEBUI tab. It should share the process with newtab. |
| 236 // Note: intentionally create this tab after the TYPE_NORMAL tabs to exercise | 236 // Note: intentionally create this tab after the TYPE_NORMAL tabs to exercise |
| 237 // bug 43448 where extension and WebUI tabs could get combined into normal | 237 // bug 43448 where extension and WebUI tabs could get combined into normal |
| 238 // renderers. | 238 // renderers. |
| 239 GURL history(chrome::kChromeUIHistoryURL); | 239 GURL history(chrome::kChromeUIHistoryURL); |
| 240 browser()->ShowSingletonTab(history, false); | 240 browser()->ShowSingletonTab(history, false); |
| 241 if (browser()->tab_count() == tab_count) | 241 if (browser()->tab_count() == tab_count) |
| 242 ui_test_utils::WaitForNewTab(browser()); | 242 ui_test_utils::WaitForNewTab(browser()); |
| 243 tab_count++; | 243 tab_count++; |
| 244 EXPECT_EQ(tab_count, browser()->tab_count()); | 244 EXPECT_EQ(tab_count, browser()->tab_count()); |
| 245 tab2 = browser()->GetTabContentsAt(tab_count - 1); | 245 tab2 = browser()->GetTabContentsAt(tab_count - 1); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 256 tab_count++; | 256 tab_count++; |
| 257 host_count++; | 257 host_count++; |
| 258 EXPECT_EQ(tab_count, browser()->tab_count()); | 258 EXPECT_EQ(tab_count, browser()->tab_count()); |
| 259 tab1 = browser()->GetTabContentsAt(tab_count - 1); | 259 tab1 = browser()->GetTabContentsAt(tab_count - 1); |
| 260 rph3 = tab1->GetRenderProcessHost(); | 260 rph3 = tab1->GetRenderProcessHost(); |
| 261 EXPECT_EQ(tab1->GetURL(), bookmarks); | 261 EXPECT_EQ(tab1->GetURL(), bookmarks); |
| 262 EXPECT_EQ(host_count, RenderProcessHostCount()); | 262 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 263 EXPECT_NE(rph1, rph3); | 263 EXPECT_NE(rph1, rph3); |
| 264 EXPECT_NE(rph2, rph3); | 264 EXPECT_NE(rph2, rph3); |
| 265 } | 265 } |
| OLD | NEW |