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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/gfx/native_widget_types.h" | 7 #include "base/gfx/native_widget_types.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // This test is flakey, see bug 5668 for details. | 192 // This test is flakey, see bug 5668 for details. |
193 TEST_F(BrowserTest, DISABLED_JavascriptAlertActivatesTab) { | 193 TEST_F(BrowserTest, DISABLED_JavascriptAlertActivatesTab) { |
194 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 194 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
195 int start_index; | 195 int start_index; |
196 ASSERT_TRUE(window->GetActiveTabIndex(&start_index)); | 196 ASSERT_TRUE(window->GetActiveTabIndex(&start_index)); |
197 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); | 197 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); |
198 int javascript_tab_index; | 198 int javascript_tab_index; |
199 ASSERT_TRUE(window->GetActiveTabIndex(&javascript_tab_index)); | 199 ASSERT_TRUE(window->GetActiveTabIndex(&javascript_tab_index)); |
200 scoped_refptr<TabProxy> javascript_tab = window->GetActiveTab(); | 200 scoped_refptr<TabProxy> javascript_tab = window->GetActiveTab(); |
| 201 ASSERT_TRUE(javascript_tab.get()); |
201 // Switch back to the starting tab, then send the second tab a javascript | 202 // Switch back to the starting tab, then send the second tab a javascript |
202 // alert, which should force it to become active. | 203 // alert, which should force it to become active. |
203 ASSERT_TRUE(window->ActivateTab(start_index)); | 204 ASSERT_TRUE(window->ActivateTab(start_index)); |
204 ASSERT_TRUE( | 205 ASSERT_TRUE( |
205 javascript_tab->NavigateToURLAsync(GURL("javascript:alert('Alert!')"))); | 206 javascript_tab->NavigateToURLAsync(GURL("javascript:alert('Alert!')"))); |
206 ASSERT_TRUE(window->WaitForTabToBecomeActive(javascript_tab_index, | 207 ASSERT_TRUE(window->WaitForTabToBecomeActive(javascript_tab_index, |
207 action_max_timeout_ms())); | 208 action_max_timeout_ms())); |
208 } | 209 } |
209 | 210 |
210 // Test that scripts can fork a new renderer process for a tab in a particular | 211 // Test that scripts can fork a new renderer process for a tab in a particular |
211 // case (which matches following a link in Gmail). The script must open a new | 212 // case (which matches following a link in Gmail). The script must open a new |
212 // tab, set its window.opener to null, and redirect it to a cross-site URL. | 213 // tab, set its window.opener to null, and redirect it to a cross-site URL. |
213 // (Bug 1115708) | 214 // (Bug 1115708) |
214 // This test can only run if V8 is in use, and not KJS, because KJS will not | 215 // This test can only run if V8 is in use, and not KJS, because KJS will not |
215 // set window.opener to null properly. | 216 // set window.opener to null properly. |
216 #ifdef CHROME_V8 | 217 #ifdef CHROME_V8 |
217 TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { | 218 TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { |
218 // This test only works in multi-process mode | 219 // This test only works in multi-process mode |
219 if (in_process_renderer()) | 220 if (in_process_renderer()) |
220 return; | 221 return; |
221 | 222 |
222 const wchar_t kDocRoot[] = L"chrome/test/data"; | 223 const wchar_t kDocRoot[] = L"chrome/test/data"; |
223 scoped_refptr<HTTPTestServer> server = | 224 scoped_refptr<HTTPTestServer> server = |
224 HTTPTestServer::CreateServer(kDocRoot, NULL); | 225 HTTPTestServer::CreateServer(kDocRoot, NULL); |
225 ASSERT_TRUE(NULL != server.get()); | 226 ASSERT_TRUE(NULL != server.get()); |
226 FilePath test_file(test_data_directory_); | 227 FilePath test_file(test_data_directory_); |
227 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 228 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
228 scoped_refptr<TabProxy> tab(window->GetActiveTab()); | 229 scoped_refptr<TabProxy> tab(window->GetActiveTab()); |
| 230 ASSERT_TRUE(tab.get()); |
229 | 231 |
230 // Start with a file:// url | 232 // Start with a file:// url |
231 test_file = test_file.AppendASCII("title2.html"); | 233 test_file = test_file.AppendASCII("title2.html"); |
232 tab->NavigateToURL(net::FilePathToFileURL(test_file)); | 234 tab->NavigateToURL(net::FilePathToFileURL(test_file)); |
233 int orig_tab_count = -1; | 235 int orig_tab_count = -1; |
234 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); | 236 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); |
235 int orig_process_count = GetBrowserProcessCount(); | 237 int orig_process_count = GetBrowserProcessCount(); |
236 ASSERT_GE(orig_process_count, 1); | 238 ASSERT_GE(orig_process_count, 1); |
237 | 239 |
238 // Use JavaScript URL to "fork" a new tab, just like Gmail. (Open tab to a | 240 // Use JavaScript URL to "fork" a new tab, just like Gmail. (Open tab to a |
(...skipping 22 matching lines...) Expand all Loading... |
261 if (in_process_renderer()) | 263 if (in_process_renderer()) |
262 return; | 264 return; |
263 | 265 |
264 const wchar_t kDocRoot[] = L"chrome/test/data"; | 266 const wchar_t kDocRoot[] = L"chrome/test/data"; |
265 scoped_refptr<HTTPTestServer> server = | 267 scoped_refptr<HTTPTestServer> server = |
266 HTTPTestServer::CreateServer(kDocRoot, NULL); | 268 HTTPTestServer::CreateServer(kDocRoot, NULL); |
267 ASSERT_TRUE(NULL != server.get()); | 269 ASSERT_TRUE(NULL != server.get()); |
268 FilePath test_file(test_data_directory_); | 270 FilePath test_file(test_data_directory_); |
269 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 271 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
270 scoped_refptr<TabProxy> tab(window->GetActiveTab()); | 272 scoped_refptr<TabProxy> tab(window->GetActiveTab()); |
| 273 ASSERT_TRUE(tab.get()); |
271 | 274 |
272 // Start with a file:// url | 275 // Start with a file:// url |
273 test_file = test_file.AppendASCII("title2.html"); | 276 test_file = test_file.AppendASCII("title2.html"); |
274 tab->NavigateToURL(net::FilePathToFileURL(test_file)); | 277 tab->NavigateToURL(net::FilePathToFileURL(test_file)); |
275 int orig_tab_count = -1; | 278 int orig_tab_count = -1; |
276 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); | 279 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); |
277 int orig_process_count = GetBrowserProcessCount(); | 280 int orig_process_count = GetBrowserProcessCount(); |
278 ASSERT_GE(orig_process_count, 1); | 281 ASSERT_GE(orig_process_count, 1); |
279 | 282 |
280 // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the | 283 // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 338 |
336 TEST_F(ShowModalDialogTest, BasicTest) { | 339 TEST_F(ShowModalDialogTest, BasicTest) { |
337 FilePath test_file(test_data_directory_); | 340 FilePath test_file(test_data_directory_); |
338 test_file = test_file.AppendASCII("showmodaldialog.html"); | 341 test_file = test_file.AppendASCII("showmodaldialog.html"); |
339 NavigateToURL(net::FilePathToFileURL(test_file)); | 342 NavigateToURL(net::FilePathToFileURL(test_file)); |
340 | 343 |
341 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, action_timeout_ms())); | 344 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(2, action_timeout_ms())); |
342 | 345 |
343 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(1); | 346 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(1); |
344 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); | 347 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); |
| 348 ASSERT_TRUE(tab.get()); |
345 | 349 |
346 std::wstring title; | 350 std::wstring title; |
347 ASSERT_TRUE(tab->GetTabTitle(&title)); | 351 ASSERT_TRUE(tab->GetTabTitle(&title)); |
348 ASSERT_EQ(title, L"ModalDialogTitle"); | 352 ASSERT_EQ(title, L"ModalDialogTitle"); |
349 } | 353 } |
350 #endif | 354 #endif |
351 | 355 |
352 } // namespace | 356 } // namespace |
OLD | NEW |