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 "base/command_line.h" | |
5 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
6 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/common/chrome_switches.h" | |
10 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
13 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
14 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
15 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
16 #include "content/public/common/page_transition_types.h" | 18 #include "content/public/common/page_transition_types.h" |
17 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
18 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
19 #include "net/test/embedded_test_server/http_request.h" | 21 #include "net/test/embedded_test_server/http_request.h" |
20 #include "net/test/embedded_test_server/http_response.h" | 22 #include "net/test/embedded_test_server/http_response.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 | 24 |
23 using content::NavigationController; | |
24 using content::OpenURLParams; | 25 using content::OpenURLParams; |
25 using content::Referrer; | 26 using content::Referrer; |
26 using content::WebContents; | 27 using content::WebContents; |
27 | 28 |
28 // TODO(jam): http://crbug.com/350550 | 29 // TODO(jam): http://crbug.com/350550 |
29 #if !(defined(OS_CHROMEOS) && defined(ADDRESS_SANITIZER)) | 30 #if !(defined(OS_CHROMEOS) && defined(ADDRESS_SANITIZER)) |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 void SimulateRendererCrash(Browser* browser) { | 34 void SimulateRendererCrash(Browser* browser) { |
(...skipping 23 matching lines...) Expand all Loading... | |
57 new net::test_server::BasicHttpResponse); | 58 new net::test_server::BasicHttpResponse); |
58 response->set_content(base::StringPrintf("<title>%d</title>", | 59 response->set_content(base::StringPrintf("<title>%d</title>", |
59 request_count_)); | 60 request_count_)); |
60 response->set_content_type("text/html"); | 61 response->set_content_type("text/html"); |
61 response->AddCustomHeader("Cache-Control", "max-age=99999"); | 62 response->AddCustomHeader("Cache-Control", "max-age=99999"); |
62 return response.PassAs<net::test_server::HttpResponse>(); | 63 return response.PassAs<net::test_server::HttpResponse>(); |
63 } | 64 } |
64 private: | 65 private: |
65 std::string path_; | 66 std::string path_; |
66 int request_count_; | 67 int request_count_; |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(CacheMaxAgeHandler); | |
67 }; | 70 }; |
68 | 71 |
69 } // namespace | |
70 | |
71 class CrashRecoveryBrowserTest : public InProcessBrowserTest { | 72 class CrashRecoveryBrowserTest : public InProcessBrowserTest { |
72 protected: | 73 protected: |
73 WebContents* GetActiveWebContents() { | 74 WebContents* GetActiveWebContents() { |
74 return browser()->tab_strip_model()->GetActiveWebContents(); | 75 return browser()->tab_strip_model()->GetActiveWebContents(); |
75 } | 76 } |
77 | |
78 private: | |
79 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE { | |
80 command_line->AppendSwitch(switches::kDisableBreakpad); | |
Paweł Hajdan Jr.
2014/05/22 07:00:27
Don't we want to disable this for all browser test
Lei Zhang
2014/05/22 07:21:07
Several years ago, Chromium builds didn't have Bre
| |
81 } | |
76 }; | 82 }; |
77 | 83 |
78 // Test that reload works after a crash. | 84 // Test that reload works after a crash. |
79 // Disabled, http://crbug.com/29331 , http://crbug.com/69637 . | 85 // Disabled, http://crbug.com/29331 , http://crbug.com/69637 . |
80 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, Reload) { | 86 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, Reload) { |
81 // The title of the active tab should change each time this URL is loaded. | 87 // The title of the active tab should change each time this URL is loaded. |
82 GURL url( | 88 GURL url( |
83 "data:text/html,<script>document.title=new Date().valueOf()</script>"); | 89 "data:text/html,<script>document.title=new Date().valueOf()</script>"); |
84 ui_test_utils::NavigateToURL(browser(), url); | 90 ui_test_utils::NavigateToURL(browser(), url); |
85 | 91 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), | 126 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), |
121 &title_after_crash)); | 127 &title_after_crash)); |
122 EXPECT_NE(title_before_crash, title_after_crash); | 128 EXPECT_NE(title_before_crash, title_after_crash); |
123 } | 129 } |
124 | 130 |
125 // Tests that loading a crashed page in a new tab correctly updates the title. | 131 // Tests that loading a crashed page in a new tab correctly updates the title. |
126 // There was an earlier bug (1270510) in process-per-site in which the max page | 132 // There was an earlier bug (1270510) in process-per-site in which the max page |
127 // ID of the RenderProcessHost was stale, so the NavigationEntry in the new tab | 133 // ID of the RenderProcessHost was stale, so the NavigationEntry in the new tab |
128 // was not committed. This prevents regression of that bug. | 134 // was not committed. This prevents regression of that bug. |
129 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, LoadInNewTab) { | 135 IN_PROC_BROWSER_TEST_F(CrashRecoveryBrowserTest, LoadInNewTab) { |
130 const base::FilePath::CharType* kTitle2File = | 136 const base::FilePath::CharType kTitle2File[] = |
131 FILE_PATH_LITERAL("title2.html"); | 137 FILE_PATH_LITERAL("title2.html"); |
132 | 138 |
133 ui_test_utils::NavigateToURL( | 139 ui_test_utils::NavigateToURL( |
134 browser(), ui_test_utils::GetTestUrl( | 140 browser(), ui_test_utils::GetTestUrl( |
135 base::FilePath(base::FilePath::kCurrentDirectory), | 141 base::FilePath(base::FilePath::kCurrentDirectory), |
136 base::FilePath(kTitle2File))); | 142 base::FilePath(kTitle2File))); |
137 | 143 |
138 base::string16 title_before_crash; | 144 base::string16 title_before_crash; |
139 base::string16 title_after_crash; | 145 base::string16 title_after_crash; |
140 | 146 |
(...skipping 18 matching lines...) Expand all Loading... | |
159 | 165 |
160 chrome::Reload(browser(), CURRENT_TAB); | 166 chrome::Reload(browser(), CURRENT_TAB); |
161 content::WaitForLoadStop(GetActiveWebContents()); | 167 content::WaitForLoadStop(GetActiveWebContents()); |
162 ASSERT_EQ(url, GetActiveWebContents()->GetVisibleURL()); | 168 ASSERT_EQ(url, GetActiveWebContents()->GetVisibleURL()); |
163 | 169 |
164 chrome::Reload(browser(), CURRENT_TAB); | 170 chrome::Reload(browser(), CURRENT_TAB); |
165 content::WaitForLoadStop(GetActiveWebContents()); | 171 content::WaitForLoadStop(GetActiveWebContents()); |
166 ASSERT_EQ(url, GetActiveWebContents()->GetVisibleURL()); | 172 ASSERT_EQ(url, GetActiveWebContents()->GetVisibleURL()); |
167 } | 173 } |
168 | 174 |
175 } // namespace | |
176 | |
169 #endif | 177 #endif |
OLD | NEW |