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

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

Issue 464039: enabled one browser test and tag JavascriptAlertActivatesTab, ReloadThenCance... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <string> 5 #include <string>
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/sys_info.h" 8 #include "base/sys_info.h"
9 #include "chrome/app/chrome_dll_resource.h" 9 #include "chrome/app/chrome_dll_resource.h"
10 #include "chrome/browser/app_modal_dialog.h" 10 #include "chrome/browser/app_modal_dialog.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 ui_test_utils::NavigateToURL(browser(), 97 ui_test_utils::NavigateToURL(browser(),
98 ui_test_utils::GetTestUrl(L".", L"title2.html")); 98 ui_test_utils::GetTestUrl(L".", L"title2.html"));
99 const std::wstring test_title(L"Title Of Awesomeness"); 99 const std::wstring test_title(L"Title Of Awesomeness");
100 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), 100 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title),
101 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab())); 101 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab()));
102 string16 tab_title; 102 string16 tab_title;
103 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); 103 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title));
104 EXPECT_EQ(WideToUTF16(test_title), tab_title); 104 EXPECT_EQ(WideToUTF16(test_title), tab_title);
105 } 105 }
106 106
107 #if !defined(OS_MACOSX) 107 #if defined(OS_MACOSX)
108 // TODO(port): BUG16322 108 // http://crbug.com//29424
109 #define JavascriptAlertActivatesTab DISABLED_JavascriptAlertActivatesTab
110 #endif
111
109 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { 112 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) {
110 GURL url(ui_test_utils::GetTestUrl(L".", L"title1.html")); 113 GURL url(ui_test_utils::GetTestUrl(L".", L"title1.html"));
111 ui_test_utils::NavigateToURL(browser(), url); 114 ui_test_utils::NavigateToURL(browser(), url);
112 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 115 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED,
113 true, 0, false, NULL); 116 true, 0, false, NULL);
114 EXPECT_EQ(2, browser()->tab_count()); 117 EXPECT_EQ(2, browser()->tab_count());
115 EXPECT_EQ(0, browser()->selected_index()); 118 EXPECT_EQ(0, browser()->selected_index());
116 TabContents* second_tab = browser()->GetTabContentsAt(1); 119 TabContents* second_tab = browser()->GetTabContentsAt(1);
117 ASSERT_TRUE(second_tab); 120 ASSERT_TRUE(second_tab);
118 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"", 121 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"",
119 L"alert('Activate!');"); 122 L"alert('Activate!');");
120 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 123 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
121 alert->CloseModalDialog(); 124 alert->CloseModalDialog();
122 EXPECT_EQ(2, browser()->tab_count()); 125 EXPECT_EQ(2, browser()->tab_count());
123 EXPECT_EQ(1, browser()->selected_index()); 126 EXPECT_EQ(1, browser()->selected_index());
124 } 127 }
125 #endif // !defined(OS_MACOSX)
126 128
127 // Create 34 tabs and verify that a lot of processes have been created. The 129 // Create 34 tabs and verify that a lot of processes have been created. The
128 // exact number of processes depends on the amount of memory. Previously we 130 // exact number of processes depends on the amount of memory. Previously we
129 // had a hard limit of 31 processes and this test is mainly directed at 131 // had a hard limit of 31 processes and this test is mainly directed at
130 // verifying that we don't crash when we pass this limit. 132 // verifying that we don't crash when we pass this limit.
131 IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) { 133 IN_PROC_BROWSER_TEST_F(BrowserTest, ThirtyFourTabs) {
132 GURL url(ui_test_utils::GetTestUrl(L".", L"title2.html")); 134 GURL url(ui_test_utils::GetTestUrl(L".", L"title2.html"));
133 135
134 // There is one initial tab. 136 // There is one initial tab.
135 for (int ix = 0; ix != 33; ++ix) { 137 for (int ix = 0; ix != 33; ++ix) {
136 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, 138 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED,
137 true, 0, false, NULL); 139 true, 0, false, NULL);
138 } 140 }
139 EXPECT_EQ(34, browser()->tab_count()); 141 EXPECT_EQ(34, browser()->tab_count());
140 142
141 // See browser\renderer_host\render_process_host.cc for the algorithm to 143 // See browser\renderer_host\render_process_host.cc for the algorithm to
142 // decide how many processes to create. 144 // decide how many processes to create.
143 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { 145 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) {
144 EXPECT_GE(CountRenderProcessHosts(), 24); 146 EXPECT_GE(CountRenderProcessHosts(), 24);
145 } else { 147 } else {
146 EXPECT_LE(CountRenderProcessHosts(), 23); 148 EXPECT_LE(CountRenderProcessHosts(), 23);
147 } 149 }
148 } 150 }
149 151
152 #if defined(OS_MACOSX)
153 // http://crbug.com//29424
154 #define ReloadThenCancelBeforeUnload DISABLED_ReloadThenCancelBeforeUnload
155 #endif
156
150 // Test for crbug.com/22004. Reloading a page with a before unload handler and 157 // Test for crbug.com/22004. Reloading a page with a before unload handler and
151 // then canceling the dialog should not leave the throbber spinning. 158 // then canceling the dialog should not leave the throbber spinning.
152 #if defined(OS_MACOSX)
153 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ReloadThenCancelBeforeUnload) {
154 #else
155 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { 159 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
156 #endif
157 GURL url("data:text/html," + BEFORE_UNLOAD_HTML); 160 GURL url("data:text/html," + BEFORE_UNLOAD_HTML);
158 ui_test_utils::NavigateToURL(browser(), url); 161 ui_test_utils::NavigateToURL(browser(), url);
159 162
160 // Navigate to another page, but click cancel in the dialog. Make sure that 163 // Navigate to another page, but click cancel in the dialog. Make sure that
161 // the throbber stops spinning. 164 // the throbber stops spinning.
162 browser()->Reload(); 165 browser()->Reload();
163 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 166 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
164 alert->CloseModalDialog(); 167 alert->CloseModalDialog();
165 EXPECT_FALSE(browser()->GetSelectedTabContents()->is_loading()); 168 EXPECT_FALSE(browser()->GetSelectedTabContents()->is_loading());
166 169
167 // Clear the beforeunload handler so the test can easily exit. 170 // Clear the beforeunload handler so the test can easily exit.
168 browser()->GetSelectedTabContents()->render_view_host()-> 171 browser()->GetSelectedTabContents()->render_view_host()->
169 ExecuteJavascriptInWebFrame(L"", L"onbeforeunload=null;"); 172 ExecuteJavascriptInWebFrame(L"", L"onbeforeunload=null;");
170 } 173 }
171 174
175 #if defined(OS_MACOSX)
176 // http://crbug.com//29424
177 #define MAYBE_SingleBeforeUnloadAfterWindowClose DISABLED_SingleBeforeUnloadAfte rWindowClose
178 #else
179 #define MAYBE_SingleBeforeUnloadAfterWindowClose FLAKY_SingleBeforeUnloadAfterWi ndowClose
180 #endif
181
172 // Test for crbug.com/11647. A page closed with window.close() should not have 182 // Test for crbug.com/11647. A page closed with window.close() should not have
173 // two beforeunload dialogs shown. 183 // two beforeunload dialogs shown.
174 #if defined(OS_MACOSX) 184 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) {
175 IN_PROC_BROWSER_TEST_F(BrowserTest,
176 DISABLED_SingleBeforeUnloadAfterWindowClose) {
177 #else
178 IN_PROC_BROWSER_TEST_F(BrowserTest, FLAKY_SingleBeforeUnloadAfterWindowClose) {
179 #endif
180 browser()->GetSelectedTabContents()->render_view_host()-> 185 browser()->GetSelectedTabContents()->render_view_host()->
181 ExecuteJavascriptInWebFrame(L"", OPEN_NEW_BEFOREUNLOAD_PAGE); 186 ExecuteJavascriptInWebFrame(L"", OPEN_NEW_BEFOREUNLOAD_PAGE);
182 187
183 // Close the new window with JavaScript, which should show a single 188 // Close the new window with JavaScript, which should show a single
184 // beforeunload dialog. Then show another alert, to make it easy to verify 189 // beforeunload dialog. Then show another alert, to make it easy to verify
185 // that a second beforeunload dialog isn't shown. 190 // that a second beforeunload dialog isn't shown.
186 browser()->GetTabContentsAt(0)->render_view_host()-> 191 browser()->GetTabContentsAt(0)->render_view_host()->
187 ExecuteJavascriptInWebFrame(L"", L"w.close(); alert('bar');"); 192 ExecuteJavascriptInWebFrame(L"", L"w.close(); alert('bar');");
188 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 193 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
189 alert->AcceptWindow(); 194 alert->AcceptWindow();
(...skipping 13 matching lines...) Expand all
203 for (; !it.IsAtEnd(); it.Advance()) { 208 for (; !it.IsAtEnd(); it.Advance()) {
204 base::TimeDelta renderer_td = 209 base::TimeDelta renderer_td =
205 it.GetCurrentValue()->get_child_process_idle_time(); 210 it.GetCurrentValue()->get_child_process_idle_time();
206 base::TimeDelta browser_td = base::TimeTicks::Now() - start; 211 base::TimeDelta browser_td = base::TimeTicks::Now() - start;
207 EXPECT_TRUE(browser_td >= renderer_td); 212 EXPECT_TRUE(browser_td >= renderer_td);
208 } 213 }
209 } 214 }
210 215
211 // Test IDC_CREATE_SHORTCUTS command is enabled for url scheme file, ftp, http 216 // Test IDC_CREATE_SHORTCUTS command is enabled for url scheme file, ftp, http
212 // and https and disabled for chrome://, about:// etc. 217 // and https and disabled for chrome://, about:// etc.
213 #if defined(OS_MACOSX)
214 IN_PROC_BROWSER_TEST_F(BrowserTest,
215 DISABLED_CommandCreateAppShortcut) {
216 #else
217 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcut) { 218 IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcut) {
218 #endif
219 static const wchar_t kDocRoot[] = L"chrome/test/data"; 219 static const wchar_t kDocRoot[] = L"chrome/test/data";
220 220
221 CommandUpdater* command_updater = browser()->command_updater(); 221 CommandUpdater* command_updater = browser()->command_updater();
222 222
223 // Urls that are okay to have shortcuts. 223 // Urls that are okay to have shortcuts.
224 GURL file_url(ui_test_utils::GetTestUrl(L".", L"empty.html")); 224 GURL file_url(ui_test_utils::GetTestUrl(L".", L"empty.html"));
225 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); 225 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme));
226 ui_test_utils::NavigateToURL(browser(), file_url); 226 ui_test_utils::NavigateToURL(browser(), file_url);
227 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 227 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
228 228
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 260 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
261 261
262 GURL downloads_url(chrome::kChromeUIDownloadsURL); 262 GURL downloads_url(chrome::kChromeUIDownloadsURL);
263 ui_test_utils::NavigateToURL(browser(), downloads_url); 263 ui_test_utils::NavigateToURL(browser(), downloads_url);
264 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 264 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
265 265
266 GURL blank_url(chrome::kAboutBlankURL); 266 GURL blank_url(chrome::kAboutBlankURL);
267 ui_test_utils::NavigateToURL(browser(), blank_url); 267 ui_test_utils::NavigateToURL(browser(), blank_url);
268 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); 268 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS));
269 } 269 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698