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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 MessageLoop::current()->PostTask( 145 MessageLoop::current()->PostTask(
146 FROM_HERE, base::Bind(&CloseWindowCallback, browser)); 146 FROM_HERE, base::Bind(&CloseWindowCallback, browser));
147 browser->ShowAppMenu(); 147 browser->ShowAppMenu();
148 } 148 }
149 149
150 // Displays "INTERSTITIAL" while the interstitial is attached. 150 // Displays "INTERSTITIAL" while the interstitial is attached.
151 // (InterstitialPage can be used in a test directly, but there would be no way 151 // (InterstitialPage can be used in a test directly, but there would be no way
152 // to visually tell if it is showing or not.) 152 // to visually tell if it is showing or not.)
153 class TestInterstitialPage : public InterstitialPage { 153 class TestInterstitialPage : public InterstitialPage {
154 public: 154 public:
155 TestInterstitialPage(TabContents* tab, bool new_navigation, const GURL& url) 155 TestInterstitialPage(WebContents* tab, bool new_navigation, const GURL& url)
156 : InterstitialPage(tab, new_navigation, url) { } 156 : InterstitialPage(tab, new_navigation, url) { }
157 virtual ~TestInterstitialPage() { } 157 virtual ~TestInterstitialPage() { }
158 158
159 virtual std::string GetHTMLContents() OVERRIDE { 159 virtual std::string GetHTMLContents() OVERRIDE {
160 return "<h1>INTERSTITIAL</h1>"; 160 return "<h1>INTERSTITIAL</h1>";
161 } 161 }
162 }; 162 };
163 163
164 } // namespace 164 } // namespace
165 165
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // then canceling the dialog should not leave the throbber spinning. 281 // then canceling the dialog should not leave the throbber spinning.
282 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { 282 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
283 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); 283 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML);
284 ui_test_utils::NavigateToURL(browser(), url); 284 ui_test_utils::NavigateToURL(browser(), url);
285 285
286 // Navigate to another page, but click cancel in the dialog. Make sure that 286 // Navigate to another page, but click cancel in the dialog. Make sure that
287 // the throbber stops spinning. 287 // the throbber stops spinning.
288 browser()->Reload(CURRENT_TAB); 288 browser()->Reload(CURRENT_TAB);
289 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 289 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
290 alert->CloseModalDialog(); 290 alert->CloseModalDialog();
291 EXPECT_FALSE(browser()->GetSelectedTabContents()->IsLoading()); 291 EXPECT_FALSE(browser()->GetSelectedWebContents()->IsLoading());
292 292
293 // Clear the beforeunload handler so the test can easily exit. 293 // Clear the beforeunload handler so the test can easily exit.
294 browser()->GetSelectedTabContents()->GetRenderViewHost()-> 294 browser()->GetSelectedWebContents()->GetRenderViewHost()->
295 ExecuteJavascriptInWebFrame(string16(), 295 ExecuteJavascriptInWebFrame(string16(),
296 ASCIIToUTF16("onbeforeunload=null;")); 296 ASCIIToUTF16("onbeforeunload=null;"));
297 } 297 }
298 298
299 // Test for crbug.com/80401. Canceling a before unload dialog should reset 299 // Test for crbug.com/80401. Canceling a before unload dialog should reset
300 // the URL to the previous page's URL. 300 // the URL to the previous page's URL.
301 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { 301 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) {
302 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 302 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
303 FilePath(kBeforeUnloadFile))); 303 FilePath(kBeforeUnloadFile)));
304 ui_test_utils::NavigateToURL(browser(), url); 304 ui_test_utils::NavigateToURL(browser(), url);
305 305
306 // Navigate to a page that triggers a cross-site transition. 306 // Navigate to a page that triggers a cross-site transition.
307 ASSERT_TRUE(test_server()->Start()); 307 ASSERT_TRUE(test_server()->Start());
308 GURL url2(test_server()->GetURL("files/title1.html")); 308 GURL url2(test_server()->GetURL("files/title1.html"));
309 browser()->OpenURL(OpenURLParams( 309 browser()->OpenURL(OpenURLParams(
310 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 310 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
311 311
312 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( 312 ui_test_utils::WindowedNotificationObserver host_destroyed_observer(
313 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 313 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
314 content::NotificationService::AllSources()); 314 content::NotificationService::AllSources());
315 315
316 // Cancel the dialog. 316 // Cancel the dialog.
317 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 317 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
318 alert->CloseModalDialog(); 318 alert->CloseModalDialog();
319 EXPECT_FALSE(browser()->GetSelectedTabContents()->IsLoading()); 319 EXPECT_FALSE(browser()->GetSelectedWebContents()->IsLoading());
320 320
321 // Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for 321 // Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for
322 // the pending RVH to be destroyed. 322 // the pending RVH to be destroyed.
323 host_destroyed_observer.Wait(); 323 host_destroyed_observer.Wait();
324 EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText())); 324 EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText()));
325 325
326 // Clear the beforeunload handler so the test can easily exit. 326 // Clear the beforeunload handler so the test can easily exit.
327 browser()->GetSelectedTabContents()->GetRenderViewHost()-> 327 browser()->GetSelectedWebContents()->GetRenderViewHost()->
328 ExecuteJavascriptInWebFrame(string16(), 328 ExecuteJavascriptInWebFrame(string16(),
329 ASCIIToUTF16("onbeforeunload=null;")); 329 ASCIIToUTF16("onbeforeunload=null;"));
330 } 330 }
331 331
332 // Crashy on mac. http://crbug.com/38522 332 // Crashy on mac. http://crbug.com/38522
333 #if defined(OS_MACOSX) 333 #if defined(OS_MACOSX)
334 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ 334 #define MAYBE_SingleBeforeUnloadAfterWindowClose \
335 DISABLED_SingleBeforeUnloadAfterWindowClose 335 DISABLED_SingleBeforeUnloadAfterWindowClose
336 #else 336 #else
337 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ 337 #define MAYBE_SingleBeforeUnloadAfterWindowClose \
338 SingleBeforeUnloadAfterWindowClose 338 SingleBeforeUnloadAfterWindowClose
339 #endif 339 #endif
340 340
341 // Test for crbug.com/11647. A page closed with window.close() should not have 341 // Test for crbug.com/11647. A page closed with window.close() should not have
342 // two beforeunload dialogs shown. 342 // two beforeunload dialogs shown.
343 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { 343 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) {
344 browser()->GetSelectedTabContents()->GetRenderViewHost()-> 344 browser()->GetSelectedWebContents()->GetRenderViewHost()->
345 ExecuteJavascriptInWebFrame(string16(), 345 ExecuteJavascriptInWebFrame(string16(),
346 ASCIIToUTF16(kOpenNewBeforeUnloadPage)); 346 ASCIIToUTF16(kOpenNewBeforeUnloadPage));
347 347
348 // Close the new window with JavaScript, which should show a single 348 // Close the new window with JavaScript, which should show a single
349 // beforeunload dialog. Then show another alert, to make it easy to verify 349 // beforeunload dialog. Then show another alert, to make it easy to verify
350 // that a second beforeunload dialog isn't shown. 350 // that a second beforeunload dialog isn't shown.
351 browser()->GetTabContentsAt(0)->GetRenderViewHost()-> 351 browser()->GetTabContentsAt(0)->GetRenderViewHost()->
352 ExecuteJavascriptInWebFrame(string16(), 352 ExecuteJavascriptInWebFrame(string16(),
353 ASCIIToUTF16("w.close(); alert('bar');")); 353 ASCIIToUTF16("w.close(); alert('bar');"));
354 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 354 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
(...skipping 17 matching lines...) Expand all
372 // Create http and https servers for a cross-site transition. 372 // Create http and https servers for a cross-site transition.
373 ASSERT_TRUE(test_server()->Start()); 373 ASSERT_TRUE(test_server()->Start());
374 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, 374 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS,
375 FilePath(kDocRoot)); 375 FilePath(kDocRoot));
376 ASSERT_TRUE(https_test_server.Start()); 376 ASSERT_TRUE(https_test_server.Start());
377 GURL http_url(test_server()->GetURL("files/title1.html")); 377 GURL http_url(test_server()->GetURL("files/title1.html"));
378 GURL https_url(https_test_server.GetURL("")); 378 GURL https_url(https_test_server.GetURL(""));
379 379
380 // Start with an http URL. 380 // Start with an http URL.
381 ui_test_utils::NavigateToURL(browser(), http_url); 381 ui_test_utils::NavigateToURL(browser(), http_url);
382 TabContents* oldtab = browser()->GetSelectedTabContents(); 382 WebContents* oldtab = browser()->GetSelectedWebContents();
383 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); 383 content::RenderProcessHost* process = oldtab->GetRenderProcessHost();
384 384
385 // Now open a tab to a blank page, set its opener to null, and redirect it 385 // Now open a tab to a blank page, set its opener to null, and redirect it
386 // cross-site. 386 // cross-site.
387 std::string redirect_popup = "w=window.open();"; 387 std::string redirect_popup = "w=window.open();";
388 redirect_popup += "w.opener=null;"; 388 redirect_popup += "w.opener=null;";
389 redirect_popup += "w.document.location=\""; 389 redirect_popup += "w.document.location=\"";
390 redirect_popup += https_url.spec(); 390 redirect_popup += https_url.spec();
391 redirect_popup += "\";"; 391 redirect_popup += "\";";
392 392
393 ui_test_utils::WindowedNotificationObserver popup_observer( 393 ui_test_utils::WindowedNotificationObserver popup_observer(
394 content::NOTIFICATION_TAB_ADDED, 394 content::NOTIFICATION_TAB_ADDED,
395 content::NotificationService::AllSources()); 395 content::NotificationService::AllSources());
396 ui_test_utils::WindowedNotificationObserver nav_observer( 396 ui_test_utils::WindowedNotificationObserver nav_observer(
397 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 397 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
398 content::NotificationService::AllSources()); 398 content::NotificationService::AllSources());
399 oldtab->GetRenderViewHost()-> 399 oldtab->GetRenderViewHost()->
400 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup)); 400 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup));
401 401
402 // Wait for popup window to appear and finish navigating. 402 // Wait for popup window to appear and finish navigating.
403 popup_observer.Wait(); 403 popup_observer.Wait();
404 ASSERT_EQ(2, browser()->tab_count()); 404 ASSERT_EQ(2, browser()->tab_count());
405 TabContents* newtab = browser()->GetSelectedTabContents(); 405 WebContents* newtab = browser()->GetSelectedWebContents();
406 EXPECT_TRUE(newtab); 406 EXPECT_TRUE(newtab);
407 EXPECT_NE(oldtab, newtab); 407 EXPECT_NE(oldtab, newtab);
408 nav_observer.Wait(); 408 nav_observer.Wait();
409 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); 409 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry());
410 EXPECT_EQ(https_url.spec(), 410 EXPECT_EQ(https_url.spec(),
411 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); 411 newtab->GetController().GetLastCommittedEntry()->GetURL().spec());
412 412
413 // Popup window should not be in the opener's process. 413 // Popup window should not be in the opener's process.
414 content::RenderProcessHost* popup_process = 414 content::RenderProcessHost* popup_process =
415 newtab->GetRenderProcessHost(); 415 newtab->GetRenderProcessHost();
(...skipping 13 matching lines...) Expand all
429 content::NotificationService::AllSources()); 429 content::NotificationService::AllSources());
430 ui_test_utils::WindowedNotificationObserver nav_observer2( 430 ui_test_utils::WindowedNotificationObserver nav_observer2(
431 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 431 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
432 content::NotificationService::AllSources()); 432 content::NotificationService::AllSources());
433 oldtab->GetRenderViewHost()-> 433 oldtab->GetRenderViewHost()->
434 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup)); 434 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup));
435 435
436 // Wait for popup window to appear and finish navigating. 436 // Wait for popup window to appear and finish navigating.
437 popup_observer2.Wait(); 437 popup_observer2.Wait();
438 ASSERT_EQ(3, browser()->tab_count()); 438 ASSERT_EQ(3, browser()->tab_count());
439 TabContents* newtab2 = browser()->GetSelectedTabContents(); 439 WebContents* newtab2 = browser()->GetSelectedWebContents();
440 EXPECT_TRUE(newtab2); 440 EXPECT_TRUE(newtab2);
441 EXPECT_NE(oldtab, newtab2); 441 EXPECT_NE(oldtab, newtab2);
442 nav_observer2.Wait(); 442 nav_observer2.Wait();
443 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); 443 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry());
444 EXPECT_EQ(https_url.spec(), 444 EXPECT_EQ(https_url.spec(),
445 newtab2->GetController().GetLastCommittedEntry()->GetURL().spec()); 445 newtab2->GetController().GetLastCommittedEntry()->GetURL().spec());
446 446
447 // This popup window should also not be in the opener's process. 447 // This popup window should also not be in the opener's process.
448 content::RenderProcessHost* popup_process2 = 448 content::RenderProcessHost* popup_process2 =
449 newtab2->GetRenderProcessHost(); 449 newtab2->GetRenderProcessHost();
(...skipping 10 matching lines...) Expand all
460 // Create http and https servers for a cross-site transition. 460 // Create http and https servers for a cross-site transition.
461 ASSERT_TRUE(test_server()->Start()); 461 ASSERT_TRUE(test_server()->Start());
462 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, 462 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS,
463 FilePath(kDocRoot)); 463 FilePath(kDocRoot));
464 ASSERT_TRUE(https_test_server.Start()); 464 ASSERT_TRUE(https_test_server.Start());
465 GURL http_url(test_server()->GetURL("files/title1.html")); 465 GURL http_url(test_server()->GetURL("files/title1.html"));
466 GURL https_url(https_test_server.GetURL("")); 466 GURL https_url(https_test_server.GetURL(""));
467 467
468 // Start with an http URL. 468 // Start with an http URL.
469 ui_test_utils::NavigateToURL(browser(), http_url); 469 ui_test_utils::NavigateToURL(browser(), http_url);
470 TabContents* oldtab = browser()->GetSelectedTabContents(); 470 WebContents* oldtab = browser()->GetSelectedWebContents();
471 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); 471 content::RenderProcessHost* process = oldtab->GetRenderProcessHost();
472 472
473 // Now open a tab to a blank page, set its opener to null, and redirect it 473 // Now open a tab to a blank page, set its opener to null, and redirect it
474 // cross-site. 474 // cross-site.
475 std::string dont_fork_popup = "w=window.open();"; 475 std::string dont_fork_popup = "w=window.open();";
476 dont_fork_popup += "w.document.location=\""; 476 dont_fork_popup += "w.document.location=\"";
477 dont_fork_popup += https_url.spec(); 477 dont_fork_popup += https_url.spec();
478 dont_fork_popup += "\";"; 478 dont_fork_popup += "\";";
479 479
480 ui_test_utils::WindowedNotificationObserver popup_observer( 480 ui_test_utils::WindowedNotificationObserver popup_observer(
481 content::NOTIFICATION_TAB_ADDED, 481 content::NOTIFICATION_TAB_ADDED,
482 content::NotificationService::AllSources()); 482 content::NotificationService::AllSources());
483 ui_test_utils::WindowedNotificationObserver nav_observer( 483 ui_test_utils::WindowedNotificationObserver nav_observer(
484 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 484 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
485 content::NotificationService::AllSources()); 485 content::NotificationService::AllSources());
486 oldtab->GetRenderViewHost()-> 486 oldtab->GetRenderViewHost()->
487 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup)); 487 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup));
488 488
489 // Wait for popup window to appear and finish navigating. 489 // Wait for popup window to appear and finish navigating.
490 popup_observer.Wait(); 490 popup_observer.Wait();
491 ASSERT_EQ(2, browser()->tab_count()); 491 ASSERT_EQ(2, browser()->tab_count());
492 TabContents* newtab = browser()->GetSelectedTabContents(); 492 WebContents* newtab = browser()->GetSelectedWebContents();
493 EXPECT_TRUE(newtab); 493 EXPECT_TRUE(newtab);
494 EXPECT_NE(oldtab, newtab); 494 EXPECT_NE(oldtab, newtab);
495 nav_observer.Wait(); 495 nav_observer.Wait();
496 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); 496 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry());
497 EXPECT_EQ(https_url.spec(), 497 EXPECT_EQ(https_url.spec(),
498 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); 498 newtab->GetController().GetLastCommittedEntry()->GetURL().spec());
499 499
500 // Popup window should still be in the opener's process. 500 // Popup window should still be in the opener's process.
501 content::RenderProcessHost* popup_process = 501 content::RenderProcessHost* popup_process =
502 newtab->GetRenderProcessHost(); 502 newtab->GetRenderProcessHost();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // Test RenderView correctly send back favicon url for web page that redirects 662 // Test RenderView correctly send back favicon url for web page that redirects
663 // to an anchor in javascript body.onload handler. 663 // to an anchor in javascript body.onload handler.
664 IN_PROC_BROWSER_TEST_F(BrowserTest, 664 IN_PROC_BROWSER_TEST_F(BrowserTest,
665 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { 665 DISABLED_FaviconOfOnloadRedirectToAnchorPage) {
666 ASSERT_TRUE(test_server()->Start()); 666 ASSERT_TRUE(test_server()->Start());
667 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); 667 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html"));
668 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); 668 GURL expected_favicon_url(test_server()->GetURL("files/test.png"));
669 669
670 ui_test_utils::NavigateToURL(browser(), url); 670 ui_test_utils::NavigateToURL(browser(), url);
671 671
672 NavigationEntry* entry = browser()->GetSelectedTabContents()-> 672 NavigationEntry* entry = browser()->GetSelectedWebContents()->
673 GetController().GetActiveEntry(); 673 GetController().GetActiveEntry();
674 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); 674 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec());
675 } 675 }
676 676
677 #if defined(OS_MACOSX) || defined(OS_LINUX) 677 #if defined(OS_MACOSX) || defined(OS_LINUX)
678 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% 678 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14%
679 #define MAYBE_FaviconChange FLAKY_FaviconChange 679 #define MAYBE_FaviconChange FLAKY_FaviconChange
680 #else 680 #else
681 #define MAYBE_FaviconChange FaviconChange 681 #define MAYBE_FaviconChange FaviconChange
682 #endif 682 #endif
683 // Test that an icon can be changed from JS. 683 // Test that an icon can be changed from JS.
684 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) { 684 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) {
685 static const FilePath::CharType* kFile = 685 static const FilePath::CharType* kFile =
686 FILE_PATH_LITERAL("onload_change_favicon.html"); 686 FILE_PATH_LITERAL("onload_change_favicon.html");
687 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 687 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
688 FilePath(kFile))); 688 FilePath(kFile)));
689 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); 689 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme));
690 ui_test_utils::NavigateToURL(browser(), file_url); 690 ui_test_utils::NavigateToURL(browser(), file_url);
691 691
692 NavigationEntry* entry = browser()->GetSelectedTabContents()-> 692 NavigationEntry* entry = browser()->GetSelectedWebContents()->
693 GetController().GetActiveEntry(); 693 GetController().GetActiveEntry();
694 static const FilePath::CharType* kIcon = 694 static const FilePath::CharType* kIcon =
695 FILE_PATH_LITERAL("test1.png"); 695 FILE_PATH_LITERAL("test1.png");
696 GURL expected_favicon_url( 696 GURL expected_favicon_url(
697 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 697 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
698 FilePath(kIcon))); 698 FilePath(kIcon)));
699 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); 699 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec());
700 } 700 }
701 701
702 // Makes sure TabClosing is sent when uninstalling an extension that is an app 702 // Makes sure TabClosing is sent when uninstalling an extension that is an app
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 // Tests that the CLD (Compact Language Detection) works properly. 786 // Tests that the CLD (Compact Language Detection) works properly.
787 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) { 787 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageLanguageDetection) {
788 ASSERT_TRUE(test_server()->Start()); 788 ASSERT_TRUE(test_server()->Start());
789 789
790 std::string lang; 790 std::string lang;
791 791
792 // Open a new tab with a page in English. 792 // Open a new tab with a page in English.
793 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), 793 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")),
794 content::PAGE_TRANSITION_TYPED); 794 content::PAGE_TRANSITION_TYPED);
795 795
796 TabContents* current_tab = browser()->GetSelectedTabContents(); 796 WebContents* current_tab = browser()->GetSelectedWebContents();
797 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 797 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
798 TranslateTabHelper* helper = wrapper->translate_tab_helper(); 798 TranslateTabHelper* helper = wrapper->translate_tab_helper();
799 content::Source<WebContents> source(current_tab); 799 content::Source<WebContents> source(current_tab);
800 800
801 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> 801 ui_test_utils::WindowedNotificationObserverWithDetails<std::string>
802 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 802 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
803 source); 803 source);
804 EXPECT_EQ("", helper->language_state().original_language()); 804 EXPECT_EQ("", helper->language_state().original_language());
805 en_language_detected_signal.Wait(); 805 en_language_detected_signal.Wait();
806 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( 806 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor(
(...skipping 21 matching lines...) Expand all
828 #else 828 #else
829 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen 829 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen
830 #endif 830 #endif
831 831
832 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { 832 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) {
833 ASSERT_TRUE(test_server()->Start()); 833 ASSERT_TRUE(test_server()->Start());
834 834
835 AddTabAtIndex( 835 AddTabAtIndex(
836 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 836 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
837 837
838 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 838 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
839 839
840 { 840 {
841 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 841 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
842 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 842 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
843 content::NotificationService::AllSources()); 843 content::NotificationService::AllSources());
844 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 844 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
845 fullscreen_observer.Wait(); 845 fullscreen_observer.Wait();
846 ASSERT_TRUE(browser()->window()->IsFullscreen()); 846 ASSERT_TRUE(browser()->window()->IsFullscreen());
847 } 847 }
848 848
(...skipping 15 matching lines...) Expand all
864 #else 864 #else
865 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen 865 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen
866 #endif 866 #endif
867 867
868 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) { 868 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) {
869 ASSERT_TRUE(test_server()->Start()); 869 ASSERT_TRUE(test_server()->Start());
870 870
871 AddTabAtIndex( 871 AddTabAtIndex(
872 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 872 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
873 873
874 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 874 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
875 875
876 { 876 {
877 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 877 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
878 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 878 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
879 content::NotificationService::AllSources()); 879 content::NotificationService::AllSources());
880 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 880 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
881 fullscreen_observer.Wait(); 881 fullscreen_observer.Wait();
882 ASSERT_TRUE(browser()->window()->IsFullscreen()); 882 ASSERT_TRUE(browser()->window()->IsFullscreen());
883 } 883 }
884 884
885 { 885 {
886 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 886 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
887 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 887 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
888 content::NotificationService::AllSources()); 888 content::NotificationService::AllSources());
889 browser()->ToggleFullscreenModeForTab(fullscreen_tab, false); 889 browser()->ToggleFullscreenModeForTab(fullscreen_tab, false);
890 fullscreen_observer.Wait(); 890 fullscreen_observer.Wait();
891 ASSERT_FALSE(browser()->window()->IsFullscreen()); 891 ASSERT_FALSE(browser()->window()->IsFullscreen());
892 } 892 }
893 } 893 }
894 894
895 IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { 895 IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) {
896 ASSERT_TRUE(test_server()->Start()); 896 ASSERT_TRUE(test_server()->Start());
897 897
898 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), 898 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
899 content::PAGE_TRANSITION_TYPED); 899 content::PAGE_TRANSITION_TYPED);
900 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), 900 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL),
901 content::PAGE_TRANSITION_TYPED); 901 content::PAGE_TRANSITION_TYPED);
902 902
903 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 903 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
904 904
905 { 905 {
906 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 906 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
907 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 907 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
908 content::NotificationService::AllSources()); 908 content::NotificationService::AllSources());
909 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 909 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
910 fullscreen_observer.Wait(); 910 fullscreen_observer.Wait();
911 ASSERT_TRUE(browser()->window()->IsFullscreen()); 911 ASSERT_TRUE(browser()->window()->IsFullscreen());
912 } 912 }
913 913
(...skipping 11 matching lines...) Expand all
925 925
926 #if defined(OS_MACOSX) 926 #if defined(OS_MACOSX)
927 // http://crbug.com/100467 927 // http://crbug.com/100467
928 IN_PROC_BROWSER_TEST_F( 928 IN_PROC_BROWSER_TEST_F(
929 BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) { 929 BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) {
930 ASSERT_TRUE(test_server()->Start()); 930 ASSERT_TRUE(test_server()->Start());
931 931
932 AddTabAtIndex( 932 AddTabAtIndex(
933 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 933 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
934 934
935 TabContents* fullscreen_tab = browser()->GetSelectedTabContents(); 935 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
936 936
937 { 937 {
938 ui_test_utils::WindowedNotificationObserver fullscreen_observer( 938 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
939 chrome::NOTIFICATION_FULLSCREEN_CHANGED, 939 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
940 content::NotificationService::AllSources()); 940 content::NotificationService::AllSources());
941 EXPECT_FALSE(browser()->window()->IsFullscreen()); 941 EXPECT_FALSE(browser()->window()->IsFullscreen());
942 EXPECT_FALSE(browser()->window()->InPresentationMode()); 942 EXPECT_FALSE(browser()->window()->InPresentationMode());
943 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 943 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
944 fullscreen_observer.Wait(); 944 fullscreen_observer.Wait();
945 ASSERT_TRUE(browser()->window()->IsFullscreen()); 945 ASSERT_TRUE(browser()->window()->IsFullscreen());
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 GURL blank_url(chrome::kAboutBlankURL); 1152 GURL blank_url(chrome::kAboutBlankURL);
1153 ui_test_utils::NavigateToURL(browser(), blank_url); 1153 ui_test_utils::NavigateToURL(browser(), blank_url);
1154 1154
1155 ui_test_utils::NavigateToURL(browser(), 1155 ui_test_utils::NavigateToURL(browser(),
1156 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 1156 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
1157 FilePath(kTitle1File))); 1157 FilePath(kTitle1File)));
1158 1158
1159 ui_test_utils::WindowedNotificationObserver back_nav_load_observer( 1159 ui_test_utils::WindowedNotificationObserver back_nav_load_observer(
1160 content::NOTIFICATION_LOAD_STOP, 1160 content::NOTIFICATION_LOAD_STOP,
1161 content::Source<NavigationController>( 1161 content::Source<NavigationController>(
1162 &browser()->GetSelectedTabContents()->GetController())); 1162 &browser()->GetSelectedWebContents()->GetController()));
1163 browser()->GoBack(CURRENT_TAB); 1163 browser()->GoBack(CURRENT_TAB);
1164 back_nav_load_observer.Wait(); 1164 back_nav_load_observer.Wait();
1165 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); 1165 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD));
1166 1166
1167 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( 1167 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer(
1168 content::NOTIFICATION_LOAD_STOP, 1168 content::NOTIFICATION_LOAD_STOP,
1169 content::Source<NavigationController>( 1169 content::Source<NavigationController>(
1170 &browser()->GetSelectedTabContents()->GetController())); 1170 &browser()->GetSelectedWebContents()->GetController()));
1171 browser()->GoForward(CURRENT_TAB); 1171 browser()->GoForward(CURRENT_TAB);
1172 // This check will happen before the navigation completes, since the browser 1172 // This check will happen before the navigation completes, since the browser
1173 // won't process the renderer's response until the Wait() call below. 1173 // won't process the renderer's response until the Wait() call below.
1174 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); 1174 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD));
1175 forward_nav_load_observer.Wait(); 1175 forward_nav_load_observer.Wait();
1176 } 1176 }
1177 1177
1178 #if defined(OS_WIN) 1178 #if defined(OS_WIN)
1179 // see http://crbug.com/105306 1179 // see http://crbug.com/105306
1180 #define MAYBE_DisableMenuItemsWhenIncognitoIsForced \ 1180 #define MAYBE_DisableMenuItemsWhenIncognitoIsForced \
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); 1298 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS));
1299 // Set Incognito to AVAILABLE. 1299 // Set Incognito to AVAILABLE.
1300 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), 1300 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(),
1301 IncognitoModePrefs::ENABLED); 1301 IncognitoModePrefs::ENABLED);
1302 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. 1302 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI.
1303 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); 1303 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS));
1304 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); 1304 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS));
1305 } 1305 }
1306 1306
1307 IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) { 1307 IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) {
1308 TabContents* contents = browser()->GetSelectedTabContents(); 1308 WebContents* contents = browser()->GetSelectedWebContents();
1309 bool enable_plus, enable_minus; 1309 bool enable_plus, enable_minus;
1310 1310
1311 ui_test_utils::WindowedNotificationObserver zoom_in_observer( 1311 ui_test_utils::WindowedNotificationObserver zoom_in_observer(
1312 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, 1312 content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
1313 content::NotificationService::AllSources()); 1313 content::NotificationService::AllSources());
1314 browser()->Zoom(content::PAGE_ZOOM_IN); 1314 browser()->Zoom(content::PAGE_ZOOM_IN);
1315 zoom_in_observer.Wait(); 1315 zoom_in_observer.Wait();
1316 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); 1316 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110);
1317 EXPECT_TRUE(enable_plus); 1317 EXPECT_TRUE(enable_plus);
1318 EXPECT_TRUE(enable_minus); 1318 EXPECT_TRUE(enable_minus);
(...skipping 24 matching lines...) Expand all
1343 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1343 host_resolver()->AddRule("www.example.com", "127.0.0.1");
1344 GURL url(test_server()->GetURL("empty.html")); 1344 GURL url(test_server()->GetURL("empty.html"));
1345 ui_test_utils::NavigateToURL(browser(), url); 1345 ui_test_utils::NavigateToURL(browser(), url);
1346 1346
1347 CommandUpdater* command_updater = browser()->command_updater(); 1347 CommandUpdater* command_updater = browser()->command_updater();
1348 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); 1348 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE));
1349 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); 1349 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT));
1350 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); 1350 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE));
1351 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); 1351 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU));
1352 1352
1353 TabContents* contents = browser()->GetSelectedTabContents(); 1353 WebContents* contents = browser()->GetSelectedWebContents();
1354 TestInterstitialPage* interstitial = new TestInterstitialPage( 1354 TestInterstitialPage* interstitial = new TestInterstitialPage(
1355 contents, false, GURL()); 1355 contents, false, GURL());
1356 1356
1357 ui_test_utils::WindowedNotificationObserver interstitial_observer( 1357 ui_test_utils::WindowedNotificationObserver interstitial_observer(
1358 content::NOTIFICATION_INTERSTITIAL_ATTACHED, 1358 content::NOTIFICATION_INTERSTITIAL_ATTACHED,
1359 content::Source<WebContents>(contents)); 1359 content::Source<WebContents>(contents));
1360 interstitial->Show(); 1360 interstitial->Show();
1361 interstitial_observer.Wait(); 1361 interstitial_observer.Wait();
1362 1362
1363 EXPECT_TRUE(contents->ShowingInterstitialPage()); 1363 EXPECT_TRUE(contents->ShowingInterstitialPage());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 1458
1459 // The normal browser should now have four. 1459 // The normal browser should now have four.
1460 EXPECT_EQ(4, browser()->tab_count()); 1460 EXPECT_EQ(4, browser()->tab_count());
1461 1461
1462 // Close the additional browsers. 1462 // Close the additional browsers.
1463 popup_browser->CloseAllTabs(); 1463 popup_browser->CloseAllTabs();
1464 app_browser->CloseAllTabs(); 1464 app_browser->CloseAllTabs();
1465 app_popup_browser->CloseAllTabs(); 1465 app_popup_browser->CloseAllTabs();
1466 } 1466 }
1467 #endif 1467 #endif
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