OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/file_util.h" | 5 #include "base/file_util.h" |
6 | 6 |
7 #include "chrome/browser/automation/url_request_mock_http_job.h" | 7 #include "chrome/browser/automation/url_request_mock_http_job.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
9 #include "chrome/test/automation/browser_proxy.h" | 9 #include "chrome/test/automation/browser_proxy.h" |
10 #include "chrome/test/ui/ui_test.h" | 10 #include "chrome/test/ui/ui_test.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 EXPECT_TRUE((button & available_buttons) != NULL); | 146 EXPECT_TRUE((button & available_buttons) != NULL); |
147 EXPECT_TRUE(automation()->ClickAppModalDialogButton(button)); | 147 EXPECT_TRUE(automation()->ClickAppModalDialogButton(button)); |
148 } | 148 } |
149 }; | 149 }; |
150 | 150 |
151 // Navigate to a page with an infinite unload handler. | 151 // Navigate to a page with an infinite unload handler. |
152 // Then two two async crosssite requests to ensure | 152 // Then two two async crosssite requests to ensure |
153 // we don't get confused and think we're closing the tab. | 153 // we don't get confused and think we're closing the tab. |
154 TEST_F(UnloadTest, CrossSiteInfiniteUnloadAsync) { | 154 TEST_F(UnloadTest, CrossSiteInfiniteUnloadAsync) { |
155 // Tests makes no sense in single-process mode since the renderer is hung. | 155 // Tests makes no sense in single-process mode since the renderer is hung. |
156 if (CommandLine().HasSwitch(switches::kSingleProcess)) | 156 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
157 return; | 157 return; |
158 | 158 |
159 NavigateToDataURL(INFINITE_UNLOAD_HTML, L"infiniteunload"); | 159 NavigateToDataURL(INFINITE_UNLOAD_HTML, L"infiniteunload"); |
160 // Must navigate to a non-data URL to trigger cross-site codepath. | 160 // Must navigate to a non-data URL to trigger cross-site codepath. |
161 NavigateToNolistenersFileTwiceAsync(); | 161 NavigateToNolistenersFileTwiceAsync(); |
162 ASSERT_TRUE(IsBrowserRunning()); | 162 ASSERT_TRUE(IsBrowserRunning()); |
163 } | 163 } |
164 | 164 |
165 // Navigate to a page with an infinite unload handler. | 165 // Navigate to a page with an infinite unload handler. |
166 // Then two two sync crosssite requests to ensure | 166 // Then two two sync crosssite requests to ensure |
167 // we correctly nav to each one. | 167 // we correctly nav to each one. |
168 TEST_F(UnloadTest, CrossSiteInfiniteUnloadSync) { | 168 TEST_F(UnloadTest, CrossSiteInfiniteUnloadSync) { |
169 // Tests makes no sense in single-process mode since the renderer is hung. | 169 // Tests makes no sense in single-process mode since the renderer is hung. |
170 if (CommandLine().HasSwitch(switches::kSingleProcess)) | 170 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
171 return; | 171 return; |
172 | 172 |
173 NavigateToDataURL(INFINITE_UNLOAD_HTML, L"infiniteunload"); | 173 NavigateToDataURL(INFINITE_UNLOAD_HTML, L"infiniteunload"); |
174 // Must navigate to a non-data URL to trigger cross-site codepath. | 174 // Must navigate to a non-data URL to trigger cross-site codepath. |
175 NavigateToNolistenersFileTwice(); | 175 NavigateToNolistenersFileTwice(); |
176 ASSERT_TRUE(IsBrowserRunning()); | 176 ASSERT_TRUE(IsBrowserRunning()); |
177 } | 177 } |
178 | 178 |
179 // Navigate to a page with an infinite beforeunload handler. | 179 // Navigate to a page with an infinite beforeunload handler. |
180 // Then two two async crosssite requests to ensure | 180 // Then two two async crosssite requests to ensure |
181 // we don't get confused and think we're closing the tab. | 181 // we don't get confused and think we're closing the tab. |
182 TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadAsync) { | 182 TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadAsync) { |
183 // Tests makes no sense in single-process mode since the renderer is hung. | 183 // Tests makes no sense in single-process mode since the renderer is hung. |
184 if (CommandLine().HasSwitch(switches::kSingleProcess)) | 184 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
185 return; | 185 return; |
186 | 186 |
187 NavigateToDataURL(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload"); | 187 NavigateToDataURL(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload"); |
188 // Must navigate to a non-data URL to trigger cross-site codepath. | 188 // Must navigate to a non-data URL to trigger cross-site codepath. |
189 NavigateToNolistenersFileTwiceAsync(); | 189 NavigateToNolistenersFileTwiceAsync(); |
190 ASSERT_TRUE(IsBrowserRunning()); | 190 ASSERT_TRUE(IsBrowserRunning()); |
191 } | 191 } |
192 | 192 |
193 // Navigate to a page with an infinite beforeunload handler. | 193 // Navigate to a page with an infinite beforeunload handler. |
194 // Then two two sync crosssite requests to ensure | 194 // Then two two sync crosssite requests to ensure |
195 // we correctly nav to each one. | 195 // we correctly nav to each one. |
196 TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadSync) { | 196 TEST_F(UnloadTest, CrossSiteInfiniteBeforeUnloadSync) { |
197 // Tests makes no sense in single-process mode since the renderer is hung. | 197 // Tests makes no sense in single-process mode since the renderer is hung. |
198 if (CommandLine().HasSwitch(switches::kSingleProcess)) | 198 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
199 return; | 199 return; |
200 | 200 |
201 NavigateToDataURL(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload"); | 201 NavigateToDataURL(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload"); |
202 // Must navigate to a non-data URL to trigger cross-site codepath. | 202 // Must navigate to a non-data URL to trigger cross-site codepath. |
203 NavigateToNolistenersFileTwice(); | 203 NavigateToNolistenersFileTwice(); |
204 ASSERT_TRUE(IsBrowserRunning()); | 204 ASSERT_TRUE(IsBrowserRunning()); |
205 } | 205 } |
206 | 206 |
207 // Tests closing the browser on a page with no unload listeners registered. | 207 // Tests closing the browser on a page with no unload listeners registered. |
208 TEST_F(UnloadTest, BrowserCloseNoUnloadListeners) { | 208 TEST_F(UnloadTest, BrowserCloseNoUnloadListeners) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 // Tests closing the browser with a beforeunload handler that takes | 283 // Tests closing the browser with a beforeunload handler that takes |
284 // two seconds to run then pops up an alert. | 284 // two seconds to run then pops up an alert. |
285 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { | 285 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { |
286 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML, | 286 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML, |
287 L"twosecondbeforeunloadalert"); | 287 L"twosecondbeforeunloadalert"); |
288 } | 288 } |
289 | 289 |
290 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 290 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
291 // and multiple windows. | 291 // and multiple windows. |
OLD | NEW |