Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/browser/browser_uitest.cc

Issue 149460: Convert JavascriptAlertActivatesTab to browser_tests framework. (Closed)
Patch Set: kill duplication Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_path.h" 5 #include "base/file_path.h"
6 #include "base/gfx/native_widget_types.h" 6 #include "base/gfx/native_widget_types.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Make sure session restore says we didn't crash. 107 // Make sure session restore says we didn't crash.
108 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); 108 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences());
109 ASSERT_TRUE(profile_prefs.get()); 109 ASSERT_TRUE(profile_prefs.get());
110 ASSERT_TRUE(profile_prefs->GetBoolean(prefs::kSessionExitedCleanly, 110 ASSERT_TRUE(profile_prefs->GetBoolean(prefs::kSessionExitedCleanly,
111 &exited_cleanly)); 111 &exited_cleanly));
112 ASSERT_TRUE(exited_cleanly); 112 ASSERT_TRUE(exited_cleanly);
113 } 113 }
114 #endif 114 #endif
115 115
116 // This test is flakey, see bug 5668 for details.
117 TEST_F(BrowserTest, DISABLED_JavascriptAlertActivatesTab) {
118 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
119 int start_index;
120 ASSERT_TRUE(window->GetActiveTabIndex(&start_index));
121 ASSERT_TRUE(window->AppendTab(GURL("about:blank")));
122 int javascript_tab_index;
123 ASSERT_TRUE(window->GetActiveTabIndex(&javascript_tab_index));
124 scoped_refptr<TabProxy> javascript_tab = window->GetActiveTab();
125 ASSERT_TRUE(javascript_tab.get());
126 // Switch back to the starting tab, then send the second tab a javascript
127 // alert, which should force it to become active.
128 ASSERT_TRUE(window->ActivateTab(start_index));
129 ASSERT_TRUE(
130 javascript_tab->NavigateToURLAsync(GURL("javascript:alert('Alert!')")));
131 ASSERT_TRUE(window->WaitForTabToBecomeActive(javascript_tab_index,
132 action_max_timeout_ms()));
133 }
134
135 // Test that scripts can fork a new renderer process for a tab in a particular 116 // Test that scripts can fork a new renderer process for a tab in a particular
136 // case (which matches following a link in Gmail). The script must open a new 117 // case (which matches following a link in Gmail). The script must open a new
137 // tab, set its window.opener to null, and redirect it to a cross-site URL. 118 // tab, set its window.opener to null, and redirect it to a cross-site URL.
138 // (Bug 1115708) 119 // (Bug 1115708)
139 // This test can only run if V8 is in use, and not KJS, because KJS will not 120 // This test can only run if V8 is in use, and not KJS, because KJS will not
140 // set window.opener to null properly. 121 // set window.opener to null properly.
141 #ifdef CHROME_V8 122 #ifdef CHROME_V8
142 TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { 123 TEST_F(BrowserTest, NullOpenerRedirectForksProcess) {
143 // This test only works in multi-process mode 124 // This test only works in multi-process mode
144 if (in_process_renderer()) 125 if (in_process_renderer())
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 259
279 // Test that window.close() works. Since we don't have a way of executing a 260 // Test that window.close() works. Since we don't have a way of executing a
280 // JS function on the page through TabProxy, reload it and use an unload 261 // JS function on the page through TabProxy, reload it and use an unload
281 // handler that closes the page. 262 // handler that closes the page.
282 ASSERT_EQ(tab->Reload(), AUTOMATION_MSG_NAVIGATION_SUCCESS); 263 ASSERT_EQ(tab->Reload(), AUTOMATION_MSG_NAVIGATION_SUCCESS);
283 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(1, action_timeout_ms())); 264 ASSERT_TRUE(automation()->WaitForWindowCountToBecome(1, action_timeout_ms()));
284 } 265 }
285 #endif 266 #endif
286 267
287 } // namespace 268 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698