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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
31 #include "chrome/test/base/in_process_browser_test.h" | 31 #include "chrome/test/base/in_process_browser_test.h" |
32 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
33 #include "content/public/browser/navigation_controller.h" | 33 #include "content/public/browser/navigation_controller.h" |
34 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "content/public/browser/notification_types.h" | 36 #include "content/public/browser/notification_types.h" |
37 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
| 38 #include "content/public/browser/render_view_host.h" |
38 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 40 #include "content/public/common/bindings_policy.h" |
39 #include "content/public/common/page_transition_types.h" | 41 #include "content/public/common/page_transition_types.h" |
40 #include "content/public/test/test_navigation_observer.h" | 42 #include "content/public/test/test_navigation_observer.h" |
41 #include "sync/protocol/session_specifics.pb.h" | 43 #include "sync/protocol/session_specifics.pb.h" |
42 | 44 |
43 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
44 #include "base/mac/scoped_nsautorelease_pool.h" | 46 #include "base/mac/scoped_nsautorelease_pool.h" |
45 #endif | 47 #endif |
46 | 48 |
47 class SessionRestoreTest : public InProcessBrowserTest { | 49 class SessionRestoreTest : public InProcessBrowserTest { |
48 protected: | 50 protected: |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 568 |
567 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 569 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
568 ASSERT_EQ(1u, BrowserList::size()); | 570 ASSERT_EQ(1u, BrowserList::size()); |
569 ASSERT_EQ(url2_, | 571 ASSERT_EQ(url2_, |
570 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 572 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
571 GoBack(new_browser); | 573 GoBack(new_browser); |
572 ASSERT_EQ(url1_, | 574 ASSERT_EQ(url1_, |
573 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 575 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
574 } | 576 } |
575 | 577 |
| 578 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWebUI) { |
| 579 const GURL webui_url("chrome://settings"); |
| 580 ui_test_utils::NavigateToURL(browser(), webui_url); |
| 581 const content::WebContents* old_tab = |
| 582 browser()->tab_strip_model()->GetActiveWebContents(); |
| 583 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
| 584 old_tab->GetRenderViewHost()->GetEnabledBindings()); |
| 585 |
| 586 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 587 ASSERT_EQ(1u, BrowserList::size()); |
| 588 const content::WebContents* new_tab = |
| 589 new_browser->tab_strip_model()->GetActiveWebContents(); |
| 590 EXPECT_EQ(webui_url, new_tab->GetURL()); |
| 591 EXPECT_EQ(content::BINDINGS_POLICY_WEB_UI, |
| 592 new_tab->GetRenderViewHost()->GetEnabledBindings()); |
| 593 } |
| 594 |
576 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { | 595 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoresForwardAndBackwardNavs) { |
577 ui_test_utils::NavigateToURL(browser(), url1_); | 596 ui_test_utils::NavigateToURL(browser(), url1_); |
578 ui_test_utils::NavigateToURL(browser(), url2_); | 597 ui_test_utils::NavigateToURL(browser(), url2_); |
579 ui_test_utils::NavigateToURL(browser(), url3_); | 598 ui_test_utils::NavigateToURL(browser(), url3_); |
580 | 599 |
581 GoBack(browser()); | 600 GoBack(browser()); |
582 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 601 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
583 ASSERT_EQ(1u, BrowserList::size()); | 602 ASSERT_EQ(1u, BrowserList::size()); |
584 ASSERT_EQ(url2_, | 603 ASSERT_EQ(url2_, |
585 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); | 604 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 content::NavigationController* controller = | 952 content::NavigationController* controller = |
934 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 953 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
935 EXPECT_TRUE( | 954 EXPECT_TRUE( |
936 controller->GetDefaultSessionStorageNamespace()->should_persist()); | 955 controller->GetDefaultSessionStorageNamespace()->should_persist()); |
937 | 956 |
938 // Quit and restore. Check that no extra tabs were created. | 957 // Quit and restore. Check that no extra tabs were created. |
939 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 958 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
940 ASSERT_EQ(1u, BrowserList::size()); | 959 ASSERT_EQ(1u, BrowserList::size()); |
941 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); | 960 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); |
942 } | 961 } |
OLD | NEW |