Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: chrome/browser/sessions/better_session_restore_browsertest.cc

Issue 2355543003: Invalidate the page state when restoring WebUIs (Closed)
Patch Set: fix nit Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 Browser* current_browser = browser();
492 {
493 base::test::ScopedFeatureList feature_list;
494 feature_list.InitAndDisableFeature(features::kMaterialDesignHistory);
495 content::WebContents* web_contents =
496 current_browser->tab_strip_model()->GetActiveWebContents();
497 content::TitleWatcher title_watcher(web_contents,
498 base::ASCIIToUTF16("History"));
499 ui_test_utils::NavigateToURL(current_browser, GURL("chrome://history"));
500 base::string16 final_title = title_watcher.WaitAndGetTitle();
501 EXPECT_EQ(3u, current_browser->tab_strip_model()
502 ->GetActiveWebContents()
503 ->GetAllFrames()
504 .size());
505 }
506 {
507 base::test::ScopedFeatureList feature_list;
508 feature_list.InitAndEnableFeature(features::kMaterialDesignHistory);
509 current_browser = QuitBrowserAndRestore(browser(), false);
510 // The new history page should have loaded.
511 CheckTitle(current_browser, base::ASCIIToUTF16("MD History"));
512 EXPECT_EQ(1u, current_browser->tab_strip_model()
513 ->GetActiveWebContents()
514 ->GetAllFrames()
515 .size());
516 }
517 {
518 base::test::ScopedFeatureList feature_list;
519 feature_list.InitAndDisableFeature(features::kMaterialDesignHistory);
520 current_browser = QuitBrowserAndRestore(current_browser, false);
521 // The old history page should have loaded.
522 CheckTitle(current_browser, base::ASCIIToUTF16("History"));
523 EXPECT_EQ(3u, current_browser->tab_strip_model()
524 ->GetActiveWebContents()
525 ->GetAllFrames()
526 .size());
527 }
528 }
529
485 // Test that leaving a popup open will not prevent session restore. 530 // Test that leaving a popup open will not prevent session restore.
486 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, 531 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest,
487 SessionCookiesBrowserCloseWithPopupOpen) { 532 SessionCookiesBrowserCloseWithPopupOpen) {
488 // Set the startup preference to "continue where I left off" and visit a page 533 // Set the startup preference to "continue where I left off" and visit a page
489 // which stores a session cookie. 534 // which stores a session cookie.
490 StoreDataWithPage("session_cookies.html"); 535 StoreDataWithPage("session_cookies.html");
491 Browser* popup = new Browser( 536 Browser* popup = new Browser(
492 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); 537 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile()));
493 popup->window()->Show(); 538 popup->window()->Show();
494 539
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 CookieSettingsFactory::GetForProfile(new_browser->profile()) 881 CookieSettingsFactory::GetForProfile(new_browser->profile())
837 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); 882 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY);
838 // ... even if background mode is active. 883 // ... even if background mode is active.
839 EnableBackgroundMode(); 884 EnableBackgroundMode();
840 new_browser = QuitBrowserAndRestore(new_browser, true); 885 new_browser = QuitBrowserAndRestore(new_browser, true);
841 StoreDataWithPage(new_browser, "cookies.html"); 886 StoreDataWithPage(new_browser, "cookies.html");
842 DisableBackgroundMode(); 887 DisableBackgroundMode();
843 new_browser = QuitBrowserAndRestore(new_browser, true); 888 new_browser = QuitBrowserAndRestore(new_browser, true);
844 StoreDataWithPage(new_browser, "cookies.html"); 889 StoreDataWithPage(new_browser, "cookies.html");
845 } 890 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/md_history_ui.h » ('j') | content/public/common/url_constants.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698