OLD | NEW |
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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_commands.h" | 14 #include "chrome/browser/ui/browser_commands.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/render_widget_host_view.h" |
23 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
24 #include "content/public/test/browser_test_utils.h" | 27 #include "content/public/test/browser_test_utils.h" |
25 #include "net/test/embedded_test_server/embedded_test_server.h" | 28 #include "net/test/embedded_test_server/embedded_test_server.h" |
26 #include "net/test/embedded_test_server/http_request.h" | 29 #include "net/test/embedded_test_server/http_request.h" |
27 #include "net/test/embedded_test_server/http_response.h" | 30 #include "net/test/embedded_test_server/http_response.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
29 #include "ui/base/page_transition_types.h" | 32 #include "ui/base/page_transition_types.h" |
30 | 33 |
31 using content::OpenURLParams; | 34 using content::OpenURLParams; |
32 using content::Referrer; | 35 using content::Referrer; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 base::string16 title_after_crash; | 102 base::string16 title_after_crash; |
100 | 103 |
101 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 104 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
102 &title_before_crash)); | 105 &title_before_crash)); |
103 SimulateRendererCrash(browser()); | 106 SimulateRendererCrash(browser()); |
104 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); | 107 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
105 content::WaitForLoadStop(GetActiveWebContents()); | 108 content::WaitForLoadStop(GetActiveWebContents()); |
106 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 109 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
107 &title_after_crash)); | 110 &title_after_crash)); |
108 EXPECT_NE(title_before_crash, title_after_crash); | 111 EXPECT_NE(title_before_crash, title_after_crash); |
| 112 ASSERT_TRUE(GetActiveWebContents()->GetMainFrame()->GetView()->IsShowing()); |
| 113 ASSERT_FALSE( |
| 114 GetActiveWebContents()->GetRenderProcessHost()->IsProcessBackgrounded()); |
109 } | 115 } |
110 | 116 |
111 // Test that reload after a crash forces a cache revalidation. | 117 // Test that reload after a crash forces a cache revalidation. |
112 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, ReloadCacheRevalidate) { | 118 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, ReloadCacheRevalidate) { |
113 const char kTestPath[] = "/test"; | 119 const char kTestPath[] = "/test"; |
114 | 120 |
115 // Use the test server so as not to bypass cache behavior. The title of the | 121 // Use the test server so as not to bypass cache behavior. The title of the |
116 // active tab should change only when this URL is reloaded. | 122 // active tab should change only when this URL is reloaded. |
117 embedded_test_server()->RegisterRequestHandler( | 123 embedded_test_server()->RegisterRequestHandler( |
118 base::Bind(&CacheMaxAgeHandler::HandleRequest, | 124 base::Bind(&CacheMaxAgeHandler::HandleRequest, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 "<script>window.onbeforeunload=function(e){return 'foo'}</script>" | 195 "<script>window.onbeforeunload=function(e){return 'foo'}</script>" |
190 "</body></html>"; | 196 "</body></html>"; |
191 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); | 197 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); |
192 ui_test_utils::NavigateToURL(browser(), url); | 198 ui_test_utils::NavigateToURL(browser(), url); |
193 SimulateRendererCrash(browser()); | 199 SimulateRendererCrash(browser()); |
194 } | 200 } |
195 | 201 |
196 } // namespace | 202 } // namespace |
197 | 203 |
198 #endif | 204 #endif |
OLD | NEW |