| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/process_util.h" | 8 #include "base/process_util.h" |
| 9 #include "chrome/browser/renderer_host/render_process_host.h" | 9 #include "chrome/browser/renderer_host/render_process_host.h" |
| 10 #include "chrome/browser/renderer_host/web_cache_manager.h" | 10 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/common/result_codes.h" |
| 13 #include "chrome/test/in_process_browser_test.h" | 14 #include "chrome/test/in_process_browser_test.h" |
| 14 #include "chrome/test/ui_test_utils.h" | 15 #include "chrome/test/ui_test_utils.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 class WebCacheManagerBrowserTest : public InProcessBrowserTest { | 18 class WebCacheManagerBrowserTest : public InProcessBrowserTest { |
| 18 }; | 19 }; |
| 19 | 20 |
| 20 // Regression test for http://crbug.com/12362. If a renderer crashes and the | 21 // Regression test for http://crbug.com/12362. If a renderer crashes and the |
| 21 // user navigates to another tab and back, the browser doesn't crash. | 22 // user navigates to another tab and back, the browser doesn't crash. |
| 22 // Flaky, http://crbug.com/15288. | 23 // Flaky, http://crbug.com/15288. |
| 23 IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, FLAKY_CrashOnceOnly) { | 24 IN_PROC_BROWSER_TEST_F(WebCacheManagerBrowserTest, FLAKY_CrashOnceOnly) { |
| 24 const FilePath kTestDir(FILE_PATH_LITERAL("google")); | 25 const FilePath kTestDir(FILE_PATH_LITERAL("google")); |
| 25 const FilePath kTestFile(FILE_PATH_LITERAL("google.html")); | 26 const FilePath kTestFile(FILE_PATH_LITERAL("google.html")); |
| 26 GURL url(ui_test_utils::GetTestUrl(kTestDir, kTestFile)); | 27 GURL url(ui_test_utils::GetTestUrl(kTestDir, kTestFile)); |
| 27 | 28 |
| 28 ui_test_utils::NavigateToURL(browser(), url); | 29 ui_test_utils::NavigateToURL(browser(), url); |
| 29 | 30 |
| 30 browser()->NewTab(); | 31 browser()->NewTab(); |
| 31 ui_test_utils::NavigateToURL(browser(), url); | 32 ui_test_utils::NavigateToURL(browser(), url); |
| 32 | 33 |
| 33 TabContents* tab = browser()->GetTabContentsAt(0); | 34 TabContents* tab = browser()->GetTabContentsAt(0); |
| 34 ASSERT_TRUE(tab != NULL); | 35 ASSERT_TRUE(tab != NULL); |
| 35 base::KillProcess(tab->GetRenderProcessHost()->GetHandle(), | 36 base::KillProcess(tab->GetRenderProcessHost()->GetHandle(), |
| 36 base::PROCESS_END_KILLED_BY_USER, true); | 37 ResultCodes::KILLED, true); |
| 37 | 38 |
| 38 browser()->SelectTabContentsAt(0, true); | 39 browser()->SelectTabContentsAt(0, true); |
| 39 browser()->NewTab(); | 40 browser()->NewTab(); |
| 40 ui_test_utils::NavigateToURL(browser(), url); | 41 ui_test_utils::NavigateToURL(browser(), url); |
| 41 | 42 |
| 42 browser()->SelectTabContentsAt(0, true); | 43 browser()->SelectTabContentsAt(0, true); |
| 43 browser()->NewTab(); | 44 browser()->NewTab(); |
| 44 ui_test_utils::NavigateToURL(browser(), url); | 45 ui_test_utils::NavigateToURL(browser(), url); |
| 45 | 46 |
| 46 // We would have crashed at the above line with the bug. | 47 // We would have crashed at the above line with the bug. |
| 47 | 48 |
| 48 browser()->SelectTabContentsAt(0, true); | 49 browser()->SelectTabContentsAt(0, true); |
| 49 browser()->CloseTab(); | 50 browser()->CloseTab(); |
| 50 browser()->SelectTabContentsAt(0, true); | 51 browser()->SelectTabContentsAt(0, true); |
| 51 browser()->CloseTab(); | 52 browser()->CloseTab(); |
| 52 browser()->SelectTabContentsAt(0, true); | 53 browser()->SelectTabContentsAt(0, true); |
| 53 browser()->CloseTab(); | 54 browser()->CloseTab(); |
| 54 | 55 |
| 55 ui_test_utils::NavigateToURL(browser(), url); | 56 ui_test_utils::NavigateToURL(browser(), url); |
| 56 | 57 |
| 57 EXPECT_EQ( | 58 EXPECT_EQ( |
| 58 WebCacheManager::GetInstance()->active_renderers_.size(), 1U); | 59 WebCacheManager::GetInstance()->active_renderers_.size(), 1U); |
| 59 EXPECT_EQ( | 60 EXPECT_EQ( |
| 60 WebCacheManager::GetInstance()->inactive_renderers_.size(), 0U); | 61 WebCacheManager::GetInstance()->inactive_renderers_.size(), 0U); |
| 61 EXPECT_EQ( | 62 EXPECT_EQ( |
| 62 WebCacheManager::GetInstance()->stats_.size(), 1U); | 63 WebCacheManager::GetInstance()->stats_.size(), 1U); |
| 63 } | 64 } |
| OLD | NEW |