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

Side by Side Diff: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc

Issue 24733003: Update defaults for InstantExtended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused. Created 7 years, 1 month 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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/chrome_notification_types.h" 6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/devtools/devtools_window.h" 7 #include "chrome/browser/devtools/devtools_window.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // in a process of that type, even if that means creating a new process. 86 // in a process of that type, even if that means creating a new process.
87 void TestProcessOverflow() { 87 void TestProcessOverflow() {
88 int tab_count = 1; 88 int tab_count = 1;
89 int host_count = 1; 89 int host_count = 1;
90 WebContents* tab1 = NULL; 90 WebContents* tab1 = NULL;
91 WebContents* tab2 = NULL; 91 WebContents* tab2 = NULL;
92 content::RenderProcessHost* rph1 = NULL; 92 content::RenderProcessHost* rph1 = NULL;
93 content::RenderProcessHost* rph2 = NULL; 93 content::RenderProcessHost* rph2 = NULL;
94 content::RenderProcessHost* rph3 = NULL; 94 content::RenderProcessHost* rph3 = NULL;
95 95
96 // Change the first tab to be the new tab page (TYPE_WEBUI). 96 // Change the first tab to be the omnibox page (TYPE_WEBUI).
97 GURL newtab(chrome::kChromeUINewTabURL); 97 GURL omnibox(chrome::kChromeUIOmniboxURL);
98 ui_test_utils::NavigateToURL(browser(), newtab); 98 ui_test_utils::NavigateToURL(browser(), omnibox);
99 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 99 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
100 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); 100 tab1 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
101 rph1 = tab1->GetRenderProcessHost(); 101 rph1 = tab1->GetRenderProcessHost();
102 EXPECT_TRUE(chrome::IsNTPURL(tab1->GetURL(), browser()->profile())); 102 EXPECT_EQ(omnibox, tab1->GetURL());
103 EXPECT_EQ(host_count, RenderProcessHostCount()); 103 EXPECT_EQ(host_count, RenderProcessHostCount());
104 104
105 // Create a new TYPE_TABBED tab. It should be in its own process. 105 // Create a new TYPE_TABBED tab. It should be in its own process.
106 GURL page1("data:text/html,hello world1"); 106 GURL page1("data:text/html,hello world1");
107 107
108 ui_test_utils::WindowedTabAddedNotificationObserver observer1( 108 ui_test_utils::WindowedTabAddedNotificationObserver observer1(
109 content::NotificationService::AllSources()); 109 content::NotificationService::AllSources());
110 chrome::ShowSingletonTab(browser(), page1); 110 chrome::ShowSingletonTab(browser(), page1);
111 observer1.Wait(); 111 observer1.Wait();
112 112
(...skipping 12 matching lines...) Expand all
125 content::NotificationService::AllSources()); 125 content::NotificationService::AllSources());
126 chrome::ShowSingletonTab(browser(), page2); 126 chrome::ShowSingletonTab(browser(), page2);
127 observer2.Wait(); 127 observer2.Wait();
128 tab_count++; 128 tab_count++;
129 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 129 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
130 tab2 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1); 130 tab2 = browser()->tab_strip_model()->GetWebContentsAt(tab_count - 1);
131 EXPECT_EQ(tab2->GetURL(), page2); 131 EXPECT_EQ(tab2->GetURL(), page2);
132 EXPECT_EQ(host_count, RenderProcessHostCount()); 132 EXPECT_EQ(host_count, RenderProcessHostCount());
133 EXPECT_EQ(tab2->GetRenderProcessHost(), rph2); 133 EXPECT_EQ(tab2->GetRenderProcessHost(), rph2);
134 134
135 // Create another TYPE_WEBUI tab. It should share the process with newtab. 135 // Create another TYPE_WEBUI tab. It should share the process with omnibox.
136 // Note: intentionally create this tab after the TYPE_TABBED tabs to 136 // Note: intentionally create this tab after the TYPE_TABBED tabs to
137 // exercise bug 43448 where extension and WebUI tabs could get combined into 137 // exercise bug 43448 where extension and WebUI tabs could get combined into
138 // normal renderers. 138 // normal renderers.
139 GURL history(chrome::kChromeUIHistoryURL); 139 GURL history(chrome::kChromeUIHistoryURL);
140 ui_test_utils::WindowedTabAddedNotificationObserver observer3( 140 ui_test_utils::WindowedTabAddedNotificationObserver observer3(
141 content::NotificationService::AllSources()); 141 content::NotificationService::AllSources());
142 chrome::ShowSingletonTab(browser(), history); 142 chrome::ShowSingletonTab(browser(), history);
143 observer3.Wait(); 143 observer3.Wait();
144 tab_count++; 144 tab_count++;
145 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 145 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // Set max renderers to 1 to force running out of processes. 180 // Set max renderers to 1 to force running out of processes.
181 content::RenderProcessHost::SetMaxRendererProcessCount(1); 181 content::RenderProcessHost::SetMaxRendererProcessCount(1);
182 182
183 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 183 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
184 parsed_command_line.AppendSwitch(switches::kProcessPerTab); 184 parsed_command_line.AppendSwitch(switches::kProcessPerTab);
185 185
186 int tab_count = 1; 186 int tab_count = 1;
187 int host_count = 1; 187 int host_count = 1;
188 188
189 // Change the first tab to be the new tab page (TYPE_WEBUI). 189 // Change the first tab to be the new tab page (TYPE_WEBUI).
190 GURL newtab(chrome::kChromeUINewTabURL); 190 GURL omnibox(chrome::kChromeUIOmniboxURL);
191 ui_test_utils::NavigateToURL(browser(), newtab); 191 ui_test_utils::NavigateToURL(browser(), omnibox);
192 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 192 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
193 EXPECT_EQ(host_count, RenderProcessHostCount()); 193 EXPECT_EQ(host_count, RenderProcessHostCount());
194 194
195 // Create a new TYPE_TABBED tab. It should be in its own process. 195 // Create a new TYPE_TABBED tab. It should be in its own process.
196 GURL page1("data:text/html,hello world1"); 196 GURL page1("data:text/html,hello world1");
197 ui_test_utils::WindowedTabAddedNotificationObserver observer1( 197 ui_test_utils::WindowedTabAddedNotificationObserver observer1(
198 content::NotificationService::AllSources()); 198 content::NotificationService::AllSources());
199 chrome::ShowSingletonTab(browser(), page1); 199 chrome::ShowSingletonTab(browser(), page1);
200 observer1.Wait(); 200 observer1.Wait();
201 tab_count++; 201 tab_count++;
202 host_count++; 202 host_count++;
203 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 203 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
204 EXPECT_EQ(host_count, RenderProcessHostCount()); 204 EXPECT_EQ(host_count, RenderProcessHostCount());
205 205
206 // Create another TYPE_TABBED tab. It should share the previous process. 206 // Create another TYPE_TABBED tab. It should share the previous process.
207 GURL page2("data:text/html,hello world2"); 207 GURL page2("data:text/html,hello world2");
208 ui_test_utils::WindowedTabAddedNotificationObserver observer2( 208 ui_test_utils::WindowedTabAddedNotificationObserver observer2(
209 content::NotificationService::AllSources()); 209 content::NotificationService::AllSources());
210 chrome::ShowSingletonTab(browser(), page2); 210 chrome::ShowSingletonTab(browser(), page2);
211 observer2.Wait(); 211 observer2.Wait();
212 tab_count++; 212 tab_count++;
213 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 213 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
214 EXPECT_EQ(host_count, RenderProcessHostCount()); 214 EXPECT_EQ(host_count, RenderProcessHostCount());
215 215
216 // Create another new tab. It should share the process with the other WebUI. 216 // Create another omnibox tab. It should share the process with the other
217 ui_test_utils::WindowedTabAddedNotificationObserver observer3( 217 // WebUI.
218 content::NotificationService::AllSources()); 218 ui_test_utils::NavigateToURLWithDisposition(
219 chrome::NewTab(browser()); 219 browser(), omnibox, NEW_FOREGROUND_TAB,
220 observer3.Wait(); 220 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
221 tab_count++; 221 tab_count++;
222 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 222 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
223 EXPECT_EQ(host_count, RenderProcessHostCount()); 223 EXPECT_EQ(host_count, RenderProcessHostCount());
224 224
225 // Create another new tab. It should share the process with the other WebUI. 225 // Create another omnibox tab. It should share the process with the other
226 ui_test_utils::WindowedTabAddedNotificationObserver observer4( 226 // WebUI.
227 content::NotificationService::AllSources()); 227 ui_test_utils::NavigateToURLWithDisposition(
228 chrome::NewTab(browser()); 228 browser(), omnibox, NEW_FOREGROUND_TAB,
229 observer4.Wait(); 229 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
230 tab_count++; 230 tab_count++;
231 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); 231 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count());
232 EXPECT_EQ(host_count, RenderProcessHostCount()); 232 EXPECT_EQ(host_count, RenderProcessHostCount());
233 } 233 }
234 234
235 // We don't change process priorities on Mac or Posix because the user lacks the 235 // We don't change process priorities on Mac or Posix because the user lacks the
236 // permission to raise a process' priority even after lowering it. 236 // permission to raise a process' priority even after lowering it.
237 #if defined(OS_WIN) || defined(OS_LINUX) 237 #if defined(OS_WIN) || defined(OS_LINUX)
238 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) { 238 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) {
239 if (!base::Process::CanBackgroundProcesses()) { 239 if (!base::Process::CanBackgroundProcesses()) {
240 LOG(ERROR) << "Can't background processes"; 240 LOG(ERROR) << "Can't background processes";
241 return; 241 return;
242 } 242 }
243 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 243 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
244 parsed_command_line.AppendSwitch(switches::kProcessPerTab); 244 parsed_command_line.AppendSwitch(switches::kProcessPerTab);
245 245
246 // Change the first tab to be the new tab page (TYPE_WEBUI). 246 // Change the first tab to be the omnibox page (TYPE_WEBUI).
247 GURL newtab(chrome::kChromeUINewTabURL); 247 GURL omnibox(chrome::kChromeUIOmniboxURL);
248 ui_test_utils::NavigateToURL(browser(), newtab); 248 ui_test_utils::NavigateToURL(browser(), omnibox);
249 249
250 // Create a new tab. It should be foreground. 250 // Create a new tab. It should be foreground.
251 GURL page1("data:text/html,hello world1"); 251 GURL page1("data:text/html,hello world1");
252 base::ProcessHandle pid1 = ShowSingletonTab(page1); 252 base::ProcessHandle pid1 = ShowSingletonTab(page1);
253 EXPECT_FALSE(base::Process(pid1).IsProcessBackgrounded()); 253 EXPECT_FALSE(base::Process(pid1).IsProcessBackgrounded());
254 254
255 // Create another tab. It should be foreground, and the first tab should 255 // Create another tab. It should be foreground, and the first tab should
256 // now be background. 256 // now be background.
257 GURL page2("data:text/html,hello world2"); 257 GURL page2("data:text/html,hello world2");
258 base::ProcessHandle pid2 = ShowSingletonTab(page2); 258 base::ProcessHandle pid2 = ShowSingletonTab(page2);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 TabStripModel* tab_strip_model_; 412 TabStripModel* tab_strip_model_;
413 413
414 DISALLOW_COPY_AND_ASSIGN(WindowDestroyer); 414 DISALLOW_COPY_AND_ASSIGN(WindowDestroyer);
415 }; 415 };
416 416
417 // Test to ensure that while iterating through all listeners in 417 // Test to ensure that while iterating through all listeners in
418 // RenderProcessHost and invalidating them, we remove them properly and don't 418 // RenderProcessHost and invalidating them, we remove them properly and don't
419 // access already freed objects. See http://crbug.com/255524. 419 // access already freed objects. See http://crbug.com/255524.
420 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, 420 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest,
421 CloseAllTabsDuringProcessDied) { 421 CloseAllTabsDuringProcessDied) {
422 GURL url(chrome::kChromeUINewTabURL); 422 GURL url(chrome::kChromeUIOmniboxURL);
423 423
424 ui_test_utils::NavigateToURL(browser(), url); 424 ui_test_utils::NavigateToURL(browser(), url);
425 ui_test_utils::NavigateToURLWithDisposition( 425 ui_test_utils::NavigateToURLWithDisposition(
426 browser(), url, NEW_BACKGROUND_TAB, 426 browser(), url, NEW_BACKGROUND_TAB,
427 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 427 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
428 428
429 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 429 EXPECT_EQ(2, browser()->tab_strip_model()->count());
430 430
431 WebContents* wc1 = browser()->tab_strip_model()->GetWebContentsAt(0); 431 WebContents* wc1 = browser()->tab_strip_model()->GetWebContentsAt(0);
432 WebContents* wc2 = browser()->tab_strip_model()->GetWebContentsAt(1); 432 WebContents* wc2 = browser()->tab_strip_model()->GetWebContentsAt(1);
433 EXPECT_EQ(wc1->GetRenderProcessHost(), wc2->GetRenderProcessHost()); 433 EXPECT_EQ(wc1->GetRenderProcessHost(), wc2->GetRenderProcessHost());
434 434
435 // Create an object that will close the window on a process crash. 435 // Create an object that will close the window on a process crash.
436 WindowDestroyer destroyer(wc1, browser()->tab_strip_model()); 436 WindowDestroyer destroyer(wc1, browser()->tab_strip_model());
437 437
438 // Use NOTIFICATION_BROWSER_CLOSED instead of NOTIFICATION_WINDOW_CLOSED, 438 // Use NOTIFICATION_BROWSER_CLOSED instead of NOTIFICATION_WINDOW_CLOSED,
439 // since the latter is not implemented on OSX and the test will timeout, 439 // since the latter is not implemented on OSX and the test will timeout,
440 // causing it to fail. 440 // causing it to fail.
441 content::WindowedNotificationObserver observer( 441 content::WindowedNotificationObserver observer(
442 chrome::NOTIFICATION_BROWSER_CLOSED, 442 chrome::NOTIFICATION_BROWSER_CLOSED,
443 content::NotificationService::AllSources()); 443 content::NotificationService::AllSources());
444 444
445 // Kill the renderer process, simulating a crash. This should the ProcessDied 445 // Kill the renderer process, simulating a crash. This should the ProcessDied
446 // method to be called. Alternatively, RenderProcessHost::OnChannelError can 446 // method to be called. Alternatively, RenderProcessHost::OnChannelError can
447 // be called to directly force a call to ProcessDied. 447 // be called to directly force a call to ProcessDied.
448 base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true); 448 base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true);
449 449
450 observer.Wait(); 450 observer.Wait();
451 } 451 }
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/search/instant_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698