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 24 matching lines...) Expand all Loading... |
35 if (page_title.empty()) | 35 if (page_title.empty()) |
36 return l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); | 36 return l10n_util::GetString(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); |
37 return page_title; | 37 return page_title; |
38 #endif | 38 #endif |
39 } | 39 } |
40 | 40 |
41 class BrowserTest : public UITest { | 41 class BrowserTest : public UITest { |
42 protected: | 42 protected: |
43 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
44 HWND GetMainWindow() { | 44 HWND GetMainWindow() { |
45 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 45 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
46 scoped_ptr<WindowProxy> window(browser->GetWindow()); | 46 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
47 | 47 |
48 HWND window_handle; | 48 HWND window_handle; |
49 EXPECT_TRUE(window->GetHWND(&window_handle)); | 49 EXPECT_TRUE(window->GetHWND(&window_handle)); |
50 return window_handle; | 50 return window_handle; |
51 } | 51 } |
52 #endif | 52 #endif |
53 | 53 |
54 std::wstring GetWindowTitle() { | 54 std::wstring GetWindowTitle() { |
55 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 55 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
56 scoped_ptr<WindowProxy> window(browser->GetWindow()); | 56 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
57 | 57 |
58 string16 title; | 58 string16 title; |
59 EXPECT_TRUE(window->GetWindowTitle(&title)); | 59 EXPECT_TRUE(window->GetWindowTitle(&title)); |
60 return UTF16ToWide(title); | 60 return UTF16ToWide(title); |
61 } | 61 } |
62 }; | 62 }; |
63 | 63 |
64 class VisibleBrowserTest : public UITest { | 64 class VisibleBrowserTest : public UITest { |
65 protected: | 65 protected: |
66 VisibleBrowserTest() : UITest() { | 66 VisibleBrowserTest() : UITest() { |
(...skipping 30 matching lines...) Expand all Loading... |
97 } | 97 } |
98 | 98 |
99 // Create 34 tabs and verify that a lot of processes have been created. The | 99 // Create 34 tabs and verify that a lot of processes have been created. The |
100 // exact number of processes depends on the amount of memory. Previously we | 100 // exact number of processes depends on the amount of memory. Previously we |
101 // had a hard limit of 31 processes and this test is mainly directed at | 101 // had a hard limit of 31 processes and this test is mainly directed at |
102 // verifying that we don't crash when we pass this limit. | 102 // verifying that we don't crash when we pass this limit. |
103 TEST_F(BrowserTest, ThirtyFourTabs) { | 103 TEST_F(BrowserTest, ThirtyFourTabs) { |
104 FilePath test_file(test_data_directory_); | 104 FilePath test_file(test_data_directory_); |
105 test_file = test_file.AppendASCII("title2.html"); | 105 test_file = test_file.AppendASCII("title2.html"); |
106 GURL url(net::FilePathToFileURL(test_file)); | 106 GURL url(net::FilePathToFileURL(test_file)); |
107 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 107 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
108 // There is one initial tab. | 108 // There is one initial tab. |
109 for (int ix = 0; ix != 33; ++ix) { | 109 for (int ix = 0; ix != 33; ++ix) { |
110 EXPECT_TRUE(window->AppendTab(url)); | 110 EXPECT_TRUE(window->AppendTab(url)); |
111 } | 111 } |
112 int tab_count = 0; | 112 int tab_count = 0; |
113 EXPECT_TRUE(window->GetTabCount(&tab_count)); | 113 EXPECT_TRUE(window->GetTabCount(&tab_count)); |
114 EXPECT_EQ(34, tab_count); | 114 EXPECT_EQ(34, tab_count); |
115 // Do not test the rest in single process mode. | 115 // Do not test the rest in single process mode. |
116 if (in_process_renderer()) | 116 if (in_process_renderer()) |
117 return; | 117 return; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); | 160 scoped_ptr<DictionaryValue> profile_prefs(GetDefaultProfilePreferences()); |
161 ASSERT_TRUE(profile_prefs.get()); | 161 ASSERT_TRUE(profile_prefs.get()); |
162 ASSERT_TRUE(profile_prefs->GetBoolean(prefs::kSessionExitedCleanly, | 162 ASSERT_TRUE(profile_prefs->GetBoolean(prefs::kSessionExitedCleanly, |
163 &exited_cleanly)); | 163 &exited_cleanly)); |
164 ASSERT_TRUE(exited_cleanly); | 164 ASSERT_TRUE(exited_cleanly); |
165 } | 165 } |
166 #endif | 166 #endif |
167 | 167 |
168 // This test is flakey, see bug 5668 for details. | 168 // This test is flakey, see bug 5668 for details. |
169 TEST_F(BrowserTest, DISABLED_JavascriptAlertActivatesTab) { | 169 TEST_F(BrowserTest, DISABLED_JavascriptAlertActivatesTab) { |
170 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 170 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
171 int start_index; | 171 int start_index; |
172 ASSERT_TRUE(window->GetActiveTabIndex(&start_index)); | 172 ASSERT_TRUE(window->GetActiveTabIndex(&start_index)); |
173 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); | 173 ASSERT_TRUE(window->AppendTab(GURL("about:blank"))); |
174 int javascript_tab_index; | 174 int javascript_tab_index; |
175 ASSERT_TRUE(window->GetActiveTabIndex(&javascript_tab_index)); | 175 ASSERT_TRUE(window->GetActiveTabIndex(&javascript_tab_index)); |
176 TabProxy* javascript_tab = window->GetActiveTab(); | 176 scoped_refptr<TabProxy> javascript_tab = window->GetActiveTab(); |
177 // Switch back to the starting tab, then send the second tab a javascript | 177 // Switch back to the starting tab, then send the second tab a javascript |
178 // alert, which should force it to become active. | 178 // alert, which should force it to become active. |
179 ASSERT_TRUE(window->ActivateTab(start_index)); | 179 ASSERT_TRUE(window->ActivateTab(start_index)); |
180 ASSERT_TRUE( | 180 ASSERT_TRUE( |
181 javascript_tab->NavigateToURLAsync(GURL("javascript:alert('Alert!')"))); | 181 javascript_tab->NavigateToURLAsync(GURL("javascript:alert('Alert!')"))); |
182 ASSERT_TRUE(window->WaitForTabToBecomeActive(javascript_tab_index, | 182 ASSERT_TRUE(window->WaitForTabToBecomeActive(javascript_tab_index, |
183 action_max_timeout_ms())); | 183 action_max_timeout_ms())); |
184 } | 184 } |
185 | 185 |
186 // Test that scripts can fork a new renderer process for a tab in a particular | 186 // Test that scripts can fork a new renderer process for a tab in a particular |
187 // case (which matches following a link in Gmail). The script must open a new | 187 // case (which matches following a link in Gmail). The script must open a new |
188 // tab, set its window.opener to null, and redirect it to a cross-site URL. | 188 // tab, set its window.opener to null, and redirect it to a cross-site URL. |
189 // (Bug 1115708) | 189 // (Bug 1115708) |
190 // This test can only run if V8 is in use, and not KJS, because KJS will not | 190 // This test can only run if V8 is in use, and not KJS, because KJS will not |
191 // set window.opener to null properly. | 191 // set window.opener to null properly. |
192 #ifdef CHROME_V8 | 192 #ifdef CHROME_V8 |
193 TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { | 193 TEST_F(BrowserTest, NullOpenerRedirectForksProcess) { |
194 // This test only works in multi-process mode | 194 // This test only works in multi-process mode |
195 if (in_process_renderer()) | 195 if (in_process_renderer()) |
196 return; | 196 return; |
197 | 197 |
198 const wchar_t kDocRoot[] = L"chrome/test/data"; | 198 const wchar_t kDocRoot[] = L"chrome/test/data"; |
199 scoped_refptr<HTTPTestServer> server = | 199 scoped_refptr<HTTPTestServer> server = |
200 HTTPTestServer::CreateServer(kDocRoot, NULL); | 200 HTTPTestServer::CreateServer(kDocRoot, NULL); |
201 ASSERT_TRUE(NULL != server.get()); | 201 ASSERT_TRUE(NULL != server.get()); |
202 FilePath test_file(test_data_directory_); | 202 FilePath test_file(test_data_directory_); |
203 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 203 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
204 scoped_ptr<TabProxy> tab(window->GetActiveTab()); | 204 scoped_refptr<TabProxy> tab(window->GetActiveTab()); |
205 | 205 |
206 // Start with a file:// url | 206 // Start with a file:// url |
207 test_file = test_file.AppendASCII("title2.html"); | 207 test_file = test_file.AppendASCII("title2.html"); |
208 tab->NavigateToURL(net::FilePathToFileURL(test_file)); | 208 tab->NavigateToURL(net::FilePathToFileURL(test_file)); |
209 int orig_tab_count = -1; | 209 int orig_tab_count = -1; |
210 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); | 210 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); |
211 int orig_process_count = GetBrowserProcessCount(); | 211 int orig_process_count = GetBrowserProcessCount(); |
212 ASSERT_GE(orig_process_count, 1); | 212 ASSERT_GE(orig_process_count, 1); |
213 | 213 |
214 // Use JavaScript URL to "fork" a new tab, just like Gmail. (Open tab to a | 214 // Use JavaScript URL to "fork" a new tab, just like Gmail. (Open tab to a |
(...skipping 20 matching lines...) Expand all Loading... |
235 TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { | 235 TEST_F(BrowserTest, OtherRedirectsDontForkProcess) { |
236 // This test only works in multi-process mode | 236 // This test only works in multi-process mode |
237 if (in_process_renderer()) | 237 if (in_process_renderer()) |
238 return; | 238 return; |
239 | 239 |
240 const wchar_t kDocRoot[] = L"chrome/test/data"; | 240 const wchar_t kDocRoot[] = L"chrome/test/data"; |
241 scoped_refptr<HTTPTestServer> server = | 241 scoped_refptr<HTTPTestServer> server = |
242 HTTPTestServer::CreateServer(kDocRoot, NULL); | 242 HTTPTestServer::CreateServer(kDocRoot, NULL); |
243 ASSERT_TRUE(NULL != server.get()); | 243 ASSERT_TRUE(NULL != server.get()); |
244 FilePath test_file(test_data_directory_); | 244 FilePath test_file(test_data_directory_); |
245 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 245 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
246 scoped_ptr<TabProxy> tab(window->GetActiveTab()); | 246 scoped_refptr<TabProxy> tab(window->GetActiveTab()); |
247 | 247 |
248 // Start with a file:// url | 248 // Start with a file:// url |
249 test_file = test_file.AppendASCII("title2.html"); | 249 test_file = test_file.AppendASCII("title2.html"); |
250 tab->NavigateToURL(net::FilePathToFileURL(test_file)); | 250 tab->NavigateToURL(net::FilePathToFileURL(test_file)); |
251 int orig_tab_count = -1; | 251 int orig_tab_count = -1; |
252 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); | 252 ASSERT_TRUE(window->GetTabCount(&orig_tab_count)); |
253 int orig_process_count = GetBrowserProcessCount(); | 253 int orig_process_count = GetBrowserProcessCount(); |
254 ASSERT_GE(orig_process_count, 1); | 254 ASSERT_GE(orig_process_count, 1); |
255 | 255 |
256 // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the | 256 // Use JavaScript URL to almost fork a new tab, but not quite. (Leave the |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 break; | 295 break; |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 if (i == 10) | 299 if (i == 10) |
300 FAIL() << "failed to get error page title"; | 300 FAIL() << "failed to get error page title"; |
301 } | 301 } |
302 #endif | 302 #endif |
303 | 303 |
304 } // namespace | 304 } // namespace |
OLD | NEW |