| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 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_finder.h" | 31 #include "chrome/browser/ui/browser_finder.h" |
| 32 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 33 #include "chrome/browser/ui/browser_navigator.h" | 33 #include "chrome/browser/ui/browser_navigator.h" |
| 34 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 35 #include "chrome/browser/ui/extensions/application_launch.h" | 35 #include "chrome/browser/ui/extensions/application_launch.h" |
| 36 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 36 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 37 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 37 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 38 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 39 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 39 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 40 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 40 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 41 #include "chrome/common/chrome_notification_types.h" | 41 #include "chrome/common/chrome_notification_types.h" |
| 42 #include "chrome/common/chrome_switches.h" | 42 #include "chrome/common/chrome_switches.h" |
| 43 #include "chrome/common/extensions/extension.h" | 43 #include "chrome/common/extensions/extension.h" |
| 44 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
| 45 #include "chrome/test/base/in_process_browser_test.h" | 45 #include "chrome/test/base/in_process_browser_test.h" |
| 46 #include "chrome/test/base/ui_test_utils.h" | 46 #include "chrome/test/base/ui_test_utils.h" |
| 47 #include "content/public/browser/favicon_status.h" | 47 #include "content/public/browser/favicon_status.h" |
| 48 #include "content/public/browser/interstitial_page.h" | 48 #include "content/public/browser/interstitial_page.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 !i.IsAtEnd(); i.Advance()) | 121 !i.IsAtEnd(); i.Advance()) |
| 122 ++result; | 122 ++result; |
| 123 return result; | 123 return result; |
| 124 } | 124 } |
| 125 | 125 |
| 126 class MockTabStripModelObserver : public TabStripModelObserver { | 126 class MockTabStripModelObserver : public TabStripModelObserver { |
| 127 public: | 127 public: |
| 128 MockTabStripModelObserver() : closing_count_(0) {} | 128 MockTabStripModelObserver() : closing_count_(0) {} |
| 129 | 129 |
| 130 virtual void TabClosingAt(TabStripModel* tab_strip_model, | 130 virtual void TabClosingAt(TabStripModel* tab_strip_model, |
| 131 TabContentsWrapper* contents, | 131 TabContents* contents, |
| 132 int index) { | 132 int index) { |
| 133 closing_count_++; | 133 closing_count_++; |
| 134 } | 134 } |
| 135 | 135 |
| 136 int closing_count() const { return closing_count_; } | 136 int closing_count() const { return closing_count_; } |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 int closing_count_; | 139 int closing_count_; |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver); | 141 DISALLOW_COPY_AND_ASSIGN(MockTabStripModelObserver); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // then canceling the dialog should not leave the throbber spinning. | 308 // then canceling the dialog should not leave the throbber spinning. |
| 309 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { | 309 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { |
| 310 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); | 310 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); |
| 311 ui_test_utils::NavigateToURL(browser(), url); | 311 ui_test_utils::NavigateToURL(browser(), url); |
| 312 | 312 |
| 313 // Navigate to another page, but click cancel in the dialog. Make sure that | 313 // Navigate to another page, but click cancel in the dialog. Make sure that |
| 314 // the throbber stops spinning. | 314 // the throbber stops spinning. |
| 315 browser()->Reload(CURRENT_TAB); | 315 browser()->Reload(CURRENT_TAB); |
| 316 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 316 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 317 alert->CloseModalDialog(); | 317 alert->CloseModalDialog(); |
| 318 EXPECT_FALSE(browser()->GetSelectedWebContents()->IsLoading()); | 318 EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading()); |
| 319 | 319 |
| 320 // Clear the beforeunload handler so the test can easily exit. | 320 // Clear the beforeunload handler so the test can easily exit. |
| 321 browser()->GetSelectedWebContents()->GetRenderViewHost()-> | 321 browser()->GetActiveWebContents()->GetRenderViewHost()-> |
| 322 ExecuteJavascriptInWebFrame(string16(), | 322 ExecuteJavascriptInWebFrame(string16(), |
| 323 ASCIIToUTF16("onbeforeunload=null;")); | 323 ASCIIToUTF16("onbeforeunload=null;")); |
| 324 } | 324 } |
| 325 | 325 |
| 326 // Test for crbug.com/80401. Canceling a before unload dialog should reset | 326 // Test for crbug.com/80401. Canceling a before unload dialog should reset |
| 327 // the URL to the previous page's URL. | 327 // the URL to the previous page's URL. |
| 328 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { | 328 IN_PROC_BROWSER_TEST_F(BrowserTest, CancelBeforeUnloadResetsURL) { |
| 329 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 329 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 330 FilePath(kBeforeUnloadFile))); | 330 FilePath(kBeforeUnloadFile))); |
| 331 ui_test_utils::NavigateToURL(browser(), url); | 331 ui_test_utils::NavigateToURL(browser(), url); |
| 332 | 332 |
| 333 // Navigate to a page that triggers a cross-site transition. | 333 // Navigate to a page that triggers a cross-site transition. |
| 334 ASSERT_TRUE(test_server()->Start()); | 334 ASSERT_TRUE(test_server()->Start()); |
| 335 GURL url2(test_server()->GetURL("files/title1.html")); | 335 GURL url2(test_server()->GetURL("files/title1.html")); |
| 336 browser()->OpenURL(OpenURLParams( | 336 browser()->OpenURL(OpenURLParams( |
| 337 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 337 url2, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); |
| 338 | 338 |
| 339 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( | 339 ui_test_utils::WindowedNotificationObserver host_destroyed_observer( |
| 340 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 340 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 341 content::NotificationService::AllSources()); | 341 content::NotificationService::AllSources()); |
| 342 | 342 |
| 343 // Cancel the dialog. | 343 // Cancel the dialog. |
| 344 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 344 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 345 alert->CloseModalDialog(); | 345 alert->CloseModalDialog(); |
| 346 EXPECT_FALSE(browser()->GetSelectedWebContents()->IsLoading()); | 346 EXPECT_FALSE(browser()->GetActiveWebContents()->IsLoading()); |
| 347 | 347 |
| 348 // Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for | 348 // Wait for the ShouldClose_ACK to arrive. We can detect it by waiting for |
| 349 // the pending RVH to be destroyed. | 349 // the pending RVH to be destroyed. |
| 350 host_destroyed_observer.Wait(); | 350 host_destroyed_observer.Wait(); |
| 351 EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText())); | 351 EXPECT_EQ(url.spec(), UTF16ToUTF8(browser()->toolbar_model()->GetText())); |
| 352 | 352 |
| 353 // Clear the beforeunload handler so the test can easily exit. | 353 // Clear the beforeunload handler so the test can easily exit. |
| 354 browser()->GetSelectedWebContents()->GetRenderViewHost()-> | 354 browser()->GetActiveWebContents()->GetRenderViewHost()-> |
| 355 ExecuteJavascriptInWebFrame(string16(), | 355 ExecuteJavascriptInWebFrame(string16(), |
| 356 ASCIIToUTF16("onbeforeunload=null;")); | 356 ASCIIToUTF16("onbeforeunload=null;")); |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Crashy on mac. http://crbug.com/38522 | 359 // Crashy on mac. http://crbug.com/38522 |
| 360 #if defined(OS_MACOSX) | 360 #if defined(OS_MACOSX) |
| 361 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ | 361 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ |
| 362 DISABLED_SingleBeforeUnloadAfterWindowClose | 362 DISABLED_SingleBeforeUnloadAfterWindowClose |
| 363 #else | 363 #else |
| 364 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ | 364 #define MAYBE_SingleBeforeUnloadAfterWindowClose \ |
| 365 SingleBeforeUnloadAfterWindowClose | 365 SingleBeforeUnloadAfterWindowClose |
| 366 #endif | 366 #endif |
| 367 | 367 |
| 368 // Test for crbug.com/11647. A page closed with window.close() should not have | 368 // Test for crbug.com/11647. A page closed with window.close() should not have |
| 369 // two beforeunload dialogs shown. | 369 // two beforeunload dialogs shown. |
| 370 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { | 370 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_SingleBeforeUnloadAfterWindowClose) { |
| 371 browser()->GetSelectedWebContents()->GetRenderViewHost()-> | 371 browser()->GetActiveWebContents()->GetRenderViewHost()-> |
| 372 ExecuteJavascriptInWebFrame(string16(), | 372 ExecuteJavascriptInWebFrame(string16(), |
| 373 ASCIIToUTF16(kOpenNewBeforeUnloadPage)); | 373 ASCIIToUTF16(kOpenNewBeforeUnloadPage)); |
| 374 | 374 |
| 375 // Close the new window with JavaScript, which should show a single | 375 // Close the new window with JavaScript, which should show a single |
| 376 // beforeunload dialog. Then show another alert, to make it easy to verify | 376 // beforeunload dialog. Then show another alert, to make it easy to verify |
| 377 // that a second beforeunload dialog isn't shown. | 377 // that a second beforeunload dialog isn't shown. |
| 378 browser()->GetWebContentsAt(0)->GetRenderViewHost()-> | 378 browser()->GetWebContentsAt(0)->GetRenderViewHost()-> |
| 379 ExecuteJavascriptInWebFrame(string16(), | 379 ExecuteJavascriptInWebFrame(string16(), |
| 380 ASCIIToUTF16("w.close(); alert('bar');")); | 380 ASCIIToUTF16("w.close(); alert('bar');")); |
| 381 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 381 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 ASSERT_TRUE(test_server()->Start()); | 434 ASSERT_TRUE(test_server()->Start()); |
| 435 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, | 435 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, |
| 436 net::TestServer::kLocalhost, | 436 net::TestServer::kLocalhost, |
| 437 FilePath(kDocRoot)); | 437 FilePath(kDocRoot)); |
| 438 ASSERT_TRUE(https_test_server.Start()); | 438 ASSERT_TRUE(https_test_server.Start()); |
| 439 GURL http_url(test_server()->GetURL("files/title1.html")); | 439 GURL http_url(test_server()->GetURL("files/title1.html")); |
| 440 GURL https_url(https_test_server.GetURL("")); | 440 GURL https_url(https_test_server.GetURL("")); |
| 441 | 441 |
| 442 // Start with an http URL. | 442 // Start with an http URL. |
| 443 ui_test_utils::NavigateToURL(browser(), http_url); | 443 ui_test_utils::NavigateToURL(browser(), http_url); |
| 444 WebContents* oldtab = browser()->GetSelectedWebContents(); | 444 WebContents* oldtab = browser()->GetActiveWebContents(); |
| 445 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); | 445 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
| 446 | 446 |
| 447 // Now open a tab to a blank page, set its opener to null, and redirect it | 447 // Now open a tab to a blank page, set its opener to null, and redirect it |
| 448 // cross-site. | 448 // cross-site. |
| 449 std::string redirect_popup = "w=window.open();"; | 449 std::string redirect_popup = "w=window.open();"; |
| 450 redirect_popup += "w.opener=null;"; | 450 redirect_popup += "w.opener=null;"; |
| 451 redirect_popup += "w.document.location=\""; | 451 redirect_popup += "w.document.location=\""; |
| 452 redirect_popup += https_url.spec(); | 452 redirect_popup += https_url.spec(); |
| 453 redirect_popup += "\";"; | 453 redirect_popup += "\";"; |
| 454 | 454 |
| 455 ui_test_utils::WindowedNotificationObserver popup_observer( | 455 ui_test_utils::WindowedNotificationObserver popup_observer( |
| 456 chrome::NOTIFICATION_TAB_ADDED, | 456 chrome::NOTIFICATION_TAB_ADDED, |
| 457 content::NotificationService::AllSources()); | 457 content::NotificationService::AllSources()); |
| 458 ui_test_utils::WindowedNotificationObserver nav_observer( | 458 ui_test_utils::WindowedNotificationObserver nav_observer( |
| 459 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 459 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 460 content::NotificationService::AllSources()); | 460 content::NotificationService::AllSources()); |
| 461 oldtab->GetRenderViewHost()-> | 461 oldtab->GetRenderViewHost()-> |
| 462 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup)); | 462 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup)); |
| 463 | 463 |
| 464 // Wait for popup window to appear and finish navigating. | 464 // Wait for popup window to appear and finish navigating. |
| 465 popup_observer.Wait(); | 465 popup_observer.Wait(); |
| 466 ASSERT_EQ(2, browser()->tab_count()); | 466 ASSERT_EQ(2, browser()->tab_count()); |
| 467 WebContents* newtab = browser()->GetSelectedWebContents(); | 467 WebContents* newtab = browser()->GetActiveWebContents(); |
| 468 EXPECT_TRUE(newtab); | 468 EXPECT_TRUE(newtab); |
| 469 EXPECT_NE(oldtab, newtab); | 469 EXPECT_NE(oldtab, newtab); |
| 470 nav_observer.Wait(); | 470 nav_observer.Wait(); |
| 471 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); | 471 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); |
| 472 EXPECT_EQ(https_url.spec(), | 472 EXPECT_EQ(https_url.spec(), |
| 473 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); | 473 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); |
| 474 | 474 |
| 475 // Popup window should not be in the opener's process. | 475 // Popup window should not be in the opener's process. |
| 476 content::RenderProcessHost* popup_process = | 476 content::RenderProcessHost* popup_process = |
| 477 newtab->GetRenderProcessHost(); | 477 newtab->GetRenderProcessHost(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 491 content::NotificationService::AllSources()); | 491 content::NotificationService::AllSources()); |
| 492 ui_test_utils::WindowedNotificationObserver nav_observer2( | 492 ui_test_utils::WindowedNotificationObserver nav_observer2( |
| 493 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 493 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 494 content::NotificationService::AllSources()); | 494 content::NotificationService::AllSources()); |
| 495 oldtab->GetRenderViewHost()-> | 495 oldtab->GetRenderViewHost()-> |
| 496 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup)); | 496 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup)); |
| 497 | 497 |
| 498 // Wait for popup window to appear and finish navigating. | 498 // Wait for popup window to appear and finish navigating. |
| 499 popup_observer2.Wait(); | 499 popup_observer2.Wait(); |
| 500 ASSERT_EQ(3, browser()->tab_count()); | 500 ASSERT_EQ(3, browser()->tab_count()); |
| 501 WebContents* newtab2 = browser()->GetSelectedWebContents(); | 501 WebContents* newtab2 = browser()->GetActiveWebContents(); |
| 502 EXPECT_TRUE(newtab2); | 502 EXPECT_TRUE(newtab2); |
| 503 EXPECT_NE(oldtab, newtab2); | 503 EXPECT_NE(oldtab, newtab2); |
| 504 nav_observer2.Wait(); | 504 nav_observer2.Wait(); |
| 505 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); | 505 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); |
| 506 EXPECT_EQ(https_url.spec(), | 506 EXPECT_EQ(https_url.spec(), |
| 507 newtab2->GetController().GetLastCommittedEntry()->GetURL().spec()); | 507 newtab2->GetController().GetLastCommittedEntry()->GetURL().spec()); |
| 508 | 508 |
| 509 // This popup window should also not be in the opener's process. | 509 // This popup window should also not be in the opener's process. |
| 510 content::RenderProcessHost* popup_process2 = | 510 content::RenderProcessHost* popup_process2 = |
| 511 newtab2->GetRenderProcessHost(); | 511 newtab2->GetRenderProcessHost(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 523 ASSERT_TRUE(test_server()->Start()); | 523 ASSERT_TRUE(test_server()->Start()); |
| 524 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, | 524 net::TestServer https_test_server(net::TestServer::TYPE_HTTPS, |
| 525 net::TestServer::kLocalhost, | 525 net::TestServer::kLocalhost, |
| 526 FilePath(kDocRoot)); | 526 FilePath(kDocRoot)); |
| 527 ASSERT_TRUE(https_test_server.Start()); | 527 ASSERT_TRUE(https_test_server.Start()); |
| 528 GURL http_url(test_server()->GetURL("files/title1.html")); | 528 GURL http_url(test_server()->GetURL("files/title1.html")); |
| 529 GURL https_url(https_test_server.GetURL("")); | 529 GURL https_url(https_test_server.GetURL("")); |
| 530 | 530 |
| 531 // Start with an http URL. | 531 // Start with an http URL. |
| 532 ui_test_utils::NavigateToURL(browser(), http_url); | 532 ui_test_utils::NavigateToURL(browser(), http_url); |
| 533 WebContents* oldtab = browser()->GetSelectedWebContents(); | 533 WebContents* oldtab = browser()->GetActiveWebContents(); |
| 534 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); | 534 content::RenderProcessHost* process = oldtab->GetRenderProcessHost(); |
| 535 | 535 |
| 536 // Now open a tab to a blank page, set its opener to null, and redirect it | 536 // Now open a tab to a blank page, set its opener to null, and redirect it |
| 537 // cross-site. | 537 // cross-site. |
| 538 std::string dont_fork_popup = "w=window.open();"; | 538 std::string dont_fork_popup = "w=window.open();"; |
| 539 dont_fork_popup += "w.document.location=\""; | 539 dont_fork_popup += "w.document.location=\""; |
| 540 dont_fork_popup += https_url.spec(); | 540 dont_fork_popup += https_url.spec(); |
| 541 dont_fork_popup += "\";"; | 541 dont_fork_popup += "\";"; |
| 542 | 542 |
| 543 ui_test_utils::WindowedNotificationObserver popup_observer( | 543 ui_test_utils::WindowedNotificationObserver popup_observer( |
| 544 chrome::NOTIFICATION_TAB_ADDED, | 544 chrome::NOTIFICATION_TAB_ADDED, |
| 545 content::NotificationService::AllSources()); | 545 content::NotificationService::AllSources()); |
| 546 ui_test_utils::WindowedNotificationObserver nav_observer( | 546 ui_test_utils::WindowedNotificationObserver nav_observer( |
| 547 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 547 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 548 content::NotificationService::AllSources()); | 548 content::NotificationService::AllSources()); |
| 549 oldtab->GetRenderViewHost()-> | 549 oldtab->GetRenderViewHost()-> |
| 550 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup)); | 550 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup)); |
| 551 | 551 |
| 552 // Wait for popup window to appear and finish navigating. | 552 // Wait for popup window to appear and finish navigating. |
| 553 popup_observer.Wait(); | 553 popup_observer.Wait(); |
| 554 ASSERT_EQ(2, browser()->tab_count()); | 554 ASSERT_EQ(2, browser()->tab_count()); |
| 555 WebContents* newtab = browser()->GetSelectedWebContents(); | 555 WebContents* newtab = browser()->GetActiveWebContents(); |
| 556 EXPECT_TRUE(newtab); | 556 EXPECT_TRUE(newtab); |
| 557 EXPECT_NE(oldtab, newtab); | 557 EXPECT_NE(oldtab, newtab); |
| 558 nav_observer.Wait(); | 558 nav_observer.Wait(); |
| 559 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); | 559 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); |
| 560 EXPECT_EQ(https_url.spec(), | 560 EXPECT_EQ(https_url.spec(), |
| 561 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); | 561 newtab->GetController().GetLastCommittedEntry()->GetURL().spec()); |
| 562 | 562 |
| 563 // Popup window should still be in the opener's process. | 563 // Popup window should still be in the opener's process. |
| 564 content::RenderProcessHost* popup_process = | 564 content::RenderProcessHost* popup_process = |
| 565 newtab->GetRenderProcessHost(); | 565 newtab->GetRenderProcessHost(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 // Test RenderView correctly send back favicon url for web page that redirects | 729 // Test RenderView correctly send back favicon url for web page that redirects |
| 730 // to an anchor in javascript body.onload handler. | 730 // to an anchor in javascript body.onload handler. |
| 731 IN_PROC_BROWSER_TEST_F(BrowserTest, | 731 IN_PROC_BROWSER_TEST_F(BrowserTest, |
| 732 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { | 732 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { |
| 733 ASSERT_TRUE(test_server()->Start()); | 733 ASSERT_TRUE(test_server()->Start()); |
| 734 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); | 734 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); |
| 735 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); | 735 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); |
| 736 | 736 |
| 737 ui_test_utils::NavigateToURL(browser(), url); | 737 ui_test_utils::NavigateToURL(browser(), url); |
| 738 | 738 |
| 739 NavigationEntry* entry = browser()->GetSelectedWebContents()-> | 739 NavigationEntry* entry = browser()->GetActiveWebContents()-> |
| 740 GetController().GetActiveEntry(); | 740 GetController().GetActiveEntry(); |
| 741 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); | 741 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); |
| 742 } | 742 } |
| 743 | 743 |
| 744 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined (OS_WIN) | 744 #if defined(OS_MACOSX) || defined(OS_LINUX) || defined (OS_WIN) |
| 745 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% | 745 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% |
| 746 #define MAYBE_FaviconChange DISABLED_FaviconChange | 746 #define MAYBE_FaviconChange DISABLED_FaviconChange |
| 747 #else | 747 #else |
| 748 #define MAYBE_FaviconChange FaviconChange | 748 #define MAYBE_FaviconChange FaviconChange |
| 749 #endif | 749 #endif |
| 750 // Test that an icon can be changed from JS. | 750 // Test that an icon can be changed from JS. |
| 751 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) { | 751 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) { |
| 752 static const FilePath::CharType* kFile = | 752 static const FilePath::CharType* kFile = |
| 753 FILE_PATH_LITERAL("onload_change_favicon.html"); | 753 FILE_PATH_LITERAL("onload_change_favicon.html"); |
| 754 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 754 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 755 FilePath(kFile))); | 755 FilePath(kFile))); |
| 756 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); | 756 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); |
| 757 ui_test_utils::NavigateToURL(browser(), file_url); | 757 ui_test_utils::NavigateToURL(browser(), file_url); |
| 758 | 758 |
| 759 NavigationEntry* entry = browser()->GetSelectedWebContents()-> | 759 NavigationEntry* entry = browser()->GetActiveWebContents()-> |
| 760 GetController().GetActiveEntry(); | 760 GetController().GetActiveEntry(); |
| 761 static const FilePath::CharType* kIcon = | 761 static const FilePath::CharType* kIcon = |
| 762 FILE_PATH_LITERAL("test1.png"); | 762 FILE_PATH_LITERAL("test1.png"); |
| 763 GURL expected_favicon_url( | 763 GURL expected_favicon_url( |
| 764 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 764 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 765 FilePath(kIcon))); | 765 FilePath(kIcon))); |
| 766 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); | 766 EXPECT_EQ(expected_favicon_url.spec(), entry->GetFavicon().url.spec()); |
| 767 } | 767 } |
| 768 | 768 |
| 769 // Makes sure TabClosing is sent when uninstalling an extension that is an app | 769 // Makes sure TabClosing is sent when uninstalling an extension that is an app |
| 770 // tab. | 770 // tab. |
| 771 IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { | 771 IN_PROC_BROWSER_TEST_F(BrowserTest, TabClosingWhenRemovingExtension) { |
| 772 ASSERT_TRUE(test_server()->Start()); | 772 ASSERT_TRUE(test_server()->Start()); |
| 773 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 773 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 774 GURL url(test_server()->GetURL("empty.html")); | 774 GURL url(test_server()->GetURL("empty.html")); |
| 775 TabStripModel* model = browser()->tab_strip_model(); | 775 TabStripModel* model = browser()->tab_strip_model(); |
| 776 | 776 |
| 777 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 777 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 778 | 778 |
| 779 const Extension* extension_app = GetExtension(); | 779 const Extension* extension_app = GetExtension(); |
| 780 | 780 |
| 781 ui_test_utils::NavigateToURL(browser(), url); | 781 ui_test_utils::NavigateToURL(browser(), url); |
| 782 | 782 |
| 783 TabContentsWrapper* app_contents = | 783 TabContents* app_contents = |
| 784 Browser::TabContentsFactory(browser()->profile(), NULL, | 784 Browser::TabContentsFactory(browser()->profile(), NULL, |
| 785 MSG_ROUTING_NONE, NULL, NULL); | 785 MSG_ROUTING_NONE, NULL, NULL); |
| 786 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); | 786 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); |
| 787 | 787 |
| 788 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), | 788 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), |
| 789 TabStripModel::ADD_NONE); | 789 TabStripModel::ADD_NONE); |
| 790 model->SetTabPinned(0, true); | 790 model->SetTabPinned(0, true); |
| 791 ui_test_utils::NavigateToURL(browser(), url); | 791 ui_test_utils::NavigateToURL(browser(), url); |
| 792 | 792 |
| 793 MockTabStripModelObserver observer; | 793 MockTabStripModelObserver observer; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 // Tests that the CLD (Compact Language Detection) works properly. | 847 // Tests that the CLD (Compact Language Detection) works properly. |
| 848 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { | 848 IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) { |
| 849 ASSERT_TRUE(test_server()->Start()); | 849 ASSERT_TRUE(test_server()->Start()); |
| 850 | 850 |
| 851 std::string lang; | 851 std::string lang; |
| 852 | 852 |
| 853 // Open a new tab with a page in English. | 853 // Open a new tab with a page in English. |
| 854 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), | 854 AddTabAtIndex(0, GURL(test_server()->GetURL("files/english_page.html")), |
| 855 content::PAGE_TRANSITION_TYPED); | 855 content::PAGE_TRANSITION_TYPED); |
| 856 | 856 |
| 857 WebContents* current_tab = browser()->GetSelectedWebContents(); | 857 WebContents* current_web_contents = browser()->GetActiveWebContents(); |
| 858 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); | 858 TabContents* current_tab_contents = browser()->GetActiveTabContents(); |
| 859 TranslateTabHelper* helper = wrapper->translate_tab_helper(); | 859 TranslateTabHelper* helper = current_tab_contents->translate_tab_helper(); |
| 860 content::Source<WebContents> source(current_tab); | 860 content::Source<WebContents> source(current_web_contents); |
| 861 | 861 |
| 862 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> | 862 ui_test_utils::WindowedNotificationObserverWithDetails<std::string> |
| 863 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, | 863 en_language_detected_signal(chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
| 864 source); | 864 source); |
| 865 EXPECT_EQ("", helper->language_state().original_language()); | 865 EXPECT_EQ("", helper->language_state().original_language()); |
| 866 en_language_detected_signal.Wait(); | 866 en_language_detected_signal.Wait(); |
| 867 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( | 867 EXPECT_TRUE(en_language_detected_signal.GetDetailsFor( |
| 868 source.map_key(), &lang)); | 868 source.map_key(), &lang)); |
| 869 EXPECT_EQ("en", lang); | 869 EXPECT_EQ("en", lang); |
| 870 EXPECT_EQ("en", helper->language_state().original_language()); | 870 EXPECT_EQ("en", helper->language_state().original_language()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 894 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { | 894 IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { |
| 895 ASSERT_TRUE(test_server()->Start()); | 895 ASSERT_TRUE(test_server()->Start()); |
| 896 | 896 |
| 897 // Add an pinned app tab. | 897 // Add an pinned app tab. |
| 898 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 898 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 899 GURL url(test_server()->GetURL("empty.html")); | 899 GURL url(test_server()->GetURL("empty.html")); |
| 900 TabStripModel* model = browser()->tab_strip_model(); | 900 TabStripModel* model = browser()->tab_strip_model(); |
| 901 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); | 901 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/"))); |
| 902 const Extension* extension_app = GetExtension(); | 902 const Extension* extension_app = GetExtension(); |
| 903 ui_test_utils::NavigateToURL(browser(), url); | 903 ui_test_utils::NavigateToURL(browser(), url); |
| 904 TabContentsWrapper* app_contents = | 904 TabContents* app_contents = |
| 905 Browser::TabContentsFactory(browser()->profile(), NULL, | 905 Browser::TabContentsFactory(browser()->profile(), NULL, |
| 906 MSG_ROUTING_NONE, NULL, NULL); | 906 MSG_ROUTING_NONE, NULL, NULL); |
| 907 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); | 907 app_contents->extension_tab_helper()->SetExtensionApp(extension_app); |
| 908 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), | 908 model->AddTabContents(app_contents, 0, content::PageTransitionFromInt(0), |
| 909 TabStripModel::ADD_NONE); | 909 TabStripModel::ADD_NONE); |
| 910 model->SetTabPinned(0, true); | 910 model->SetTabPinned(0, true); |
| 911 ui_test_utils::NavigateToURL(browser(), url); | 911 ui_test_utils::NavigateToURL(browser(), url); |
| 912 | 912 |
| 913 // Add a non pinned tab. | 913 // Add a non pinned tab. |
| 914 browser()->NewTab(); | 914 browser()->NewTab(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 application_launch::OpenApplication(browser()->profile(), | 996 application_launch::OpenApplication(browser()->profile(), |
| 997 extension_app, | 997 extension_app, |
| 998 extension_misc::LAUNCH_WINDOW, | 998 extension_misc::LAUNCH_WINDOW, |
| 999 GURL(), | 999 GURL(), |
| 1000 NEW_WINDOW, | 1000 NEW_WINDOW, |
| 1001 NULL); | 1001 NULL); |
| 1002 ASSERT_TRUE(app_window); | 1002 ASSERT_TRUE(app_window); |
| 1003 | 1003 |
| 1004 // Apps launched in a window from the NTP do not have extension_app set in | 1004 // Apps launched in a window from the NTP do not have extension_app set in |
| 1005 // tab contents. | 1005 // tab contents. |
| 1006 TabContentsWrapper* wrapper = | 1006 TabContents* tab_contents = TabContents::FromWebContents(app_window); |
| 1007 TabContentsWrapper::GetCurrentWrapperForContents(app_window); | 1007 EXPECT_FALSE(tab_contents->extension_tab_helper()->extension_app()); |
| 1008 EXPECT_FALSE(wrapper->extension_tab_helper()->extension_app()); | |
| 1009 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); | 1008 EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); |
| 1010 | 1009 |
| 1011 // The launch should have created a new browser. | 1010 // The launch should have created a new browser. |
| 1012 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); | 1011 ASSERT_EQ(2u, browser::GetBrowserCount(browser()->profile())); |
| 1013 | 1012 |
| 1014 // Find the new browser. | 1013 // Find the new browser. |
| 1015 Browser* new_browser = NULL; | 1014 Browser* new_browser = NULL; |
| 1016 for (BrowserList::const_iterator i = BrowserList::begin(); | 1015 for (BrowserList::const_iterator i = BrowserList::begin(); |
| 1017 i != BrowserList::end() && !new_browser; ++i) { | 1016 i != BrowserList::end() && !new_browser; ++i) { |
| 1018 if (*i != browser()) | 1017 if (*i != browser()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 GURL blank_url(chrome::kAboutBlankURL); | 1069 GURL blank_url(chrome::kAboutBlankURL); |
| 1071 ui_test_utils::NavigateToURL(browser(), blank_url); | 1070 ui_test_utils::NavigateToURL(browser(), blank_url); |
| 1072 | 1071 |
| 1073 ui_test_utils::NavigateToURL(browser(), | 1072 ui_test_utils::NavigateToURL(browser(), |
| 1074 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 1073 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 1075 FilePath(kTitle1File))); | 1074 FilePath(kTitle1File))); |
| 1076 | 1075 |
| 1077 ui_test_utils::WindowedNotificationObserver back_nav_load_observer( | 1076 ui_test_utils::WindowedNotificationObserver back_nav_load_observer( |
| 1078 content::NOTIFICATION_LOAD_STOP, | 1077 content::NOTIFICATION_LOAD_STOP, |
| 1079 content::Source<NavigationController>( | 1078 content::Source<NavigationController>( |
| 1080 &browser()->GetSelectedWebContents()->GetController())); | 1079 &browser()->GetActiveWebContents()->GetController())); |
| 1081 browser()->GoBack(CURRENT_TAB); | 1080 browser()->GoBack(CURRENT_TAB); |
| 1082 back_nav_load_observer.Wait(); | 1081 back_nav_load_observer.Wait(); |
| 1083 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); | 1082 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); |
| 1084 | 1083 |
| 1085 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( | 1084 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( |
| 1086 content::NOTIFICATION_LOAD_STOP, | 1085 content::NOTIFICATION_LOAD_STOP, |
| 1087 content::Source<NavigationController>( | 1086 content::Source<NavigationController>( |
| 1088 &browser()->GetSelectedWebContents()->GetController())); | 1087 &browser()->GetActiveWebContents()->GetController())); |
| 1089 browser()->GoForward(CURRENT_TAB); | 1088 browser()->GoForward(CURRENT_TAB); |
| 1090 // This check will happen before the navigation completes, since the browser | 1089 // This check will happen before the navigation completes, since the browser |
| 1091 // won't process the renderer's response until the Wait() call below. | 1090 // won't process the renderer's response until the Wait() call below. |
| 1092 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); | 1091 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); |
| 1093 forward_nav_load_observer.Wait(); | 1092 forward_nav_load_observer.Wait(); |
| 1094 } | 1093 } |
| 1095 | 1094 |
| 1096 // Makes sure certain commands are disabled when Incognito mode is forced. | 1095 // Makes sure certain commands are disabled when Incognito mode is forced. |
| 1097 IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) { | 1096 IN_PROC_BROWSER_TEST_F(BrowserTest, DisableMenuItemsWhenIncognitoIsForced) { |
| 1098 CommandUpdater* command_updater = browser()->command_updater(); | 1097 CommandUpdater* command_updater = browser()->command_updater(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1205 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1207 // Set Incognito to AVAILABLE. | 1206 // Set Incognito to AVAILABLE. |
| 1208 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), | 1207 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), |
| 1209 IncognitoModePrefs::ENABLED); | 1208 IncognitoModePrefs::ENABLED); |
| 1210 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. | 1209 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. |
| 1211 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1210 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1212 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1211 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1213 } | 1212 } |
| 1214 | 1213 |
| 1215 IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) { | 1214 IN_PROC_BROWSER_TEST_F(BrowserTest, PageZoom) { |
| 1216 WebContents* contents = browser()->GetSelectedWebContents(); | 1215 WebContents* contents = browser()->GetActiveWebContents(); |
| 1217 bool enable_plus, enable_minus; | 1216 bool enable_plus, enable_minus; |
| 1218 | 1217 |
| 1219 ui_test_utils::WindowedNotificationObserver zoom_in_observer( | 1218 ui_test_utils::WindowedNotificationObserver zoom_in_observer( |
| 1220 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1219 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| 1221 content::NotificationService::AllSources()); | 1220 content::NotificationService::AllSources()); |
| 1222 browser()->Zoom(content::PAGE_ZOOM_IN); | 1221 browser()->Zoom(content::PAGE_ZOOM_IN); |
| 1223 zoom_in_observer.Wait(); | 1222 zoom_in_observer.Wait(); |
| 1224 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); | 1223 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); |
| 1225 EXPECT_TRUE(enable_plus); | 1224 EXPECT_TRUE(enable_plus); |
| 1226 EXPECT_TRUE(enable_minus); | 1225 EXPECT_TRUE(enable_minus); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1251 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1250 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1252 GURL url(test_server()->GetURL("empty.html")); | 1251 GURL url(test_server()->GetURL("empty.html")); |
| 1253 ui_test_utils::NavigateToURL(browser(), url); | 1252 ui_test_utils::NavigateToURL(browser(), url); |
| 1254 | 1253 |
| 1255 CommandUpdater* command_updater = browser()->command_updater(); | 1254 CommandUpdater* command_updater = browser()->command_updater(); |
| 1256 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 1255 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
| 1257 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | 1256 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); |
| 1258 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 1257 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
| 1259 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 1258 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
| 1260 | 1259 |
| 1261 WebContents* contents = browser()->GetSelectedWebContents(); | 1260 WebContents* contents = browser()->GetActiveWebContents(); |
| 1262 TestInterstitialPage* interstitial = new TestInterstitialPage( | 1261 TestInterstitialPage* interstitial = new TestInterstitialPage( |
| 1263 contents, false, GURL()); | 1262 contents, false, GURL()); |
| 1264 | 1263 |
| 1265 ui_test_utils::WindowedNotificationObserver interstitial_observer( | 1264 ui_test_utils::WindowedNotificationObserver interstitial_observer( |
| 1266 content::NOTIFICATION_INTERSTITIAL_ATTACHED, | 1265 content::NOTIFICATION_INTERSTITIAL_ATTACHED, |
| 1267 content::Source<WebContents>(contents)); | 1266 content::Source<WebContents>(contents)); |
| 1268 interstitial_observer.Wait(); | 1267 interstitial_observer.Wait(); |
| 1269 | 1268 |
| 1270 EXPECT_TRUE(contents->ShowingInterstitialPage()); | 1269 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1271 | 1270 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 private: | 1308 private: |
| 1310 bool got_user_gesture_; | 1309 bool got_user_gesture_; |
| 1311 | 1310 |
| 1312 DISALLOW_COPY_AND_ASSIGN(MockWebContentsObserver); | 1311 DISALLOW_COPY_AND_ASSIGN(MockWebContentsObserver); |
| 1313 }; | 1312 }; |
| 1314 | 1313 |
| 1315 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { | 1314 IN_PROC_BROWSER_TEST_F(BrowserTest, UserGesturesReported) { |
| 1316 // Regression test for http://crbug.com/110707. Also tests that a user | 1315 // Regression test for http://crbug.com/110707. Also tests that a user |
| 1317 // gesture is sent when a normal navigation (via e.g. the omnibox) is | 1316 // gesture is sent when a normal navigation (via e.g. the omnibox) is |
| 1318 // performed. | 1317 // performed. |
| 1319 WebContents* web_contents = browser()->GetSelectedWebContents(); | 1318 WebContents* web_contents = browser()->GetActiveWebContents(); |
| 1320 MockWebContentsObserver mock_observer(web_contents); | 1319 MockWebContentsObserver mock_observer(web_contents); |
| 1321 | 1320 |
| 1322 ASSERT_TRUE(test_server()->Start()); | 1321 ASSERT_TRUE(test_server()->Start()); |
| 1323 GURL url(test_server()->GetURL("empty.html")); | 1322 GURL url(test_server()->GetURL("empty.html")); |
| 1324 | 1323 |
| 1325 ui_test_utils::NavigateToURL(browser(), url); | 1324 ui_test_utils::NavigateToURL(browser(), url); |
| 1326 EXPECT_TRUE(mock_observer.got_user_gesture()); | 1325 EXPECT_TRUE(mock_observer.got_user_gesture()); |
| 1327 | 1326 |
| 1328 mock_observer.set_got_user_gesture(false); | 1327 mock_observer.set_got_user_gesture(false); |
| 1329 browser()->Reload(CURRENT_TAB); | 1328 browser()->Reload(CURRENT_TAB); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 app_popup_browser->CloseAllTabs(); | 1415 app_popup_browser->CloseAllTabs(); |
| 1417 } | 1416 } |
| 1418 #endif | 1417 #endif |
| 1419 | 1418 |
| 1420 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) { | 1419 IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) { |
| 1421 GURL url = ui_test_utils::GetTestUrl( | 1420 GURL url = ui_test_utils::GetTestUrl( |
| 1422 FilePath(), FilePath().AppendASCII("window.close.html")); | 1421 FilePath(), FilePath().AppendASCII("window.close.html")); |
| 1423 | 1422 |
| 1424 string16 title = ASCIIToUTF16("Title Of Awesomeness"); | 1423 string16 title = ASCIIToUTF16("Title Of Awesomeness"); |
| 1425 ui_test_utils::TitleWatcher title_watcher( | 1424 ui_test_utils::TitleWatcher title_watcher( |
| 1426 browser()->GetSelectedWebContents(), title); | 1425 browser()->GetActiveWebContents(), title); |
| 1427 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); | 1426 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2); |
| 1428 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); | 1427 EXPECT_EQ(title, title_watcher.WaitAndGetTitle()); |
| 1429 } | 1428 } |
| 1430 | 1429 |
| 1431 class ShowModalDialogTest : public BrowserTest { | 1430 class ShowModalDialogTest : public BrowserTest { |
| 1432 public: | 1431 public: |
| 1433 ShowModalDialogTest() {} | 1432 ShowModalDialogTest() {} |
| 1434 | 1433 |
| 1435 virtual void SetUpCommandLine(CommandLine* command_line) { | 1434 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 1436 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 1435 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
| 1437 } | 1436 } |
| 1438 }; | 1437 }; |
| 1439 | 1438 |
| 1440 IN_PROC_BROWSER_TEST_F(ShowModalDialogTest, BasicTest) { | 1439 IN_PROC_BROWSER_TEST_F(ShowModalDialogTest, BasicTest) { |
| 1441 // This navigation should show a modal dialog that will be immediately | 1440 // This navigation should show a modal dialog that will be immediately |
| 1442 // closed, but the fact that it was shown should be recorded. | 1441 // closed, but the fact that it was shown should be recorded. |
| 1443 GURL url = ui_test_utils::GetTestUrl( | 1442 GURL url = ui_test_utils::GetTestUrl( |
| 1444 FilePath(), FilePath().AppendASCII("showmodaldialog.html")); | 1443 FilePath(), FilePath().AppendASCII("showmodaldialog.html")); |
| 1445 | 1444 |
| 1446 string16 expected_title(ASCIIToUTF16("SUCCESS")); | 1445 string16 expected_title(ASCIIToUTF16("SUCCESS")); |
| 1447 ui_test_utils::TitleWatcher title_watcher( | 1446 ui_test_utils::TitleWatcher title_watcher( |
| 1448 browser()->GetSelectedWebContents(), expected_title); | 1447 browser()->GetActiveWebContents(), expected_title); |
| 1449 ui_test_utils::NavigateToURL(browser(), url); | 1448 ui_test_utils::NavigateToURL(browser(), url); |
| 1450 | 1449 |
| 1451 // Verify that we set a mark on successful dialog show. | 1450 // Verify that we set a mark on successful dialog show. |
| 1452 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 1451 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 1453 } | 1452 } |
| 1454 | 1453 |
| 1455 IN_PROC_BROWSER_TEST_F(BrowserTest, DisallowFileUrlUniversalAccessTest) { | 1454 IN_PROC_BROWSER_TEST_F(BrowserTest, DisallowFileUrlUniversalAccessTest) { |
| 1456 GURL url = ui_test_utils::GetTestUrl( | 1455 GURL url = ui_test_utils::GetTestUrl( |
| 1457 FilePath(), FilePath().AppendASCII("fileurl_universalaccess.html")); | 1456 FilePath(), FilePath().AppendASCII("fileurl_universalaccess.html")); |
| 1458 | 1457 |
| 1459 string16 expected_title(ASCIIToUTF16("Disallowed")); | 1458 string16 expected_title(ASCIIToUTF16("Disallowed")); |
| 1460 ui_test_utils::TitleWatcher title_watcher( | 1459 ui_test_utils::TitleWatcher title_watcher( |
| 1461 browser()->GetSelectedWebContents(), expected_title); | 1460 browser()->GetActiveWebContents(), expected_title); |
| 1462 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed")); | 1461 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed")); |
| 1463 ui_test_utils::NavigateToURL(browser(), url); | 1462 ui_test_utils::NavigateToURL(browser(), url); |
| 1464 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 1463 ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 1465 } | 1464 } |
| 1466 | 1465 |
| 1467 #if !defined(OS_MACOSX) | 1466 #if !defined(OS_MACOSX) |
| 1468 class KioskModeTest : public BrowserTest { | 1467 class KioskModeTest : public BrowserTest { |
| 1469 public: | 1468 public: |
| 1470 KioskModeTest() {} | 1469 KioskModeTest() {} |
| 1471 | 1470 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 command_line->AppendSwitchASCII(switches::kApp, url.spec()); | 1572 command_line->AppendSwitchASCII(switches::kApp, url.spec()); |
| 1574 } | 1573 } |
| 1575 }; | 1574 }; |
| 1576 | 1575 |
| 1577 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { | 1576 IN_PROC_BROWSER_TEST_F(AppModeTest, EnableAppModeTest) { |
| 1578 // Test that an application browser window loads correctly. | 1577 // Test that an application browser window loads correctly. |
| 1579 | 1578 |
| 1580 // Verify the browser is in application mode. | 1579 // Verify the browser is in application mode. |
| 1581 EXPECT_TRUE(browser()->IsApplication()); | 1580 EXPECT_TRUE(browser()->IsApplication()); |
| 1582 } | 1581 } |
| OLD | NEW |