| Index: chrome/browser/renderer_host/test/render_process_host_browsertest.cc
|
| ===================================================================
|
| --- chrome/browser/renderer_host/test/render_process_host_browsertest.cc (revision 70598)
|
| +++ chrome/browser/renderer_host/test/render_process_host_browsertest.cc (working copy)
|
| @@ -2,10 +2,12 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/command_line.h"
|
| #include "chrome/browser/renderer_host/site_instance.h"
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| #include "chrome/browser/renderer_host/render_process_host.h"
|
| #include "chrome/browser/ui/browser.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/in_process_browser_test.h"
|
| #include "chrome/test/ui_test_utils.h"
|
| @@ -28,6 +30,58 @@
|
| }
|
| };
|
|
|
| +IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) {
|
| + // Set max renderers to 1 to force running out of processes.
|
| + RenderProcessHost::SetMaxRendererProcessCount(1);
|
| +
|
| + CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
|
| + parsed_command_line.AppendSwitch(switches::kProcessPerTab);
|
| +
|
| + int tab_count = 1;
|
| + int host_count = 1;
|
| +
|
| + // Change the first tab to be the new tab page (TYPE_DOMUI).
|
| + GURL newtab(chrome::kChromeUINewTabURL);
|
| + ui_test_utils::NavigateToURL(browser(), newtab);
|
| + EXPECT_EQ(tab_count, browser()->tab_count());
|
| + EXPECT_EQ(host_count, RenderProcessHostCount());
|
| +
|
| + // Create a new TYPE_NORMAL tab. It should be in its own process.
|
| + GURL page1("data:text/html,hello world1");
|
| + browser()->ShowSingletonTab(page1, false);
|
| + if (browser()->tab_count() == tab_count)
|
| + ui_test_utils::WaitForNewTab(browser());
|
| + tab_count++;
|
| + host_count++;
|
| + EXPECT_EQ(tab_count, browser()->tab_count());
|
| + EXPECT_EQ(host_count, RenderProcessHostCount());
|
| +
|
| + // Create another TYPE_NORMAL tab. It should share the previous process.
|
| + GURL page2("data:text/html,hello world2");
|
| + browser()->ShowSingletonTab(page2, false);
|
| + if (browser()->tab_count() == tab_count)
|
| + ui_test_utils::WaitForNewTab(browser());
|
| + tab_count++;
|
| + EXPECT_EQ(tab_count, browser()->tab_count());
|
| + EXPECT_EQ(host_count, RenderProcessHostCount());
|
| +
|
| + // Create another new tab. It should share the process with the other DOMUI.
|
| + browser()->NewTab();
|
| + if (browser()->tab_count() == tab_count)
|
| + ui_test_utils::WaitForNewTab(browser());
|
| + tab_count++;
|
| + EXPECT_EQ(tab_count, browser()->tab_count());
|
| + EXPECT_EQ(host_count, RenderProcessHostCount());
|
| +
|
| + // Create another new tab. It should share the process with the other DOMUI.
|
| + browser()->NewTab();
|
| + if (browser()->tab_count() == tab_count)
|
| + ui_test_utils::WaitForNewTab(browser());
|
| + tab_count++;
|
| + EXPECT_EQ(tab_count, browser()->tab_count());
|
| + EXPECT_EQ(host_count, RenderProcessHostCount());
|
| +}
|
| +
|
| // When we hit the max number of renderers, verify that the way we do process
|
| // sharing behaves correctly. In particular, this test is verifying that even
|
| // when we hit the max process limit, that renderers of each type will wind up
|
|
|