| OLD | NEW |
| 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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 oldtab->GetRenderViewHost()-> | 376 oldtab->GetRenderViewHost()-> |
| 377 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup)); | 377 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(redirect_popup)); |
| 378 | 378 |
| 379 // Wait for popup window to appear and finish navigating. | 379 // Wait for popup window to appear and finish navigating. |
| 380 popup_observer.Wait(); | 380 popup_observer.Wait(); |
| 381 ASSERT_EQ(2, browser()->tab_count()); | 381 ASSERT_EQ(2, browser()->tab_count()); |
| 382 TabContents* newtab = browser()->GetSelectedTabContents(); | 382 TabContents* newtab = browser()->GetSelectedTabContents(); |
| 383 EXPECT_TRUE(newtab); | 383 EXPECT_TRUE(newtab); |
| 384 EXPECT_NE(oldtab, newtab); | 384 EXPECT_NE(oldtab, newtab); |
| 385 nav_observer.Wait(); | 385 nav_observer.Wait(); |
| 386 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); | 386 ASSERT_TRUE(newtab->controller().GetLastCommittedEntry()); |
| 387 EXPECT_EQ(https_url.spec(), | 387 EXPECT_EQ(https_url.spec(), |
| 388 newtab->GetController().GetLastCommittedEntry()->url().spec()); | 388 newtab->controller().GetLastCommittedEntry()->url().spec()); |
| 389 | 389 |
| 390 // Popup window should not be in the opener's process. | 390 // Popup window should not be in the opener's process. |
| 391 content::RenderProcessHost* popup_process = | 391 content::RenderProcessHost* popup_process = |
| 392 newtab->GetRenderProcessHost(); | 392 newtab->GetRenderProcessHost(); |
| 393 EXPECT_NE(process, popup_process); | 393 EXPECT_NE(process, popup_process); |
| 394 | 394 |
| 395 // Now open a tab to a blank page, set its opener to null, and use a | 395 // Now open a tab to a blank page, set its opener to null, and use a |
| 396 // meta-refresh to navigate it instead. | 396 // meta-refresh to navigate it instead. |
| 397 std::string refresh_popup = "w=window.open();"; | 397 std::string refresh_popup = "w=window.open();"; |
| 398 refresh_popup += "w.opener=null;"; | 398 refresh_popup += "w.opener=null;"; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 410 oldtab->GetRenderViewHost()-> | 410 oldtab->GetRenderViewHost()-> |
| 411 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup)); | 411 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(refresh_popup)); |
| 412 | 412 |
| 413 // Wait for popup window to appear and finish navigating. | 413 // Wait for popup window to appear and finish navigating. |
| 414 popup_observer2.Wait(); | 414 popup_observer2.Wait(); |
| 415 ASSERT_EQ(3, browser()->tab_count()); | 415 ASSERT_EQ(3, browser()->tab_count()); |
| 416 TabContents* newtab2 = browser()->GetSelectedTabContents(); | 416 TabContents* newtab2 = browser()->GetSelectedTabContents(); |
| 417 EXPECT_TRUE(newtab2); | 417 EXPECT_TRUE(newtab2); |
| 418 EXPECT_NE(oldtab, newtab2); | 418 EXPECT_NE(oldtab, newtab2); |
| 419 nav_observer2.Wait(); | 419 nav_observer2.Wait(); |
| 420 ASSERT_TRUE(newtab2->GetController().GetLastCommittedEntry()); | 420 ASSERT_TRUE(newtab2->controller().GetLastCommittedEntry()); |
| 421 EXPECT_EQ(https_url.spec(), | 421 EXPECT_EQ(https_url.spec(), |
| 422 newtab2->GetController().GetLastCommittedEntry()->url().spec()); | 422 newtab2->controller().GetLastCommittedEntry()->url().spec()); |
| 423 | 423 |
| 424 // This popup window should also not be in the opener's process. | 424 // This popup window should also not be in the opener's process. |
| 425 content::RenderProcessHost* popup_process2 = | 425 content::RenderProcessHost* popup_process2 = |
| 426 newtab2->GetRenderProcessHost(); | 426 newtab2->GetRenderProcessHost(); |
| 427 EXPECT_NE(process, popup_process2); | 427 EXPECT_NE(process, popup_process2); |
| 428 } | 428 } |
| 429 | 429 |
| 430 // Tests that other popup navigations that do not follow the steps at | 430 // Tests that other popup navigations that do not follow the steps at |
| 431 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not | 431 // http://www.google.com/chrome/intl/en/webmasters-faq.html#newtab will not |
| 432 // fork a new renderer process. | 432 // fork a new renderer process. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 463 oldtab->GetRenderViewHost()-> | 463 oldtab->GetRenderViewHost()-> |
| 464 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup)); | 464 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(dont_fork_popup)); |
| 465 | 465 |
| 466 // Wait for popup window to appear and finish navigating. | 466 // Wait for popup window to appear and finish navigating. |
| 467 popup_observer.Wait(); | 467 popup_observer.Wait(); |
| 468 ASSERT_EQ(2, browser()->tab_count()); | 468 ASSERT_EQ(2, browser()->tab_count()); |
| 469 TabContents* newtab = browser()->GetSelectedTabContents(); | 469 TabContents* newtab = browser()->GetSelectedTabContents(); |
| 470 EXPECT_TRUE(newtab); | 470 EXPECT_TRUE(newtab); |
| 471 EXPECT_NE(oldtab, newtab); | 471 EXPECT_NE(oldtab, newtab); |
| 472 nav_observer.Wait(); | 472 nav_observer.Wait(); |
| 473 ASSERT_TRUE(newtab->GetController().GetLastCommittedEntry()); | 473 ASSERT_TRUE(newtab->controller().GetLastCommittedEntry()); |
| 474 EXPECT_EQ(https_url.spec(), | 474 EXPECT_EQ(https_url.spec(), |
| 475 newtab->GetController().GetLastCommittedEntry()->url().spec()); | 475 newtab->controller().GetLastCommittedEntry()->url().spec()); |
| 476 | 476 |
| 477 // Popup window should still be in the opener's process. | 477 // Popup window should still be in the opener's process. |
| 478 content::RenderProcessHost* popup_process = | 478 content::RenderProcessHost* popup_process = |
| 479 newtab->GetRenderProcessHost(); | 479 newtab->GetRenderProcessHost(); |
| 480 EXPECT_EQ(process, popup_process); | 480 EXPECT_EQ(process, popup_process); |
| 481 | 481 |
| 482 // Same thing if the current tab tries to navigate itself. | 482 // Same thing if the current tab tries to navigate itself. |
| 483 std::string navigate_str = "document.location=\""; | 483 std::string navigate_str = "document.location=\""; |
| 484 navigate_str += https_url.spec(); | 484 navigate_str += https_url.spec(); |
| 485 navigate_str += "\";"; | 485 navigate_str += "\";"; |
| 486 | 486 |
| 487 ui_test_utils::WindowedNotificationObserver nav_observer2( | 487 ui_test_utils::WindowedNotificationObserver nav_observer2( |
| 488 content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 488 content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 489 content::NotificationService::AllSources()); | 489 content::NotificationService::AllSources()); |
| 490 oldtab->GetRenderViewHost()-> | 490 oldtab->GetRenderViewHost()-> |
| 491 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(navigate_str)); | 491 ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(navigate_str)); |
| 492 nav_observer2.Wait(); | 492 nav_observer2.Wait(); |
| 493 ASSERT_TRUE(oldtab->GetController().GetLastCommittedEntry()); | 493 ASSERT_TRUE(oldtab->controller().GetLastCommittedEntry()); |
| 494 EXPECT_EQ(https_url.spec(), | 494 EXPECT_EQ(https_url.spec(), |
| 495 oldtab->GetController().GetLastCommittedEntry()->url().spec()); | 495 oldtab->controller().GetLastCommittedEntry()->url().spec()); |
| 496 | 496 |
| 497 // Original window should still be in the original process. | 497 // Original window should still be in the original process. |
| 498 content::RenderProcessHost* new_process = newtab->GetRenderProcessHost(); | 498 content::RenderProcessHost* new_process = newtab->GetRenderProcessHost(); |
| 499 EXPECT_EQ(process, new_process); | 499 EXPECT_EQ(process, new_process); |
| 500 } | 500 } |
| 501 | 501 |
| 502 // Test that get_process_idle_time() returns reasonable values when compared | 502 // Test that get_process_idle_time() returns reasonable values when compared |
| 503 // with time deltas measured locally. | 503 // with time deltas measured locally. |
| 504 IN_PROC_BROWSER_TEST_F(BrowserTest, RenderIdleTime) { | 504 IN_PROC_BROWSER_TEST_F(BrowserTest, RenderIdleTime) { |
| 505 base::TimeTicks start = base::TimeTicks::Now(); | 505 base::TimeTicks start = base::TimeTicks::Now(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // to an anchor in javascript body.onload handler. | 640 // to an anchor in javascript body.onload handler. |
| 641 IN_PROC_BROWSER_TEST_F(BrowserTest, | 641 IN_PROC_BROWSER_TEST_F(BrowserTest, |
| 642 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { | 642 DISABLED_FaviconOfOnloadRedirectToAnchorPage) { |
| 643 ASSERT_TRUE(test_server()->Start()); | 643 ASSERT_TRUE(test_server()->Start()); |
| 644 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); | 644 GURL url(test_server()->GetURL("files/onload_redirect_to_anchor.html")); |
| 645 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); | 645 GURL expected_favicon_url(test_server()->GetURL("files/test.png")); |
| 646 | 646 |
| 647 ui_test_utils::NavigateToURL(browser(), url); | 647 ui_test_utils::NavigateToURL(browser(), url); |
| 648 | 648 |
| 649 NavigationEntry* entry = browser()->GetSelectedTabContents()-> | 649 NavigationEntry* entry = browser()->GetSelectedTabContents()-> |
| 650 GetController().GetActiveEntry(); | 650 controller().GetActiveEntry(); |
| 651 EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec()); | 651 EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec()); |
| 652 } | 652 } |
| 653 | 653 |
| 654 #if defined(OS_MACOSX) || defined(OS_LINUX) | 654 #if defined(OS_MACOSX) || defined(OS_LINUX) |
| 655 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% | 655 // http://crbug.com/83828. On Mac 10.6, the failure rate is 14% |
| 656 #define MAYBE_FaviconChange FLAKY_FaviconChange | 656 #define MAYBE_FaviconChange FLAKY_FaviconChange |
| 657 #else | 657 #else |
| 658 #define MAYBE_FaviconChange FaviconChange | 658 #define MAYBE_FaviconChange FaviconChange |
| 659 #endif | 659 #endif |
| 660 // Test that an icon can be changed from JS. | 660 // Test that an icon can be changed from JS. |
| 661 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) { | 661 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_FaviconChange) { |
| 662 static const FilePath::CharType* kFile = | 662 static const FilePath::CharType* kFile = |
| 663 FILE_PATH_LITERAL("onload_change_favicon.html"); | 663 FILE_PATH_LITERAL("onload_change_favicon.html"); |
| 664 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 664 GURL file_url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 665 FilePath(kFile))); | 665 FilePath(kFile))); |
| 666 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); | 666 ASSERT_TRUE(file_url.SchemeIs(chrome::kFileScheme)); |
| 667 ui_test_utils::NavigateToURL(browser(), file_url); | 667 ui_test_utils::NavigateToURL(browser(), file_url); |
| 668 | 668 |
| 669 NavigationEntry* entry = browser()->GetSelectedTabContents()-> | 669 NavigationEntry* entry = browser()->GetSelectedTabContents()-> |
| 670 GetController().GetActiveEntry(); | 670 controller().GetActiveEntry(); |
| 671 static const FilePath::CharType* kIcon = | 671 static const FilePath::CharType* kIcon = |
| 672 FILE_PATH_LITERAL("test1.png"); | 672 FILE_PATH_LITERAL("test1.png"); |
| 673 GURL expected_favicon_url( | 673 GURL expected_favicon_url( |
| 674 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 674 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 675 FilePath(kIcon))); | 675 FilePath(kIcon))); |
| 676 EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec()); | 676 EXPECT_EQ(expected_favicon_url.spec(), entry->favicon().url().spec()); |
| 677 } | 677 } |
| 678 | 678 |
| 679 // Makes sure TabClosing is sent when uninstalling an extension that is an app | 679 // Makes sure TabClosing is sent when uninstalling an extension that is an app |
| 680 // tab. | 680 // tab. |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 GURL blank_url(chrome::kAboutBlankURL); | 1129 GURL blank_url(chrome::kAboutBlankURL); |
| 1130 ui_test_utils::NavigateToURL(browser(), blank_url); | 1130 ui_test_utils::NavigateToURL(browser(), blank_url); |
| 1131 | 1131 |
| 1132 ui_test_utils::NavigateToURL(browser(), | 1132 ui_test_utils::NavigateToURL(browser(), |
| 1133 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 1133 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 1134 FilePath(kTitle1File))); | 1134 FilePath(kTitle1File))); |
| 1135 | 1135 |
| 1136 ui_test_utils::WindowedNotificationObserver back_nav_load_observer( | 1136 ui_test_utils::WindowedNotificationObserver back_nav_load_observer( |
| 1137 content::NOTIFICATION_LOAD_STOP, | 1137 content::NOTIFICATION_LOAD_STOP, |
| 1138 content::Source<NavigationController>( | 1138 content::Source<NavigationController>( |
| 1139 &browser()->GetSelectedTabContents()->GetController())); | 1139 &browser()->GetSelectedTabContents()->controller())); |
| 1140 browser()->GoBack(CURRENT_TAB); | 1140 browser()->GoBack(CURRENT_TAB); |
| 1141 back_nav_load_observer.Wait(); | 1141 back_nav_load_observer.Wait(); |
| 1142 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); | 1142 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); |
| 1143 | 1143 |
| 1144 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( | 1144 ui_test_utils::WindowedNotificationObserver forward_nav_load_observer( |
| 1145 content::NOTIFICATION_LOAD_STOP, | 1145 content::NOTIFICATION_LOAD_STOP, |
| 1146 content::Source<NavigationController>( | 1146 content::Source<NavigationController>( |
| 1147 &browser()->GetSelectedTabContents()->GetController())); | 1147 &browser()->GetSelectedTabContents()->controller())); |
| 1148 browser()->GoForward(CURRENT_TAB); | 1148 browser()->GoForward(CURRENT_TAB); |
| 1149 // This check will happen before the navigation completes, since the browser | 1149 // This check will happen before the navigation completes, since the browser |
| 1150 // won't process the renderer's response until the Wait() call below. | 1150 // won't process the renderer's response until the Wait() call below. |
| 1151 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); | 1151 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_FORWARD)); |
| 1152 forward_nav_load_observer.Wait(); | 1152 forward_nav_load_observer.Wait(); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| 1155 #if defined(OS_WIN) | 1155 #if defined(OS_WIN) |
| 1156 // see http://crbug.com/105306 | 1156 // see http://crbug.com/105306 |
| 1157 #define MAYBE_DisableMenuItemsWhenIncognitoIsForced \ | 1157 #define MAYBE_DisableMenuItemsWhenIncognitoIsForced \ |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 | 1392 |
| 1393 // The normal browser should now have four. | 1393 // The normal browser should now have four. |
| 1394 EXPECT_EQ(4, browser()->tab_count()); | 1394 EXPECT_EQ(4, browser()->tab_count()); |
| 1395 | 1395 |
| 1396 // Close the additional browsers. | 1396 // Close the additional browsers. |
| 1397 popup_browser->CloseAllTabs(); | 1397 popup_browser->CloseAllTabs(); |
| 1398 app_browser->CloseAllTabs(); | 1398 app_browser->CloseAllTabs(); |
| 1399 app_popup_browser->CloseAllTabs(); | 1399 app_popup_browser->CloseAllTabs(); |
| 1400 } | 1400 } |
| 1401 #endif | 1401 #endif |
| OLD | NEW |