| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/notification_source.h" | 24 #include "content/public/browser/notification_source.h" |
| 25 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/page_navigator.h" | 26 #include "content/public/browser/page_navigator.h" |
| 27 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 30 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
| 31 #include "net/test/spawned_test_server/spawned_test_server.h" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 32 #include "third_party/WebKit/public/web/WebFindOptions.h" | 32 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 33 | 33 |
| 34 class TabRestoreTest : public InProcessBrowserTest { | 34 class TabRestoreTest : public InProcessBrowserTest { |
| 35 public: | 35 public: |
| 36 TabRestoreTest() | 36 TabRestoreTest() |
| 37 : active_browser_list_(BrowserList::GetInstance( | 37 : active_browser_list_(BrowserList::GetInstance( |
| 38 chrome::GetActiveDesktop())) { | 38 chrome::GetActiveDesktop())) { |
| 39 url1_ = ui_test_utils::GetTestUrl( | 39 url1_ = ui_test_utils::GetTestUrl( |
| 40 base::FilePath().AppendASCII("session_history"), | 40 base::FilePath().AppendASCII("session_history"), |
| 41 base::FilePath().AppendASCII("bot1.html")); | 41 base::FilePath().AppendASCII("bot1.html")); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // Restore the next-to-last-closed tab into the same window. | 356 // Restore the next-to-last-closed tab into the same window. |
| 357 ASSERT_NO_FATAL_FAILURE(RestoreTab(1, 0)); | 357 ASSERT_NO_FATAL_FAILURE(RestoreTab(1, 0)); |
| 358 EXPECT_EQ(2, browser->tab_strip_model()->count()); | 358 EXPECT_EQ(2, browser->tab_strip_model()->count()); |
| 359 EXPECT_EQ(url1_, | 359 EXPECT_EQ(url1_, |
| 360 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 360 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
| 361 } | 361 } |
| 362 | 362 |
| 363 // Tests that a duplicate history entry is not created when we restore a page | 363 // Tests that a duplicate history entry is not created when we restore a page |
| 364 // to an existing SiteInstance. (Bug 1230446) | 364 // to an existing SiteInstance. (Bug 1230446) |
| 365 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWithExistingSiteInstance) { | 365 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWithExistingSiteInstance) { |
| 366 ASSERT_TRUE(test_server()->Start()); | 366 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 367 | 367 |
| 368 GURL http_url1(test_server()->GetURL("files/title1.html")); | 368 GURL http_url1(embedded_test_server()->GetURL("/title1.html")); |
| 369 GURL http_url2(test_server()->GetURL("files/title2.html")); | 369 GURL http_url2(embedded_test_server()->GetURL("/title2.html")); |
| 370 int tab_count = browser()->tab_strip_model()->count(); | 370 int tab_count = browser()->tab_strip_model()->count(); |
| 371 | 371 |
| 372 // Add a tab | 372 // Add a tab |
| 373 ui_test_utils::NavigateToURLWithDisposition( | 373 ui_test_utils::NavigateToURLWithDisposition( |
| 374 browser(), http_url1, NEW_FOREGROUND_TAB, | 374 browser(), http_url1, NEW_FOREGROUND_TAB, |
| 375 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 375 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 376 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); | 376 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); |
| 377 | 377 |
| 378 // Navigate to another same-site URL. | 378 // Navigate to another same-site URL. |
| 379 content::WebContents* tab = | 379 content::WebContents* tab = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance DISABLED_RestoreCrossSite
WithExistingSiteInstance | 413 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance DISABLED_RestoreCrossSite
WithExistingSiteInstance |
| 414 #else | 414 #else |
| 415 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance RestoreCrossSiteWithExist
ingSiteInstance | 415 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance RestoreCrossSiteWithExist
ingSiteInstance |
| 416 #endif | 416 #endif |
| 417 | 417 |
| 418 // Tests that the SiteInstances used for entries in a restored tab's history | 418 // Tests that the SiteInstances used for entries in a restored tab's history |
| 419 // are given appropriate max page IDs, even if the renderer for the entry | 419 // are given appropriate max page IDs, even if the renderer for the entry |
| 420 // already exists. (Bug 1204135) | 420 // already exists. (Bug 1204135) |
| 421 IN_PROC_BROWSER_TEST_F(TabRestoreTest, | 421 IN_PROC_BROWSER_TEST_F(TabRestoreTest, |
| 422 MAYBE_RestoreCrossSiteWithExistingSiteInstance) { | 422 MAYBE_RestoreCrossSiteWithExistingSiteInstance) { |
| 423 ASSERT_TRUE(test_server()->Start()); | 423 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 424 | 424 |
| 425 GURL http_url1(test_server()->GetURL("files/title1.html")); | 425 GURL http_url1(embedded_test_server()->GetURL("/title1.html")); |
| 426 GURL http_url2(test_server()->GetURL("files/title2.html")); | 426 GURL http_url2(embedded_test_server()->GetURL("/title2.html")); |
| 427 | 427 |
| 428 int tab_count = browser()->tab_strip_model()->count(); | 428 int tab_count = browser()->tab_strip_model()->count(); |
| 429 | 429 |
| 430 // Add a tab | 430 // Add a tab |
| 431 ui_test_utils::NavigateToURLWithDisposition( | 431 ui_test_utils::NavigateToURLWithDisposition( |
| 432 browser(), http_url1, NEW_FOREGROUND_TAB, | 432 browser(), http_url1, NEW_FOREGROUND_TAB, |
| 433 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 433 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 434 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); | 434 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); |
| 435 | 435 |
| 436 // Navigate to more URLs, then a cross-site URL. | 436 // Navigate to more URLs, then a cross-site URL. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 // See if content is as expected. | 544 // See if content is as expected. |
| 545 EXPECT_GT( | 545 EXPECT_GT( |
| 546 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, | 546 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, |
| 547 NULL), | 547 NULL), |
| 548 0); | 548 0); |
| 549 } | 549 } |
| 550 | 550 |
| 551 // Restore tab with special URL in its navigation history, go back to that | 551 // Restore tab with special URL in its navigation history, go back to that |
| 552 // entry and see that it loads properly. See http://crbug.com/31905 | 552 // entry and see that it loads properly. See http://crbug.com/31905 |
| 553 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreTabWithSpecialURLOnBack) { | 553 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreTabWithSpecialURLOnBack) { |
| 554 ASSERT_TRUE(test_server()->Start()); | 554 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 555 | 555 |
| 556 const GURL http_url(test_server()->GetURL("files/title1.html")); | 556 const GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
| 557 | 557 |
| 558 // Navigate new tab to a special URL. | 558 // Navigate new tab to a special URL. |
| 559 ui_test_utils::NavigateToURLWithDisposition( | 559 ui_test_utils::NavigateToURLWithDisposition( |
| 560 browser(), GURL(chrome::kChromeUICreditsURL), NEW_FOREGROUND_TAB, | 560 browser(), GURL(chrome::kChromeUICreditsURL), NEW_FOREGROUND_TAB, |
| 561 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 561 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 562 | 562 |
| 563 // Then navigate to a normal URL. | 563 // Then navigate to a normal URL. |
| 564 ui_test_utils::NavigateToURL(browser(), http_url); | 564 ui_test_utils::NavigateToURL(browser(), http_url); |
| 565 | 565 |
| 566 // Close the tab. | 566 // Close the tab. |
| 567 CloseTab(1); | 567 CloseTab(1); |
| 568 | 568 |
| 569 // Restore the closed tab. | 569 // Restore the closed tab. |
| 570 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); | 570 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); |
| 571 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); | 571 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); |
| 572 EnsureTabFinishedRestoring(tab); | 572 EnsureTabFinishedRestoring(tab); |
| 573 ASSERT_EQ(http_url, tab->GetURL()); | 573 ASSERT_EQ(http_url, tab->GetURL()); |
| 574 | 574 |
| 575 // Go back, and see if content is as expected. | 575 // Go back, and see if content is as expected. |
| 576 GoBack(browser()); | 576 GoBack(browser()); |
| 577 EXPECT_GT( | 577 EXPECT_GT( |
| 578 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, | 578 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, |
| 579 NULL), | 579 NULL), |
| 580 0); | 580 0); |
| 581 } | 581 } |
| OLD | NEW |