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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_close_browsertest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #if defined(OS_MACOSX) 10 #if defined(OS_MACOSX)
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/translate/translate_tab_helper.h" 26 #include "chrome/browser/translate/translate_tab_helper.h"
27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 27 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
28 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 28 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
29 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 29 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
30 #include "chrome/browser/ui/browser.h" 30 #include "chrome/browser/ui/browser.h"
31 #include "chrome/browser/ui/browser_command_controller.h" 31 #include "chrome/browser/ui/browser_command_controller.h"
32 #include "chrome/browser/ui/browser_commands.h" 32 #include "chrome/browser/ui/browser_commands.h"
33 #include "chrome/browser/ui/browser_finder.h" 33 #include "chrome/browser/ui/browser_finder.h"
34 #include "chrome/browser/ui/browser_list.h" 34 #include "chrome/browser/ui/browser_list.h"
35 #include "chrome/browser/ui/browser_navigator.h" 35 #include "chrome/browser/ui/browser_navigator.h"
36 #include "chrome/browser/ui/browser_tabstrip.h"
36 #include "chrome/browser/ui/browser_ui_prefs.h" 37 #include "chrome/browser/ui/browser_ui_prefs.h"
37 #include "chrome/browser/ui/browser_window.h" 38 #include "chrome/browser/ui/browser_window.h"
38 #include "chrome/browser/ui/extensions/application_launch.h" 39 #include "chrome/browser/ui/extensions/application_launch.h"
39 #include "chrome/browser/ui/startup/startup_browser_creator.h" 40 #include "chrome/browser/ui/startup/startup_browser_creator.h"
40 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" 41 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
41 #include "chrome/browser/ui/tab_contents/tab_contents.h" 42 #include "chrome/browser/ui/tab_contents/tab_contents.h"
42 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" 43 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
43 #include "chrome/browser/ui/tabs/tab_strip_model.h" 44 #include "chrome/browser/ui/tabs/tab_strip_model.h"
44 #include "chrome/common/chrome_notification_types.h" 45 #include "chrome/common/chrome_notification_types.h"
45 #include "chrome/common/chrome_switches.h" 46 #include "chrome/common/chrome_switches.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 EXPECT_EQ(test_title, tab_title); 250 EXPECT_EQ(test_title, tab_title);
250 } 251 }
251 252
252 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { 253 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) {
253 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 254 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
254 FilePath(kTitle1File))); 255 FilePath(kTitle1File)));
255 ui_test_utils::NavigateToURL(browser(), url); 256 ui_test_utils::NavigateToURL(browser(), url);
256 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); 257 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
257 EXPECT_EQ(2, browser()->tab_count()); 258 EXPECT_EQ(2, browser()->tab_count());
258 EXPECT_EQ(0, browser()->active_index()); 259 EXPECT_EQ(0, browser()->active_index());
259 WebContents* second_tab = browser()->GetWebContentsAt(1); 260 WebContents* second_tab = chrome::GetWebContentsAt(browser(), 1);
260 ASSERT_TRUE(second_tab); 261 ASSERT_TRUE(second_tab);
261 second_tab->GetRenderViewHost()->ExecuteJavascriptInWebFrame( 262 second_tab->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
262 string16(), 263 string16(),
263 ASCIIToUTF16("alert('Activate!');")); 264 ASCIIToUTF16("alert('Activate!');"));
264 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 265 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
265 alert->CloseModalDialog(); 266 alert->CloseModalDialog();
266 EXPECT_EQ(2, browser()->tab_count()); 267 EXPECT_EQ(2, browser()->tab_count());
267 EXPECT_EQ(1, browser()->active_index()); 268 EXPECT_EQ(1, browser()->active_index());
268 } 269 }
269 270
(...skipping 10 matching lines...) Expand all
280 // had a hard limit of 31 processes and this test is mainly directed at 281 // had a hard limit of 31 processes and this test is mainly directed at
281 // verifying that we don't crash when we pass this limit. 282 // verifying that we don't crash when we pass this limit.
282 // Warning: this test can take >30 seconds when running on a slow (low 283 // Warning: this test can take >30 seconds when running on a slow (low
283 // memory?) Mac builder. 284 // memory?) Mac builder.
284 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) { 285 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_ThirtyFourTabs) {
285 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 286 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
286 FilePath(kTitle2File))); 287 FilePath(kTitle2File)));
287 288
288 // There is one initial tab. 289 // There is one initial tab.
289 const int kTabCount = 34; 290 const int kTabCount = 34;
290 for (int ix = 0; ix != (kTabCount - 1); ++ix) 291 for (int ix = 0; ix != (kTabCount - 1); ++ix) {
291 browser()->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_TYPED); 292 chrome::AddSelectedTabWithURL(browser(), url,
293 content::PAGE_TRANSITION_TYPED);
294 }
292 EXPECT_EQ(kTabCount, browser()->tab_count()); 295 EXPECT_EQ(kTabCount, browser()->tab_count());
293 296
294 // See GetMaxRendererProcessCount() in 297 // See GetMaxRendererProcessCount() in
295 // content/browser/renderer_host/render_process_host_impl.cc 298 // content/browser/renderer_host/render_process_host_impl.cc
296 // for the algorithm to decide how many processes to create. 299 // for the algorithm to decide how many processes to create.
297 const int kExpectedProcessCount = 300 const int kExpectedProcessCount =
298 #if defined(ARCH_CPU_64_BITS) 301 #if defined(ARCH_CPU_64_BITS)
299 17; 302 17;
300 #else 303 #else
301 25; 304 25;
302 #endif 305 #endif
303 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) { 306 if (base::SysInfo::AmountOfPhysicalMemoryMB() >= 2048) {
304 EXPECT_GE(CountRenderProcessHosts(), kExpectedProcessCount); 307 EXPECT_GE(CountRenderProcessHosts(), kExpectedProcessCount);
305 } else { 308 } else {
306 EXPECT_LT(CountRenderProcessHosts(), kExpectedProcessCount); 309 EXPECT_LT(CountRenderProcessHosts(), kExpectedProcessCount);
307 } 310 }
308 } 311 }
309 312
310 // Test for crbug.com/22004. Reloading a page with a before unload handler and 313 // Test for crbug.com/22004. Reloading a page with a before unload handler and
311 // then canceling the dialog should not leave the throbber spinning. 314 // then canceling the dialog should not leave the throbber spinning.
312 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { 315 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
313 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); 316 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML);
314 ui_test_utils::NavigateToURL(browser(), url); 317 ui_test_utils::NavigateToURL(browser(), url);
315 318
316 // Navigate to another page, but click cancel in the dialog. Make sure that 319 // Navigate to another page, but click cancel in the dialog. Make sure that
317 // the throbber stops spinning. 320 // the throbber stops spinning.
318 chrome::Reload(browser(), CURRENT_TAB); 321 chrome::Reload(browser(), CURRENT_TAB);
319 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 322 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
320 alert->CloseModalDialog(); 323 alert->CloseModalDialog();
321 EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading()); 324 EXPECT_FALSE(chrome::GetActiveWebContents(browser())->IsLoading());
322 325
323 // Clear the beforeunload handler so the test can easily exit. 326 // Clear the beforeunload handler so the test can easily exit.
324 browser()->GetActiveWebContents()->GetRenderViewHost()-> 327 chrome::GetActiveWebContents(browser())->GetRenderViewHost()->
325 ExecuteJavascriptInWebFrame(string16(), 328 ExecuteJavascriptInWebFrame(string16(),
326 ASCIIToUTF16("onbeforeunload=null;")); 329 ASCIIToUTF16("onbeforeunload=null;"));
327 } 330 }
328 331
329 // Test for crbug.com/80401. Canceling a before unload dialog should reset 332 // Test for crbug.com/80401. Canceling a before unload dialog should reset
330 // the URL to the previous page's URL. 333 // the URL to the previous page's URL.
331 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { 334 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) {
332 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 335 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
333 FilePath(kBeforeUnloadFile))); 336 FilePath(kBeforeUnloadFile)));
334 ui_test_utils::NavigateToURL(browser(), url); 337 ui_test_utils::NavigateToURL(browser(), url);
335 338
336 // Navigate to a page that triggers a cross-site transition. 339 // Navigate to a page that triggers a cross-site transition.
337 ASSERT_TRUE(test_server()->Start()); 340 ASSERT_TRUE(test_server()->Start());
338 GURL url2(test_server()->GetURL("files/title1.html")); 341 GURL url2(test_server()->GetURL("files/title1.html"));
339 browser()->OpenURL(OpenURLParams( 342 browser()->OpenURL(OpenURLParams(
340 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 343 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
341 344
342 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( 345 ui_test_utils::WindowedNotificationObserver host_destroyed_observer(
343 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 346 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
344 content::NotificationService::AllSources()); 347 content::NotificationService::AllSources());
345 348
346 // Cancel the dialog. 349 // Cancel the dialog.
347 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 350 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
348 alert->CloseModalDialog(); 351 alert->CloseModalDialog();
349 EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading()); 352 EXPECT_FALSE(chrome::GetActiveWebContents(browser())->IsLoading());
350 353
351 // Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for 354 // Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for
352 // the pending RVH to be destroyed. 355 // the pending RVH to be destroyed.
353 host_destroyed_observer.Wait(); 356 host_destroyed_observer.Wait();
354 EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText())); 357 EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText()));
355 358
356 // Clear the beforeunload handler so the test can easily exit. 359 // Clear the beforeunload handler so the test can easily exit.
357 browser()->GetActiveWebContents()->GetRenderViewHost()-> 360 chrome::GetActiveWebContents(browser())->GetRenderViewHost()->
358 ExecuteJavascriptInWebFrame(string16(), 361 ExecuteJavascriptInWebFrame(string16(),
359 ASCIIToUTF16("onbeforeunload=null;")); 362 ASCIIToUTF16("onbeforeunload=null;"));
360 } 363 }
361 364
362 // Crashy on mac. http://crbug.com/38522 365 // Crashy on mac. http://crbug.com/38522
363 #if defined(OS_MACOSX) 366 #if defined(OS_MACOSX)
364 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ 367 #define MAYBE_SingleBeforeUnloadAfterWindowClose \
365 DISABLED_SingleBeforeUnloadAfterWindowClose 368 DISABLED_SingleBeforeUnloadAfterWindowClose
366 #else 369 #else
367 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ 370 #define MAYBE_SingleBeforeUnloadAfterWindowClose \
368 SingleBeforeUnloadAfterWindowClose 371 SingleBeforeUnloadAfterWindowClose
369 #endif 372 #endif
370 373
371 // Test for crbug.com/11647. A page closed with window.close() should not have 374 // Test for crbug.com/11647. A page closed with window.close() should not have
372 // two beforeunload dialogs shown. 375 // two beforeunload dialogs shown.
373 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { 376 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) {
374 browser()->GetActiveWebContents()->GetRenderViewHost()-> 377 chrome::GetActiveWebContents(browser())->GetRenderViewHost()->
375 ExecuteJavascriptInWebFrame(string16(), 378 ExecuteJavascriptInWebFrame(string16(),
376 ASCIIToUTF16(kOpenNewBeforeUnloadPage)); 379 ASCIIToUTF16(kOpenNewBeforeUnloadPage));
377 380
378 // Close the new window with JavaScript, which should show a single 381 // Close the new window with JavaScript, which should show a single
379 // beforeunload dialog. Then show another alert, to make it easy to verify 382 // beforeunload dialog. Then show another alert, to make it easy to verify
380 // that a second beforeunload dialog isn't shown. 383 // that a second beforeunload dialog isn't shown.
381 browser()->GetWebContentsAt(0)->GetRenderViewHost()-> 384 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost()->
382 ExecuteJavascriptInWebFrame(string16(), 385 ExecuteJavascriptInWebFrame(string16(),
383 ASCIIToUTF16("w.close(); alert('bar');")); 386 ASCIIToUTF16("w.close(); alert('bar');"));
384 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 387 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
385 alert->native_dialog()->AcceptAppModalDialog(); 388 alert->native_dialog()->AcceptAppModalDialog();
386 389
387 alert = ui_test_utils::WaitForAppModalDialog(); 390 alert = ui_test_utils::WaitForAppModalDialog();
388 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)-> 391 EXPECT_FALSE(static_cast<JavaScriptAppModalDialog*>(alert)->
389 is_before_unload_dialog()); 392 is_before_unload_dialog());
390 alert->native_dialog()->AcceptAppModalDialog(); 393 alert->native_dialog()->AcceptAppModalDialog();
391 } 394 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 ASSERT_TRUE(test_server()->Start()); 440 ASSERT_TRUE(test_server()->Start());
438 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, 441 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS,
439 net::TestServer::kLocalhost, 442 net::TestServer::kLocalhost,
440 FilePath(kDocRoot)); 443 FilePath(kDocRoot));
441 ASSERT_TRUE(https_test_server.Start()); 444 ASSERT_TRUE(https_test_server.Start());
442 GURL http_url(test_server()->GetURL("files/title1.html")); 445 GURL http_url(test_server()->GetURL("files/title1.html"));
443 GURL https_url(https_test_server.GetURL("")); 446 GURL https_url(https_test_server.GetURL(""));
444 447
445 // Start with an http URL. 448 // Start with an http URL.
446 ui_test_utils::NavigateToURL(browser(), http_url); 449 ui_test_utils::NavigateToURL(browser(), http_url);
447 WebContents* oldtab = browser()->GetActiveWebContents(); 450 WebContents* oldtab = chrome::GetActiveWebContents(browser());
448 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); 451 content::RenderProcessHost* process = oldtab->GetRenderProcessHost();
449 452
450 // Now open a tab to a blank page, set its opener to null, and redirect it 453 // Now open a tab to a blank page, set its opener to null, and redirect it
451 // cross-site. 454 // cross-site.
452 std::string redirect_popup = "w=window.open();"; 455 std::string redirect_popup = "w=window.open();";
453 redirect_popup += "w.opener=null;"; 456 redirect_popup += "w.opener=null;";
454 redirect_popup += "w.document.location=\""; 457 redirect_popup += "w.document.location=\"";
455 redirect_popup += https_url.spec(); 458 redirect_popup += https_url.spec();
456 redirect_popup += "\";"; 459 redirect_popup += "\";";
457 460
458 ui_test_utils::WindowedNotificationObserver popup_observer( 461 ui_test_utils::WindowedNotificationObserver popup_observer(
459 chrome::NOTIFICATION_TAB_ADDED, 462 chrome::NOTIFICATION_TAB_ADDED,
460 content::NotificationService::AllSources()); 463 content::NotificationService::AllSources());
461 ui_test_utils::WindowedNotificationObserver nav_observer( 464 ui_test_utils::WindowedNotificationObserver nav_observer(
462 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 465 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
463 content::NotificationService::AllSources()); 466 content::NotificationService::AllSources());
464 oldtab->GetRenderViewHost()-> 467 oldtab->GetRenderViewHost()->
465 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup)); 468 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup));
466 469
467 // Wait for popup window to appear and finish navigating. 470 // Wait for popup window to appear and finish navigating.
468 popup_observer.Wait(); 471 popup_observer.Wait();
469 ASSERT_EQ(2, browser()->tab_count()); 472 ASSERT_EQ(2, browser()->tab_count());
470 WebContents* newtab = browser()->GetActiveWebContents(); 473 WebContents* newtab = chrome::GetActiveWebContents(browser());
471 EXPECT_TRUE(newtab); 474 EXPECT_TRUE(newtab);
472 EXPECT_NE(oldtab, newtab); 475 EXPECT_NE(oldtab, newtab);
473 nav_observer.Wait(); 476 nav_observer.Wait();
474 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); 477 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry());
475 EXPECT_EQ(https_url.spec(), 478 EXPECT_EQ(https_url.spec(),
476 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); 479 newtab->GetController().GetLastCommittedEntry()->GetURL().spec());
477 480
478 // Popup window should not be in the opener's process. 481 // Popup window should not be in the opener's process.
479 content::RenderProcessHost* popup_process = 482 content::RenderProcessHost* popup_process =
480 newtab->GetRenderProcessHost(); 483 newtab->GetRenderProcessHost();
(...skipping 13 matching lines...) Expand all
494 content::NotificationService::AllSources()); 497 content::NotificationService::AllSources());
495 ui_test_utils::WindowedNotificationObserver nav_observer2( 498 ui_test_utils::WindowedNotificationObserver nav_observer2(
496 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 499 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
497 content::NotificationService::AllSources()); 500 content::NotificationService::AllSources());
498 oldtab->GetRenderViewHost()-> 501 oldtab->GetRenderViewHost()->
499 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup)); 502 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup));
500 503
501 // Wait for popup window to appear and finish navigating. 504 // Wait for popup window to appear and finish navigating.
502 popup_observer2.Wait(); 505 popup_observer2.Wait();
503 ASSERT_EQ(3, browser()->tab_count()); 506 ASSERT_EQ(3, browser()->tab_count());
504 WebContents* newtab2 = browser()->GetActiveWebContents(); 507 WebContents* newtab2 = chrome::GetActiveWebContents(browser());
505 EXPECT_TRUE(newtab2); 508 EXPECT_TRUE(newtab2);
506 EXPECT_NE(oldtab, newtab2); 509 EXPECT_NE(oldtab, newtab2);
507 nav_observer2.Wait(); 510 nav_observer2.Wait();
508 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); 511 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry());
509 EXPECT_EQ(https_url.spec(), 512 EXPECT_EQ(https_url.spec(),
510 newtab2->GetController().GetLastCommittedEntry()->GetURL().spec()); 513 newtab2->GetController().GetLastCommittedEntry()->GetURL().spec());
511 514
512 // This popup window should also not be in the opener's process. 515 // This popup window should also not be in the opener's process.
513 content::RenderProcessHost* popup_process2 = 516 content::RenderProcessHost* popup_process2 =
514 newtab2->GetRenderProcessHost(); 517 newtab2->GetRenderProcessHost();
(...skipping 11 matching lines...) Expand all
526 ASSERT_TRUE(test_server()->Start()); 529 ASSERT_TRUE(test_server()->Start());
527 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, 530 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS,
528 net::TestServer::kLocalhost, 531 net::TestServer::kLocalhost,
529 FilePath(kDocRoot)); 532 FilePath(kDocRoot));
530 ASSERT_TRUE(https_test_server.Start()); 533 ASSERT_TRUE(https_test_server.Start());
531 GURL http_url(test_server()->GetURL("files/title1.html")); 534 GURL http_url(test_server()->GetURL("files/title1.html"));
532 GURL https_url(https_test_server.GetURL("")); 535 GURL https_url(https_test_server.GetURL(""));
533 536
534 // Start with an http URL. 537 // Start with an http URL.
535 ui_test_utils::NavigateToURL(browser(), http_url); 538 ui_test_utils::NavigateToURL(browser(), http_url);
536 WebContents* oldtab = browser()->GetActiveWebContents(); 539 WebContents* oldtab = chrome::GetActiveWebContents(browser());
537 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); 540 content::RenderProcessHost* process = oldtab->GetRenderProcessHost();
538 541
539 // Now open a tab to a blank page, set its opener to null, and redirect it 542 // Now open a tab to a blank page, set its opener to null, and redirect it
540 // cross-site. 543 // cross-site.
541 std::string dont_fork_popup = "w=window.open();"; 544 std::string dont_fork_popup = "w=window.open();";
542 dont_fork_popup += "w.document.location=\""; 545 dont_fork_popup += "w.document.location=\"";
543 dont_fork_popup += https_url.spec(); 546 dont_fork_popup += https_url.spec();
544 dont_fork_popup += "\";"; 547 dont_fork_popup += "\";";
545 548
546 ui_test_utils::WindowedNotificationObserver popup_observer( 549 ui_test_utils::WindowedNotificationObserver popup_observer(
547 chrome::NOTIFICATION_TAB_ADDED, 550 chrome::NOTIFICATION_TAB_ADDED,
548 content::NotificationService::AllSources()); 551 content::NotificationService::AllSources());
549 ui_test_utils::WindowedNotificationObserver nav_observer( 552 ui_test_utils::WindowedNotificationObserver nav_observer(
550 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 553 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
551 content::NotificationService::AllSources()); 554 content::NotificationService::AllSources());
552 oldtab->GetRenderViewHost()-> 555 oldtab->GetRenderViewHost()->
553 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup)); 556 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup));
554 557
555 // Wait for popup window to appear and finish navigating. 558 // Wait for popup window to appear and finish navigating.
556 popup_observer.Wait(); 559 popup_observer.Wait();
557 ASSERT_EQ(2, browser()->tab_count()); 560 ASSERT_EQ(2, browser()->tab_count());
558 WebContents* newtab = browser()->GetActiveWebContents(); 561 WebContents* newtab = chrome::GetActiveWebContents(browser());
559 EXPECT_TRUE(newtab); 562 EXPECT_TRUE(newtab);
560 EXPECT_NE(oldtab, newtab); 563 EXPECT_NE(oldtab, newtab);
561 nav_observer.Wait(); 564 nav_observer.Wait();
562 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); 565 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry());
563 EXPECT_EQ(https_url.spec(), 566 EXPECT_EQ(https_url.spec(),
564 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); 567 newtab->GetController().GetLastCommittedEntry()->GetURL().spec());
565 568
566 // Popup window should still be in the opener's process. 569 // Popup window should still be in the opener's process.
567 content::RenderProcessHost* popup_process = 570 content::RenderProcessHost* popup_process =
568 newtab->GetRenderProcessHost(); 571 newtab->GetRenderProcessHost();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 687 }
685 688
686 // Change a tab into an application window. 689 // Change a tab into an application window.
687 // DISABLED: http://crbug.com/72310 690 // DISABLED: http://crbug.com/72310
688 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { 691 IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) {
689 ASSERT_TRUE(test_server()->Start()); 692 ASSERT_TRUE(test_server()->Start());
690 GURL http_url(test_server()->GetURL("")); 693 GURL http_url(test_server()->GetURL(""));
691 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); 694 ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme));
692 695
693 ASSERT_EQ(1, browser()->tab_count()); 696 ASSERT_EQ(1, browser()->tab_count());
694 WebContents* initial_tab = browser()->GetWebContentsAt(0); 697 WebContents* initial_tab = chrome::GetWebContentsAt(browser(), 0);
695 WebContents* app_tab = browser()->AddSelectedTabWithURL( 698 WebContents* app_tab = chrome::AddSelectedTabWithURL(
696 http_url, content::PAGE_TRANSITION_TYPED)->web_contents(); 699 browser(), http_url, content::PAGE_TRANSITION_TYPED)->web_contents();
697 ASSERT_EQ(2, browser()->tab_count()); 700 ASSERT_EQ(2, browser()->tab_count());
698 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile())); 701 ASSERT_EQ(1u, browser::GetBrowserCount(browser()->profile()));
699 702
700 // Normal tabs should accept load drops. 703 // Normal tabs should accept load drops.
701 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); 704 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops);
702 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); 705 EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops);
703 706
704 // Turn |app_tab| into a tab in an app panel. 707 // Turn |app_tab| into a tab in an app panel.
705 chrome::ConvertTabToAppWindow(browser(), app_tab); 708 chrome::ConvertTabToAppWindow(browser(), app_tab);
706 709
707 // The launch should have created a new browser. 710 // The launch should have created a new browser.
708 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); 711 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile()));
709 712
710 // Find the new browser. 713 // Find the new browser.
711 Browser* app_browser = NULL; 714 Browser* app_browser = NULL;
712 for (BrowserList::const_iterator i = BrowserList::begin(); 715 for (BrowserList::const_iterator i = BrowserList::begin();
713 i != BrowserList::end() && !app_browser; ++i) { 716 i != BrowserList::end() && !app_browser; ++i) {
714 if (*i != browser()) 717 if (*i != browser())
715 app_browser = *i; 718 app_browser = *i;
716 } 719 }
717 ASSERT_TRUE(app_browser); 720 ASSERT_TRUE(app_browser);
718 721
719 // Check that the tab contents is in the new browser, and not in the old. 722 // Check that the tab contents is in the new browser, and not in the old.
720 ASSERT_EQ(1, browser()->tab_count()); 723 ASSERT_EQ(1, browser()->tab_count());
721 ASSERT_EQ(initial_tab, browser()->GetWebContentsAt(0)); 724 ASSERT_EQ(initial_tab, chrome::GetWebContentsAt(browser(), 0));
722 725
723 // Check that the appliaction browser has a single tab, and that tab contains 726 // Check that the appliaction browser has a single tab, and that tab contains
724 // the content that we app-ified. 727 // the content that we app-ified.
725 ASSERT_EQ(1, app_browser->tab_count()); 728 ASSERT_EQ(1, app_browser->tab_count());
726 ASSERT_EQ(app_tab, app_browser->GetWebContentsAt(0)); 729 ASSERT_EQ(app_tab, chrome::GetWebContentsAt(app_browser, 0));
727 730
728 // Normal tabs should accept load drops. 731 // Normal tabs should accept load drops.
729 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); 732 EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops);
730 733
731 // The tab in an app window should not. 734 // The tab in an app window should not.
732 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); 735 EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops);
733 } 736 }
734 737
735 #endif // !defined(OS_MACOSX) 738 #endif // !defined(OS_MACOSX)
736 739
737 // Test RenderView correctly send back favicon url for web page that redirects 740 // Test RenderView correctly send back favicon url for web page that redirects
738 // to an anchor in javascript body.onload handler. 741 // to an anchor in javascript body.onload handler.
739 IN_PROC_BROWSER_TEST_F(BrowserTest, 742 IN_PROC_BROWSER_TEST_F(BrowserTest,
740 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { 743 DISABLED_FaviconOfOnloadRedirectToAnchorPage) {
741 ASSERT_TRUE(test_server()->Start()); 744 ASSERT_TRUE(test_server()->Start());
742 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); 745 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html"));
743 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); 746 GURL expected_favicon_url(test_server()->GetURL("files/test.png"));
744 747
745 ui_test_utils::NavigateToURL(browser(), url); 748 ui_test_utils::NavigateToURL(browser(), url);
746 749
747 NavigationEntry* entry = browser()->GetActiveWebContents()-> 750 NavigationEntry* entry = chrome::GetActiveWebContents(browser())->
748 GetController().GetActiveEntry(); 751 GetController().GetActiveEntry();
749 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); 752 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec());
750 } 753 }
751 754
752 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined (OS_WIN) 755 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined (OS_WIN)
753 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% 756 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14%
754 #define MAYBE_FaviconChange DISABLED_FaviconChange 757 #define MAYBE_FaviconChange DISABLED_FaviconChange
755 #else 758 #else
756 #define MAYBE_FaviconChange FaviconChange 759 #define MAYBE_FaviconChange FaviconChange
757 #endif 760 #endif
758 // Test that an icon can be changed from JS. 761 // Test that an icon can be changed from JS.
759 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) { 762 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) {
760 static const FilePath::CharType* kFile = 763 static const FilePath::CharType* kFile =
761 FILE_PATH_LITERAL("onload_change_favicon.html"); 764 FILE_PATH_LITERAL("onload_change_favicon.html");
762 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 765 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
763 FilePath(kFile))); 766 FilePath(kFile)));
764 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); 767 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme));
765 ui_test_utils::NavigateToURL(browser(), file_url); 768 ui_test_utils::NavigateToURL(browser(), file_url);
766 769
767 NavigationEntry* entry = browser()->GetActiveWebContents()-> 770 NavigationEntry* entry = chrome::GetActiveWebContents(browser())->
768 GetController().GetActiveEntry(); 771 GetController().GetActiveEntry();
769 static const FilePath::CharType* kIcon = 772 static const FilePath::CharType* kIcon =
770 FILE_PATH_LITERAL("test1.png"); 773 FILE_PATH_LITERAL("test1.png");
771 GURL expected_favicon_url( 774 GURL expected_favicon_url(
772 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 775 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
773 FilePath(kIcon))); 776 FilePath(kIcon)));
774 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); 777 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec());
775 } 778 }
776 779
777 // Makes sure TabClosing is sent when uninstalling an extension that is an app 780 // Makes sure TabClosing is sent when uninstalling an extension that is an app
778 // tab. 781 // tab.
779 IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { 782 IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) {
780 ASSERT_TRUE(test_server()->Start()); 783 ASSERT_TRUE(test_server()->Start());
781 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 784 host_resolver()->AddRule("www.example.com", "127.0.0.1");
782 GURL url(test_server()->GetURL("empty.html")); 785 GURL url(test_server()->GetURL("empty.html"));
783 TabStripModel* model = browser()->tab_strip_model(); 786 TabStripModel* model = browser()->tab_strip_model();
784 787
785 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 788 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
786 789
787 const Extension* extension_app = GetExtension(); 790 const Extension* extension_app = GetExtension();
788 791
789 ui_test_utils::NavigateToURL(browser(), url); 792 ui_test_utils::NavigateToURL(browser(), url);
790 793
791 TabContents* app_contents = 794 TabContents* app_contents = chrome::TabContentsFactory(
792 Browser::TabContentsFactory(browser()->profile(), NULL, 795 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
793 MSG_ROUTING_NONE, NULL, NULL);
794 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); 796 app_contents->extension_tab_helper()->SetExtensionApp(extension_app);
795 797
796 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), 798 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0),
797 TabStripModel::ADD_NONE); 799 TabStripModel::ADD_NONE);
798 model->SetTabPinned(0, true); 800 model->SetTabPinned(0, true);
799 ui_test_utils::NavigateToURL(browser(), url); 801 ui_test_utils::NavigateToURL(browser(), url);
800 802
801 MockTabStripModelObserver observer; 803 MockTabStripModelObserver observer;
802 model->AddObserver(&observer); 804 model->AddObserver(&observer);
803 805
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 // Tests that the CLD (Compact Language Detection) works properly. 857 // Tests that the CLD (Compact Language Detection) works properly.
856 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { 858 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) {
857 ASSERT_TRUE(test_server()->Start()); 859 ASSERT_TRUE(test_server()->Start());
858 860
859 std::string lang; 861 std::string lang;
860 862
861 // Open a new tab with a page in English. 863 // Open a new tab with a page in English.
862 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), 864 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")),
863 content::PAGE_TRANSITION_TYPED); 865 content::PAGE_TRANSITION_TYPED);
864 866
865 WebContents* current_web_contents = browser()->GetActiveWebContents(); 867 WebContents* current_web_contents = chrome::GetActiveWebContents(browser());
866 TabContents* current_tab_contents = browser()->GetActiveTabContents(); 868 TabContents* current_tab_contents = chrome::GetActiveTabContents(browser());
867 TranslateTabHelper* helper = current_tab_contents->translate_tab_helper(); 869 TranslateTabHelper* helper = current_tab_contents->translate_tab_helper();
868 content::Source<WebContents> source(current_web_contents); 870 content::Source<WebContents> source(current_web_contents);
869 871
870 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 872 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
871 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 873 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
872 source); 874 source);
873 EXPECT_EQ("", helper->language_state().original_language()); 875 EXPECT_EQ("", helper->language_state().original_language());
874 en_language_detected_signal.Wait(); 876 en_language_detected_signal.Wait();
875 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( 877 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor(
876 source.map_key(), &lang)); 878 source.map_key(), &lang));
(...skipping 25 matching lines...) Expand all
902 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { 904 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
903 ASSERT_TRUE(test_server()->Start()); 905 ASSERT_TRUE(test_server()->Start());
904 906
905 // Add an pinned app tab. 907 // Add an pinned app tab.
906 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 908 host_resolver()->AddRule("www.example.com", "127.0.0.1");
907 GURL url(test_server()->GetURL("empty.html")); 909 GURL url(test_server()->GetURL("empty.html"));
908 TabStripModel* model = browser()->tab_strip_model(); 910 TabStripModel* model = browser()->tab_strip_model();
909 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); 911 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
910 const Extension* extension_app = GetExtension(); 912 const Extension* extension_app = GetExtension();
911 ui_test_utils::NavigateToURL(browser(), url); 913 ui_test_utils::NavigateToURL(browser(), url);
912 TabContents* app_contents = 914 TabContents* app_contents = chrome::TabContentsFactory(
913 Browser::TabContentsFactory(browser()->profile(), NULL, 915 browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
914 MSG_ROUTING_NONE, NULL, NULL);
915 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); 916 app_contents->extension_tab_helper()->SetExtensionApp(extension_app);
916 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), 917 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0),
917 TabStripModel::ADD_NONE); 918 TabStripModel::ADD_NONE);
918 model->SetTabPinned(0, true); 919 model->SetTabPinned(0, true);
919 ui_test_utils::NavigateToURL(browser(), url); 920 ui_test_utils::NavigateToURL(browser(), url);
920 921
921 // Add a non pinned tab. 922 // Add a non pinned tab.
922 chrome::NewTab(browser()); 923 chrome::NewTab(browser());
923 924
924 // Add a pinned non-app tab. 925 // Add a pinned non-app tab.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 GURL blank_url(chrome::kAboutBlankURL); 1072 GURL blank_url(chrome::kAboutBlankURL);
1072 ui_test_utils::NavigateToURL(browser(), blank_url); 1073 ui_test_utils::NavigateToURL(browser(), blank_url);
1073 1074
1074 ui_test_utils::NavigateToURL(browser(), 1075 ui_test_utils::NavigateToURL(browser(),
1075 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 1076 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
1076 FilePath(kTitle1File))); 1077 FilePath(kTitle1File)));
1077 1078
1078 ui_test_utils::WindowedNotificationObserver back_nav_load_observer( 1079 ui_test_utils::WindowedNotificationObserver back_nav_load_observer(
1079 content::NOTIFICATION_LOAD_STOP, 1080 content::NOTIFICATION_LOAD_STOP,
1080 content::Source<NavigationController>( 1081 content::Source<NavigationController>(
1081 &browser()->GetActiveWebContents()->GetController())); 1082 &chrome::GetActiveWebContents(browser())->GetController()));
1082 chrome::GoBack(browser(), CURRENT_TAB); 1083 chrome::GoBack(browser(), CURRENT_TAB);
1083 back_nav_load_observer.Wait(); 1084 back_nav_load_observer.Wait();
1084 CommandUpdater* command_updater = 1085 CommandUpdater* command_updater =
1085 browser()->command_controller()->command_updater(); 1086 browser()->command_controller()->command_updater();
1086 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_FORWARD)); 1087 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_FORWARD));
1087 1088
1088 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( 1089 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer(
1089 content::NOTIFICATION_LOAD_STOP, 1090 content::NOTIFICATION_LOAD_STOP,
1090 content::Source<NavigationController>( 1091 content::Source<NavigationController>(
1091 &browser()->GetActiveWebContents()->GetController())); 1092 &chrome::GetActiveWebContents(browser())->GetController()));
1092 chrome::GoForward(browser(), CURRENT_TAB); 1093 chrome::GoForward(browser(), CURRENT_TAB);
1093 // This check will happen before the navigation completes, since the browser 1094 // This check will happen before the navigation completes, since the browser
1094 // won't process the renderer's response until the Wait() call below. 1095 // won't process the renderer's response until the Wait() call below.
1095 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_FORWARD)); 1096 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_FORWARD));
1096 forward_nav_load_observer.Wait(); 1097 forward_nav_load_observer.Wait();
1097 } 1098 }
1098 1099
1099 // Makes sure certain commands are disabled when Incognito mode is forced. 1100 // Makes sure certain commands are disabled when Incognito mode is forced.
1100 IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) { 1101 IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) {
1101 CommandUpdater* command_updater = 1102 CommandUpdater* command_updater =
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); 1217 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS));
1217 // Set Incognito to AVAILABLE. 1218 // Set Incognito to AVAILABLE.
1218 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), 1219 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(),
1219 IncognitoModePrefs::ENABLED); 1220 IncognitoModePrefs::ENABLED);
1220 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. 1221 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI.
1221 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); 1222 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS));
1222 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); 1223 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS));
1223 } 1224 }
1224 1225
1225 IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) { 1226 IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) {
1226 WebContents* contents = browser()->GetActiveWebContents(); 1227 WebContents* contents = chrome::GetActiveWebContents(browser());
1227 bool enable_plus, enable_minus; 1228 bool enable_plus, enable_minus;
1228 1229
1229 ui_test_utils::WindowedNotificationObserver zoom_in_observer( 1230 ui_test_utils::WindowedNotificationObserver zoom_in_observer(
1230 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, 1231 content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
1231 content::NotificationService::AllSources()); 1232 content::NotificationService::AllSources());
1232 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); 1233 chrome::Zoom(browser(), content::PAGE_ZOOM_IN);
1233 zoom_in_observer.Wait(); 1234 zoom_in_observer.Wait();
1234 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); 1235 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110);
1235 EXPECT_TRUE(enable_plus); 1236 EXPECT_TRUE(enable_plus);
1236 EXPECT_TRUE(enable_minus); 1237 EXPECT_TRUE(enable_minus);
(...skipping 25 matching lines...) Expand all
1262 GURL url(test_server()->GetURL("empty.html")); 1263 GURL url(test_server()->GetURL("empty.html"));
1263 ui_test_utils::NavigateToURL(browser(), url); 1264 ui_test_utils::NavigateToURL(browser(), url);
1264 1265
1265 CommandUpdater* command_updater = 1266 CommandUpdater* command_updater =
1266 browser()->command_controller()->command_updater(); 1267 browser()->command_controller()->command_updater();
1267 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); 1268 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE));
1268 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); 1269 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT));
1269 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); 1270 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE));
1270 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); 1271 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU));
1271 1272
1272 WebContents* contents = browser()->GetActiveWebContents(); 1273 WebContents* contents = chrome::GetActiveWebContents(browser());
1273 TestInterstitialPage* interstitial = new TestInterstitialPage( 1274 TestInterstitialPage* interstitial = new TestInterstitialPage(
1274 contents, false, GURL()); 1275 contents, false, GURL());
1275 1276
1276 ui_test_utils::WindowedNotificationObserver interstitial_observer( 1277 ui_test_utils::WindowedNotificationObserver interstitial_observer(
1277 content::NOTIFICATION_INTERSTITIAL_ATTACHED, 1278 content::NOTIFICATION_INTERSTITIAL_ATTACHED,
1278 content::Source<WebContents>(contents)); 1279 content::Source<WebContents>(contents));
1279 interstitial_observer.Wait(); 1280 interstitial_observer.Wait();
1280 1281
1281 EXPECT_TRUE(contents->ShowingInterstitialPage()); 1282 EXPECT_TRUE(contents->ShowingInterstitialPage());
1282 1283
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 private: 1321 private:
1321 bool got_user_gesture_; 1322 bool got_user_gesture_;
1322 1323
1323 DISALLOW_COPY_AND_ASSIGN(MockWebContentsObserver); 1324 DISALLOW_COPY_AND_ASSIGN(MockWebContentsObserver);
1324 }; 1325 };
1325 1326
1326 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { 1327 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) {
1327 // Regression test for http://crbug.com/110707. Also tests that a user 1328 // Regression test for http://crbug.com/110707. Also tests that a user
1328 // gesture is sent when a normal navigation (via e.g. the omnibox) is 1329 // gesture is sent when a normal navigation (via e.g. the omnibox) is
1329 // performed. 1330 // performed.
1330 WebContents* web_contents = browser()->GetActiveWebContents(); 1331 WebContents* web_contents = chrome::GetActiveWebContents(browser());
1331 MockWebContentsObserver mock_observer(web_contents); 1332 MockWebContentsObserver mock_observer(web_contents);
1332 1333
1333 ASSERT_TRUE(test_server()->Start()); 1334 ASSERT_TRUE(test_server()->Start());
1334 GURL url(test_server()->GetURL("empty.html")); 1335 GURL url(test_server()->GetURL("empty.html"));
1335 1336
1336 ui_test_utils::NavigateToURL(browser(), url); 1337 ui_test_utils::NavigateToURL(browser(), url);
1337 EXPECT_TRUE(mock_observer.got_user_gesture()); 1338 EXPECT_TRUE(mock_observer.got_user_gesture());
1338 1339
1339 mock_observer.set_got_user_gesture(false); 1340 mock_observer.set_got_user_gesture(false);
1340 chrome::Reload(browser(), CURRENT_TAB); 1341 chrome::Reload(browser(), CURRENT_TAB);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 app_popup_browser->AddTabWithURL(&params3); 1416 app_popup_browser->AddTabWithURL(&params3);
1416 EXPECT_EQ(app_popup_browser, params3.target); 1417 EXPECT_EQ(app_popup_browser, params3.target);
1417 1418
1418 // The popup should still only have one tab. 1419 // The popup should still only have one tab.
1419 EXPECT_EQ(1, app_popup_browser->tab_count()); 1420 EXPECT_EQ(1, app_popup_browser->tab_count());
1420 1421
1421 // The normal browser should now have four. 1422 // The normal browser should now have four.
1422 EXPECT_EQ(4, browser()->tab_count()); 1423 EXPECT_EQ(4, browser()->tab_count());
1423 1424
1424 // Close the additional browsers. 1425 // Close the additional browsers.
1425 popup_browser->CloseAllTabs(); 1426 chrome::CloseAllTabs(popup_browser);
1426 app_browser->CloseAllTabs(); 1427 chrome::CloseAllTabs(app_browser);
1427 app_popup_browser->CloseAllTabs(); 1428 chrome::CloseAllTabs(app_popup_browser);
1428 } 1429 }
1429 #endif 1430 #endif
1430 1431
1431 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) { 1432 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) {
1432 GURL url = ui_test_utils::GetTestUrl( 1433 GURL url = ui_test_utils::GetTestUrl(
1433 FilePath(), FilePath().AppendASCII("window.close.html")); 1434 FilePath(), FilePath().AppendASCII("window.close.html"));
1434 1435
1435 string16 title = ASCIIToUTF16("Title Of Awesomeness"); 1436 string16 title = ASCIIToUTF16("Title Of Awesomeness");
1436 ui_test_utils::TitleWatcher title_watcher( 1437 ui_test_utils::TitleWatcher title_watcher(
1437 browser()->GetActiveWebContents(), title); 1438 chrome::GetActiveWebContents(browser()), title);
1438 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); 1439 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
1439 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); 1440 EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
1440 } 1441 }
1441 1442
1442 class ShowModalDialogTest : public BrowserTest { 1443 class ShowModalDialogTest : public BrowserTest {
1443 public: 1444 public:
1444 ShowModalDialogTest() {} 1445 ShowModalDialogTest() {}
1445 1446
1446 virtual void SetUpCommandLine(CommandLine* command_line) { 1447 virtual void SetUpCommandLine(CommandLine* command_line) {
1447 command_line->AppendSwitch(switches::kDisablePopupBlocking); 1448 command_line->AppendSwitch(switches::kDisablePopupBlocking);
1448 } 1449 }
1449 }; 1450 };
1450 1451
1451 IN_PROC_BROWSER_TEST_F(ShowModalDialogTest, BasicTest) { 1452 IN_PROC_BROWSER_TEST_F(ShowModalDialogTest, BasicTest) {
1452 // This navigation should show a modal dialog that will be immediately 1453 // This navigation should show a modal dialog that will be immediately
1453 // closed, but the fact that it was shown should be recorded. 1454 // closed, but the fact that it was shown should be recorded.
1454 GURL url = ui_test_utils::GetTestUrl( 1455 GURL url = ui_test_utils::GetTestUrl(
1455 FilePath(), FilePath().AppendASCII("showmodaldialog.html")); 1456 FilePath(), FilePath().AppendASCII("showmodaldialog.html"));
1456 1457
1457 string16 expected_title(ASCIIToUTF16("SUCCESS")); 1458 string16 expected_title(ASCIIToUTF16("SUCCESS"));
1458 ui_test_utils::TitleWatcher title_watcher( 1459 ui_test_utils::TitleWatcher title_watcher(
1459 browser()->GetActiveWebContents(), expected_title); 1460 chrome::GetActiveWebContents(browser()), expected_title);
1460 ui_test_utils::NavigateToURL(browser(), url); 1461 ui_test_utils::NavigateToURL(browser(), url);
1461 1462
1462 // Verify that we set a mark on successful dialog show. 1463 // Verify that we set a mark on successful dialog show.
1463 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 1464 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
1464 } 1465 }
1465 1466
1466 IN_PROC_BROWSER_TEST_F(BrowserTest, DisallowFileUrlUniversalAccessTest) { 1467 IN_PROC_BROWSER_TEST_F(BrowserTest, DisallowFileUrlUniversalAccessTest) {
1467 GURL url = ui_test_utils::GetTestUrl( 1468 GURL url = ui_test_utils::GetTestUrl(
1468 FilePath(), FilePath().AppendASCII("fileurl_universalaccess.html")); 1469 FilePath(), FilePath().AppendASCII("fileurl_universalaccess.html"));
1469 1470
1470 string16 expected_title(ASCIIToUTF16("Disallowed")); 1471 string16 expected_title(ASCIIToUTF16("Disallowed"));
1471 ui_test_utils::TitleWatcher title_watcher( 1472 ui_test_utils::TitleWatcher title_watcher(
1472 browser()->GetActiveWebContents(), expected_title); 1473 chrome::GetActiveWebContents(browser()), expected_title);
1473 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed")); 1474 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed"));
1474 ui_test_utils::NavigateToURL(browser(), url); 1475 ui_test_utils::NavigateToURL(browser(), url);
1475 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 1476 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
1476 } 1477 }
1477 1478
1478 class KioskModeTest : public BrowserTest { 1479 class KioskModeTest : public BrowserTest {
1479 public: 1480 public:
1480 KioskModeTest() {} 1481 KioskModeTest() {}
1481 1482
1482 virtual void SetUpCommandLine(CommandLine* command_line) { 1483 virtual void SetUpCommandLine(CommandLine* command_line) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 command_line->AppendSwitchASCII(switches::kApp, url.spec()); 1583 command_line->AppendSwitchASCII(switches::kApp, url.spec());
1583 } 1584 }
1584 }; 1585 };
1585 1586
1586 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { 1587 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) {
1587 // Test that an application browser window loads correctly. 1588 // Test that an application browser window loads correctly.
1588 1589
1589 // Verify the browser is in application mode. 1590 // Verify the browser is in application mode.
1590 EXPECT_TRUE(browser()->IsApplication()); 1591 EXPECT_TRUE(browser()->IsApplication());
1591 } 1592 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_close_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698