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

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

Issue 9514016: 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: Final cleanup update. 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.h » ('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 "base/time.h" 5 #include "base/time.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 11 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/browser/tab_contents/tab_contents.h" 12 #include "content/browser/tab_contents/tab_contents.h"
13 #include "content/common/view_messages.h" 13 #include "content/common/view_messages.h"
14 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
15 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
16 #include "net/base/host_port_pair.h" 17 #include "net/base/host_port_pair.h"
17 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
18 #include "net/test/test_server.h" 19 #include "net/test/test_server.h"
19 20
20 using content::RenderViewHostImpl; 21 using content::RenderViewHostImpl;
21 using content::WebContents; 22 using content::WebContents;
22 23
23 class RenderViewHostTest : public InProcessBrowserTest { 24 class RenderViewHostTest : public InProcessBrowserTest {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 ui_test_utils::NavigateToURL(browser(), test_url); 222 ui_test_utils::NavigateToURL(browser(), test_url);
222 EXPECT_TRUE(observer.base_url().is_empty()); 223 EXPECT_TRUE(observer.base_url().is_empty());
223 EXPECT_EQ(1, observer.navigation_count()); 224 EXPECT_EQ(1, observer.navigation_count());
224 225
225 // But should be set to the original page when reading MHTML. 226 // But should be set to the original page when reading MHTML.
226 test_url = net::FilePathToFileURL(test_server()->document_root().Append( 227 test_url = net::FilePathToFileURL(test_server()->document_root().Append(
227 FILE_PATH_LITERAL("google.mht"))); 228 FILE_PATH_LITERAL("google.mht")));
228 ui_test_utils::NavigateToURL(browser(), test_url); 229 ui_test_utils::NavigateToURL(browser(), test_url);
229 EXPECT_EQ("http://www.google.com/", observer.base_url().spec()); 230 EXPECT_EQ("http://www.google.com/", observer.base_url().spec());
230 } 231 }
232
233 // This test has experienced flackiness because of a bug in the input event
234 // processing interacting with the hang detection timer. If it starts being
235 // flacky again, ensure there has been no regressions on that area.
236 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, UnresponsiveCrossSiteNavigation) {
237 WebContents* tab = NULL;
238 WebContents* tab2 = NULL;
239 content::RenderProcessHost* rph = NULL;
240 base::ProcessHandle process;
241 FilePath doc_root;
242
243 doc_root = doc_root.Append(FILE_PATH_LITERAL("content"));
244 doc_root = doc_root.Append(FILE_PATH_LITERAL("test"));
245 doc_root = doc_root.Append(FILE_PATH_LITERAL("data"));
246
247 // Start two servers to enable cross-site navigations.
248 net::TestServer server(net::TestServer::TYPE_HTTP,
249 net::TestServer::kLocalhost, doc_root);
250 ASSERT_TRUE(server.Start());
251 net::TestServer https_server(net::TestServer::TYPE_HTTPS,
252 net::TestServer::kLocalhost, doc_root);
253 ASSERT_TRUE(https_server.Start());
254
255 GURL infinite_beforeunload_url(
256 server.GetURL("files/infinite_beforeunload.html"));
257 GURL infinite_unload_url(server.GetURL("files/infinite_unload.html"));
258 GURL same_process_url(server.GetURL("files/english_page.html"));
259 GURL new_process_url(https_server.GetURL("files/english_page.html"));
260
261 // Navigate the tab to the page which will lock up the process when we
262 // navigate away from it.
263 ui_test_utils::NavigateToURL(browser(), infinite_unload_url);
264 tab = browser()->GetWebContentsAt(0);
265 rph = tab->GetRenderProcessHost();
266 EXPECT_EQ(tab->GetURL(), infinite_unload_url);
267
268 // Remember the process prior to navigation, as we expect it to get killed.
269 process = rph->GetHandle();
270 ASSERT_TRUE(process);
271
272 {
273 ui_test_utils::WindowedNotificationObserver process_exit_observer(
274 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
275 content::NotificationService::AllSources());
276 ui_test_utils::NavigateToURL(browser(), new_process_url);
277 process_exit_observer.Wait();
278 }
279
280 // This should fail, because the navigation to the new URL would result in
281 // the process getting killed. This is an indirect way to check for the
282 // process having been terminated.
283 EXPECT_FALSE(base::KillProcess(process, 1, false));
284
285 ui_test_utils::NavigateToURL(browser(), same_process_url);
286 tab = browser()->GetWebContentsAt(0);
287 rph = tab->GetRenderProcessHost();
288 ASSERT_TRUE(tab != NULL);
289 EXPECT_EQ(tab->GetURL(), same_process_url);
290
291
292 // Now, let's open another tab with the unresponsive page, which will cause
293 // the previous page and the unresponsive one to use the same process.
294 ui_test_utils::NavigateToURLWithDisposition(browser(),
295 infinite_beforeunload_url, NEW_FOREGROUND_TAB,
296 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
297 EXPECT_EQ(browser()->tab_count(), 2);
298 tab2 = browser()->GetWebContentsAt(1);
299 ASSERT_TRUE(tab2 != NULL);
300 EXPECT_EQ(tab2->GetURL(), infinite_beforeunload_url);
301 EXPECT_EQ(rph, tab2->GetRenderProcessHost());
302
303 process = rph->GetHandle();
304 ASSERT_TRUE(process);
305
306 // Navigating to the cross site URL will not kill the process, since it will
307 // have more than one tab using it. Kill it to confirm that it is still there,
308 // as well as finish the test faster.
309 {
310 ui_test_utils::WindowedNotificationObserver process_exit_observer(
311 content::NOTIFICATION_RENDERER_PROCESS_HANG,
312 content::NotificationService::AllSources());
313 ui_test_utils::NavigateToURL(browser(), new_process_url);
314 process_exit_observer.Wait();
315 }
316
317 EXPECT_TRUE(base::KillProcess(process, 2, false));
318 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698