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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/test/scoped_feature_list.h" |
16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
17 #include "chrome/browser/background/background_mode_manager.h" | 18 #include "chrome/browser/background/background_mode_manager.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 20 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
20 #include "chrome/browser/defaults.h" | 21 #include "chrome/browser/defaults.h" |
21 #include "chrome/browser/infobars/infobar_service.h" | 22 #include "chrome/browser/infobars/infobar_service.h" |
22 #include "chrome/browser/lifetime/keep_alive_types.h" | 23 #include "chrome/browser/lifetime/keep_alive_types.h" |
23 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 24 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
24 #include "chrome/browser/prefs/session_startup_pref.h" | 25 #include "chrome/browser/prefs/session_startup_pref.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/profiles/profile_impl.h" | 27 #include "chrome/browser/profiles/profile_impl.h" |
27 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
28 #include "chrome/browser/sessions/session_restore_test_helper.h" | 29 #include "chrome/browser/sessions/session_restore_test_helper.h" |
29 #include "chrome/browser/sessions/session_service_factory.h" | 30 #include "chrome/browser/sessions/session_service_factory.h" |
30 #include "chrome/browser/sessions/session_service_test_helper.h" | 31 #include "chrome/browser/sessions/session_service_test_helper.h" |
31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
32 #include "chrome/browser/ui/browser_commands.h" | 33 #include "chrome/browser/ui/browser_commands.h" |
33 #include "chrome/browser/ui/browser_list.h" | 34 #include "chrome/browser/ui/browser_list.h" |
34 #include "chrome/browser/ui/browser_window.h" | 35 #include "chrome/browser/ui/browser_window.h" |
35 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 36 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 38 #include "chrome/browser/ui/webui/md_history_ui.h" |
| 39 #include "chrome/common/chrome_features.h" |
37 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
38 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
39 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
40 #include "chrome/test/base/in_process_browser_test.h" | 43 #include "chrome/test/base/in_process_browser_test.h" |
41 #include "chrome/test/base/ui_test_utils.h" | 44 #include "chrome/test/base/ui_test_utils.h" |
42 #include "components/content_settings/core/browser/cookie_settings.h" | 45 #include "components/content_settings/core/browser/cookie_settings.h" |
43 #include "components/content_settings/core/common/content_settings.h" | 46 #include "components/content_settings/core/common/content_settings.h" |
44 #include "components/infobars/core/confirm_infobar_delegate.h" | 47 #include "components/infobars/core/confirm_infobar_delegate.h" |
45 #include "components/prefs/pref_service.h" | 48 #include "components/prefs/pref_service.h" |
46 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, SessionCookiesBrowserClose) { | 478 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, SessionCookiesBrowserClose) { |
476 // Set the startup preference to "continue where I left off" and visit a page | 479 // Set the startup preference to "continue where I left off" and visit a page |
477 // which stores a session cookie. | 480 // which stores a session cookie. |
478 StoreDataWithPage("session_cookies.html"); | 481 StoreDataWithPage("session_cookies.html"); |
479 Browser* new_browser = QuitBrowserAndRestore(browser(), false); | 482 Browser* new_browser = QuitBrowserAndRestore(browser(), false); |
480 // The browsing session will be continued; just wait for the page to reload | 483 // The browsing session will be continued; just wait for the page to reload |
481 // and check the stored data. | 484 // and check the stored data. |
482 CheckReloadedPageRestored(new_browser); | 485 CheckReloadedPageRestored(new_browser); |
483 } | 486 } |
484 | 487 |
| 488 // Test that switching MD History on behaves correctly with session restore. |
| 489 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, MDHistoryUpgrade) { |
| 490 MdHistoryUI::use_test_title = true; |
| 491 { |
| 492 base::test::ScopedFeatureList feature_list; |
| 493 feature_list.InitAndDisableFeature(features::kMaterialDesignHistory); |
| 494 content::WebContents* web_contents = |
| 495 browser()->tab_strip_model()->GetActiveWebContents(); |
| 496 content::TitleWatcher title_watcher(web_contents, |
| 497 base::ASCIIToUTF16("History")); |
| 498 ui_test_utils::NavigateToURL(browser(), GURL("chrome://history")); |
| 499 base::string16 final_title = title_watcher.WaitAndGetTitle(); |
| 500 } |
| 501 { |
| 502 base::test::ScopedFeatureList feature_list; |
| 503 feature_list.InitAndEnableFeature(features::kMaterialDesignHistory); |
| 504 Browser* new_browser = QuitBrowserAndRestore(browser(), false); |
| 505 // The new history page should have loaded. |
| 506 CheckTitle(new_browser, base::ASCIIToUTF16("MD History")); |
| 507 } |
| 508 } |
| 509 |
485 // Test that leaving a popup open will not prevent session restore. | 510 // Test that leaving a popup open will not prevent session restore. |
486 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, | 511 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, |
487 SessionCookiesBrowserCloseWithPopupOpen) { | 512 SessionCookiesBrowserCloseWithPopupOpen) { |
488 // Set the startup preference to "continue where I left off" and visit a page | 513 // Set the startup preference to "continue where I left off" and visit a page |
489 // which stores a session cookie. | 514 // which stores a session cookie. |
490 StoreDataWithPage("session_cookies.html"); | 515 StoreDataWithPage("session_cookies.html"); |
491 Browser* popup = new Browser( | 516 Browser* popup = new Browser( |
492 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); | 517 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
493 popup->window()->Show(); | 518 popup->window()->Show(); |
494 | 519 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 CookieSettingsFactory::GetForProfile(new_browser->profile()) | 861 CookieSettingsFactory::GetForProfile(new_browser->profile()) |
837 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 862 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
838 // ... even if background mode is active. | 863 // ... even if background mode is active. |
839 EnableBackgroundMode(); | 864 EnableBackgroundMode(); |
840 new_browser = QuitBrowserAndRestore(new_browser, true); | 865 new_browser = QuitBrowserAndRestore(new_browser, true); |
841 StoreDataWithPage(new_browser, "cookies.html"); | 866 StoreDataWithPage(new_browser, "cookies.html"); |
842 DisableBackgroundMode(); | 867 DisableBackgroundMode(); |
843 new_browser = QuitBrowserAndRestore(new_browser, true); | 868 new_browser = QuitBrowserAndRestore(new_browser, true); |
844 StoreDataWithPage(new_browser, "cookies.html"); | 869 StoreDataWithPage(new_browser, "cookies.html"); |
845 } | 870 } |
OLD | NEW |