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

Side by Side Diff: content/browser/renderer_host/render_process_host_browsertest.cc

Issue 9691009: Revert 126199 - Fixing a problem, where a hung renderer process is not killed when navigating away (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/renderer_host/render_process_host_browsertest.h" 5 #include "content/browser/renderer_host/render_process_host_browsertest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/process.h" 10 #include "base/process.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/browser/renderer_host/render_process_host_impl.h" 13 #include "content/browser/renderer_host/render_process_host_impl.h"
14 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
15 #include "content/common/test_url_constants.h" 15 #include "content/common/test_url_constants.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/common/content_switches.h" 17 #include "content/public/common/content_switches.h"
18 #include "net/test/test_server.h"
19 18
20 using content::WebContents; 19 using content::WebContents;
21 20
22 RenderProcessHostTest::RenderProcessHostTest() { 21 RenderProcessHostTest::RenderProcessHostTest() {
23 EnableDOMAutomation(); 22 EnableDOMAutomation();
24 } 23 }
25 24
26 int RenderProcessHostTest::RenderProcessHostCount() { 25 int RenderProcessHostTest::RenderProcessHostCount() {
27 content::RenderProcessHost::iterator hosts = 26 content::RenderProcessHost::iterator hosts =
28 content::RenderProcessHost::AllHostsIterator(); 27 content::RenderProcessHost::AllHostsIterator();
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // Set max renderers to 1 to force running out of processes. 245 // Set max renderers to 1 to force running out of processes.
247 content::RenderProcessHost::SetMaxRendererProcessCount(1); 246 content::RenderProcessHost::SetMaxRendererProcessCount(1);
248 TestProcessOverflow(); 247 TestProcessOverflow();
249 } 248 }
250 249
251 // Variation of the ProcessOverflow test, which is driven through command line 250 // Variation of the ProcessOverflow test, which is driven through command line
252 // parameter instead of direct function call into the class. 251 // parameter instead of direct function call into the class.
253 IN_PROC_BROWSER_TEST_F(RenderProcessHostTestWithCommandLine, ProcessOverflow) { 252 IN_PROC_BROWSER_TEST_F(RenderProcessHostTestWithCommandLine, ProcessOverflow) {
254 TestProcessOverflow(); 253 TestProcessOverflow();
255 } 254 }
256
257 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, UnresponsiveCrossSiteNavigation) {
258 WebContents* tab = NULL;
259 WebContents* tab2 = NULL;
260 content::RenderProcessHost* rph = NULL;
261 base::ProcessHandle process;
262 FilePath doc_root;
263
264 doc_root = doc_root.Append(FILE_PATH_LITERAL("content"));
265 doc_root = doc_root.Append(FILE_PATH_LITERAL("test"));
266 doc_root = doc_root.Append(FILE_PATH_LITERAL("data"));
267
268 // Start two servers to enable cross-site navigations.
269 net::TestServer server(net::TestServer::TYPE_HTTP,
270 net::TestServer::kLocalhost, doc_root);
271 ASSERT_TRUE(server.Start());
272 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
273 net::TestServer::kLocalhost, doc_root);
274 ASSERT_TRUE(https_server.Start());
275
276 GURL infinite_beforeunload_url(
277 server.GetURL("files/infinite_beforeunload.html"));
278 GURL infinite_unload_url(server.GetURL("files/infinite_unload.html"));
279 GURL same_process_url(server.GetURL("files/english_page.html"));
280 GURL new_process_url(https_server.GetURL("files/english_page.html"));
281
282 // Navigate the tab to the page which will lock up the process when we
283 // navigate away from it.
284 ui_test_utils::NavigateToURL(browser(), infinite_unload_url);
285 tab = browser()->GetWebContentsAt(0);
286 rph = tab->GetRenderProcessHost();
287 EXPECT_EQ(tab->GetURL(), infinite_unload_url);
288
289 // Remember the process prior to navigation, as we expect it to get killed.
290 process = rph->GetHandle();
291 ASSERT_TRUE(process);
292
293 ui_test_utils::NavigateToURL(browser(), new_process_url);
294 // This should fail, because the navigation to the new URL would result in
295 // the process getting killed. This is an indirect way to check for the
296 // process having been terminated.
297 EXPECT_FALSE(base::KillProcess(process, 1, false));
298
299 // Now, let's load the unresponsive page in one tab, then open another tab
300 // which will use the same process.
301 ui_test_utils::NavigateToURL(browser(), infinite_beforeunload_url);
302 tab = browser()->GetWebContentsAt(0);
303 rph = tab->GetRenderProcessHost();
304 EXPECT_EQ(tab->GetURL(), infinite_beforeunload_url);
305
306 ui_test_utils::NavigateToURLWithDisposition(browser(), same_process_url,
307 NEW_BACKGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
308 EXPECT_EQ(browser()->tab_count(), 2);
309 tab2 = browser()->GetWebContentsAt(1);
310 ASSERT_TRUE(tab2 != NULL);
311 EXPECT_EQ(tab2->GetURL(), same_process_url);
312 EXPECT_EQ(rph, tab2->GetRenderProcessHost());
313
314 process = rph->GetHandle();
315 ASSERT_TRUE(process);
316
317 // Navigating to the cross site URL will not kill the process, since it will
318 // have more than one tab using it. Kill it to confirm that it is still there,
319 // as well as finish the test faster.
320 ui_test_utils::NavigateToURL(browser(), new_process_url);
321 EXPECT_TRUE(base::KillProcess(process, 1, false));
322 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698