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 : native_browser_list(BrowserList::GetInstance( | 37 : native_browser_list(BrowserList::GetInstance( |
38 chrome::HOST_DESKTOP_TYPE_NATIVE)) { | 38 chrome::HOST_DESKTOP_TYPE_NATIVE)) { |
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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // Restore the next-to-last-closed tab into the same window. | 357 // Restore the next-to-last-closed tab into the same window. |
358 ASSERT_NO_FATAL_FAILURE(RestoreTab(1, 0)); | 358 ASSERT_NO_FATAL_FAILURE(RestoreTab(1, 0)); |
359 EXPECT_EQ(2, browser->tab_strip_model()->count()); | 359 EXPECT_EQ(2, browser->tab_strip_model()->count()); |
360 EXPECT_EQ(url1_, | 360 EXPECT_EQ(url1_, |
361 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 361 browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
362 } | 362 } |
363 | 363 |
364 // Tests that a duplicate history entry is not created when we restore a page | 364 // Tests that a duplicate history entry is not created when we restore a page |
365 // to an existing SiteInstance. (Bug 1230446) | 365 // to an existing SiteInstance. (Bug 1230446) |
366 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWithExistingSiteInstance) { | 366 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreWithExistingSiteInstance) { |
367 ASSERT_TRUE(test_server()->Start()); | 367 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
368 | 368 |
369 GURL http_url1(test_server()->GetURL("files/title1.html")); | 369 GURL http_url1(embedded_test_server()->GetURL("/title1.html")); |
370 GURL http_url2(test_server()->GetURL("files/title2.html")); | 370 GURL http_url2(embedded_test_server()->GetURL("/title2.html")); |
371 int tab_count = browser()->tab_strip_model()->count(); | 371 int tab_count = browser()->tab_strip_model()->count(); |
372 | 372 |
373 // Add a tab | 373 // Add a tab |
374 ui_test_utils::NavigateToURLWithDisposition( | 374 ui_test_utils::NavigateToURLWithDisposition( |
375 browser(), http_url1, NEW_FOREGROUND_TAB, | 375 browser(), http_url1, NEW_FOREGROUND_TAB, |
376 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 376 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
377 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); | 377 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); |
378 | 378 |
379 // Navigate to another same-site URL. | 379 // Navigate to another same-site URL. |
380 content::WebContents* tab = | 380 content::WebContents* tab = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance DISABLED_RestoreCrossSite
WithExistingSiteInstance | 414 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance DISABLED_RestoreCrossSite
WithExistingSiteInstance |
415 #else | 415 #else |
416 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance RestoreCrossSiteWithExist
ingSiteInstance | 416 #define MAYBE_RestoreCrossSiteWithExistingSiteInstance RestoreCrossSiteWithExist
ingSiteInstance |
417 #endif | 417 #endif |
418 | 418 |
419 // Tests that the SiteInstances used for entries in a restored tab's history | 419 // Tests that the SiteInstances used for entries in a restored tab's history |
420 // are given appropriate max page IDs, even if the renderer for the entry | 420 // are given appropriate max page IDs, even if the renderer for the entry |
421 // already exists. (Bug 1204135) | 421 // already exists. (Bug 1204135) |
422 IN_PROC_BROWSER_TEST_F(TabRestoreTest, | 422 IN_PROC_BROWSER_TEST_F(TabRestoreTest, |
423 MAYBE_RestoreCrossSiteWithExistingSiteInstance) { | 423 MAYBE_RestoreCrossSiteWithExistingSiteInstance) { |
424 ASSERT_TRUE(test_server()->Start()); | 424 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
425 | 425 |
426 GURL http_url1(test_server()->GetURL("files/title1.html")); | 426 GURL http_url1(embedded_test_server()->GetURL("/title1.html")); |
427 GURL http_url2(test_server()->GetURL("files/title2.html")); | 427 GURL http_url2(embedded_test_server()->GetURL("/title2.html")); |
428 | 428 |
429 int tab_count = browser()->tab_strip_model()->count(); | 429 int tab_count = browser()->tab_strip_model()->count(); |
430 | 430 |
431 // Add a tab | 431 // Add a tab |
432 ui_test_utils::NavigateToURLWithDisposition( | 432 ui_test_utils::NavigateToURLWithDisposition( |
433 browser(), http_url1, NEW_FOREGROUND_TAB, | 433 browser(), http_url1, NEW_FOREGROUND_TAB, |
434 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 434 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
435 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); | 435 EXPECT_EQ(++tab_count, browser()->tab_strip_model()->count()); |
436 | 436 |
437 // Navigate to more URLs, then a cross-site URL. | 437 // Navigate to more URLs, then a cross-site URL. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // See if content is as expected. | 545 // See if content is as expected. |
546 EXPECT_GT( | 546 EXPECT_GT( |
547 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, | 547 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, |
548 NULL), | 548 NULL), |
549 0); | 549 0); |
550 } | 550 } |
551 | 551 |
552 // Restore tab with special URL in its navigation history, go back to that | 552 // Restore tab with special URL in its navigation history, go back to that |
553 // entry and see that it loads properly. See http://crbug.com/31905 | 553 // entry and see that it loads properly. See http://crbug.com/31905 |
554 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreTabWithSpecialURLOnBack) { | 554 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreTabWithSpecialURLOnBack) { |
555 ASSERT_TRUE(test_server()->Start()); | 555 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
556 | 556 |
557 const GURL http_url(test_server()->GetURL("files/title1.html")); | 557 const GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
558 | 558 |
559 // Navigate new tab to a special URL. | 559 // Navigate new tab to a special URL. |
560 ui_test_utils::NavigateToURLWithDisposition( | 560 ui_test_utils::NavigateToURLWithDisposition( |
561 browser(), GURL(chrome::kChromeUICreditsURL), NEW_FOREGROUND_TAB, | 561 browser(), GURL(chrome::kChromeUICreditsURL), NEW_FOREGROUND_TAB, |
562 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 562 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
563 | 563 |
564 // Then navigate to a normal URL. | 564 // Then navigate to a normal URL. |
565 ui_test_utils::NavigateToURL(browser(), http_url); | 565 ui_test_utils::NavigateToURL(browser(), http_url); |
566 | 566 |
567 // Close the tab. | 567 // Close the tab. |
568 CloseTab(1); | 568 CloseTab(1); |
569 | 569 |
570 // Restore the closed tab. | 570 // Restore the closed tab. |
571 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); | 571 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); |
572 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); | 572 content::WebContents* tab = browser()->tab_strip_model()->GetWebContentsAt(1); |
573 EnsureTabFinishedRestoring(tab); | 573 EnsureTabFinishedRestoring(tab); |
574 ASSERT_EQ(http_url, tab->GetURL()); | 574 ASSERT_EQ(http_url, tab->GetURL()); |
575 | 575 |
576 // Go back, and see if content is as expected. | 576 // Go back, and see if content is as expected. |
577 GoBack(browser()); | 577 GoBack(browser()); |
578 EXPECT_GT( | 578 EXPECT_GT( |
579 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, | 579 ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, |
580 NULL), | 580 NULL), |
581 0); | 581 0); |
582 } | 582 } |
OLD | NEW |