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

Side by Side Diff: chrome/browser/renderer_host/test/render_process_host_browsertest.cc

Issue 6106003: Similar as extension, DOM UI needs to be created in its own process.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/site_instance.h" 6 #include "chrome/browser/renderer_host/site_instance.h"
6 #include "chrome/browser/tab_contents/tab_contents.h" 7 #include "chrome/browser/tab_contents/tab_contents.h"
7 #include "chrome/browser/renderer_host/render_process_host.h" 8 #include "chrome/browser/renderer_host/render_process_host.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/common/chrome_switches.h"
9 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
10 #include "chrome/test/in_process_browser_test.h" 12 #include "chrome/test/in_process_browser_test.h"
11 #include "chrome/test/ui_test_utils.h" 13 #include "chrome/test/ui_test_utils.h"
12 14
13 class RenderProcessHostTest : public InProcessBrowserTest { 15 class RenderProcessHostTest : public InProcessBrowserTest {
14 public: 16 public:
15 RenderProcessHostTest() { 17 RenderProcessHostTest() {
16 EnableDOMAutomation(); 18 EnableDOMAutomation();
17 } 19 }
18 20
19 int RenderProcessHostCount() { 21 int RenderProcessHostCount() {
20 RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator(); 22 RenderProcessHost::iterator hosts = RenderProcessHost::AllHostsIterator();
21 int count = 0; 23 int count = 0;
22 while (!hosts.IsAtEnd()) { 24 while (!hosts.IsAtEnd()) {
23 if (hosts.GetCurrentValue()->HasConnection()) 25 if (hosts.GetCurrentValue()->HasConnection())
24 count++; 26 count++;
25 hosts.Advance(); 27 hosts.Advance();
26 } 28 }
27 return count; 29 return count;
28 } 30 }
29 }; 31 };
30 32
33 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) {
34 // Set max renderers to 1 to force running out of processes.
35 RenderProcessHost::SetMaxRendererProcessCount(1);
Charlie Reis 2011/01/06 18:27:59 I don't think you need this line. Even if the max
klobag.chromium 2011/01/06 20:23:02 I added some normal page cases.
36
37 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
38 parsed_command_line.AppendSwitch(switches::kProcessPerTab);
39
40 int tab_count = 1;
41
42 // Change the first tab to be the new tab page (TYPE_DOMUI).
43 GURL newtab(chrome::kChromeUINewTabURL);
44 ui_test_utils::NavigateToURL(browser(), newtab);
45 EXPECT_EQ(tab_count, browser()->tab_count());
46 EXPECT_EQ(1, RenderProcessHostCount());
47
48 // Create another new tab. It should share the previous process.
49 browser()->NewTab();
50 if (browser()->tab_count() == tab_count)
51 ui_test_utils::WaitForNewTab(browser());
52 tab_count++;
53 EXPECT_EQ(tab_count, browser()->tab_count());
54 EXPECT_EQ(1, RenderProcessHostCount());
55 }
56
31 // When we hit the max number of renderers, verify that the way we do process 57 // When we hit the max number of renderers, verify that the way we do process
32 // sharing behaves correctly. In particular, this test is verifying that even 58 // sharing behaves correctly. In particular, this test is verifying that even
33 // when we hit the max process limit, that renderers of each type will wind up 59 // when we hit the max process limit, that renderers of each type will wind up
34 // in a process of that type, even if that means creating a new process. 60 // in a process of that type, even if that means creating a new process.
35 // TODO(erikkay) crbug.com/43448 - disabled for now until we can get a 61 // TODO(erikkay) crbug.com/43448 - disabled for now until we can get a
36 // reasonable implementation in place. 62 // reasonable implementation in place.
37 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, DISABLED_ProcessOverflow) { 63 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, DISABLED_ProcessOverflow) {
38 // Set max renderers to 1 to force running out of processes. 64 // Set max renderers to 1 to force running out of processes.
39 RenderProcessHost::SetMaxRendererProcessCount(1); 65 RenderProcessHost::SetMaxRendererProcessCount(1);
40 66
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 tab_count++; 131 tab_count++;
106 host_count++; 132 host_count++;
107 EXPECT_EQ(tab_count, browser()->tab_count()); 133 EXPECT_EQ(tab_count, browser()->tab_count());
108 tab1 = browser()->GetTabContentsAt(tab_count - 1); 134 tab1 = browser()->GetTabContentsAt(tab_count - 1);
109 rph3 = tab1->GetRenderProcessHost(); 135 rph3 = tab1->GetRenderProcessHost();
110 EXPECT_EQ(tab1->GetURL(), bookmarks); 136 EXPECT_EQ(tab1->GetURL(), bookmarks);
111 EXPECT_EQ(host_count, RenderProcessHostCount()); 137 EXPECT_EQ(host_count, RenderProcessHostCount());
112 EXPECT_NE(rph1, rph3); 138 EXPECT_NE(rph1, rph3);
113 EXPECT_NE(rph2, rph3); 139 EXPECT_NE(rph2, rph3);
114 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698