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" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 CloseBrowserSynchronously(browser); | 325 CloseBrowserSynchronously(browser); |
326 | 326 |
327 SessionServiceTestHelper helper; | 327 SessionServiceTestHelper helper; |
328 helper.SetService( | 328 helper.SetService( |
329 SessionServiceFactory::GetForProfileForSessionRestore(profile)); | 329 SessionServiceFactory::GetForProfileForSessionRestore(profile)); |
330 helper.SetForceBrowserNotAliveWithNoWindows(true); | 330 helper.SetForceBrowserNotAliveWithNoWindows(true); |
331 helper.ReleaseService(); | 331 helper.ReleaseService(); |
332 | 332 |
333 // Create a new window, which should trigger session restore. | 333 // Create a new window, which should trigger session restore. |
334 ui_test_utils::BrowserAddedObserver window_observer; | 334 ui_test_utils::BrowserAddedObserver window_observer; |
335 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE); | 335 chrome::NewEmptyWindow(profile); |
336 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); | 336 Browser* new_browser = window_observer.WaitForSingleNewBrowser(); |
337 chrome::DecrementKeepAliveCount(); | 337 chrome::DecrementKeepAliveCount(); |
338 | 338 |
339 return new_browser; | 339 return new_browser; |
340 } | 340 } |
341 | 341 |
342 std::string fake_server_address() { | 342 std::string fake_server_address() { |
343 return fake_server_address_; | 343 return fake_server_address_; |
344 } | 344 } |
345 | 345 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 // and check the stored data. | 479 // and check the stored data. |
480 CheckReloadedPageRestored(new_browser); | 480 CheckReloadedPageRestored(new_browser); |
481 } | 481 } |
482 | 482 |
483 // Test that leaving a popup open will not prevent session restore. | 483 // Test that leaving a popup open will not prevent session restore. |
484 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, | 484 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, |
485 SessionCookiesBrowserCloseWithPopupOpen) { | 485 SessionCookiesBrowserCloseWithPopupOpen) { |
486 // Set the startup preference to "continue where I left off" and visit a page | 486 // Set the startup preference to "continue where I left off" and visit a page |
487 // which stores a session cookie. | 487 // which stores a session cookie. |
488 StoreDataWithPage("session_cookies.html"); | 488 StoreDataWithPage("session_cookies.html"); |
489 Browser* popup = new Browser(Browser::CreateParams( | 489 Browser* popup = new Browser( |
490 Browser::TYPE_POPUP, | 490 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
491 browser()->profile(), | |
492 chrome::HOST_DESKTOP_TYPE_NATIVE)); | |
493 popup->window()->Show(); | 491 popup->window()->Show(); |
494 | 492 |
495 Browser* new_browser = QuitBrowserAndRestore(browser(), false); | 493 Browser* new_browser = QuitBrowserAndRestore(browser(), false); |
496 // The browsing session will be continued; just wait for the page to reload | 494 // The browsing session will be continued; just wait for the page to reload |
497 // and check the stored data. | 495 // and check the stored data. |
498 CheckReloadedPageRestored(new_browser); | 496 CheckReloadedPageRestored(new_browser); |
499 } | 497 } |
500 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, | 498 IN_PROC_BROWSER_TEST_F(ContinueWhereILeftOffTest, |
501 CookiesClearedOnBrowserClose) { | 499 CookiesClearedOnBrowserClose) { |
502 StoreDataWithPage("cookies.html"); | 500 StoreDataWithPage("cookies.html"); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 if (browser_defaults::kBrowserAliveWithNoWindows) | 762 if (browser_defaults::kBrowserAliveWithNoWindows) |
765 NavigateAndCheckStoredData(new_browser, "session_cookies.html"); | 763 NavigateAndCheckStoredData(new_browser, "session_cookies.html"); |
766 else | 764 else |
767 StoreDataWithPage(new_browser, "session_cookies.html"); | 765 StoreDataWithPage(new_browser, "session_cookies.html"); |
768 } | 766 } |
769 | 767 |
770 // Tests that session cookies are not cleared when only a popup window is open. | 768 // Tests that session cookies are not cleared when only a popup window is open. |
771 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, | 769 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, |
772 SessionCookiesBrowserCloseWithPopupOpen) { | 770 SessionCookiesBrowserCloseWithPopupOpen) { |
773 StoreDataWithPage("session_cookies.html"); | 771 StoreDataWithPage("session_cookies.html"); |
774 Browser* popup = new Browser(Browser::CreateParams( | 772 Browser* popup = new Browser( |
775 Browser::TYPE_POPUP, | 773 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
776 browser()->profile(), | |
777 chrome::HOST_DESKTOP_TYPE_NATIVE)); | |
778 popup->window()->Show(); | 774 popup->window()->Show(); |
779 Browser* new_browser = QuitBrowserAndRestore(browser(), false); | 775 Browser* new_browser = QuitBrowserAndRestore(browser(), false); |
780 NavigateAndCheckStoredData(new_browser, "session_cookies.html"); | 776 NavigateAndCheckStoredData(new_browser, "session_cookies.html"); |
781 } | 777 } |
782 | 778 |
783 // Tests that session cookies are cleared if the last window to close is a | 779 // Tests that session cookies are cleared if the last window to close is a |
784 // popup. | 780 // popup. |
785 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, | 781 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, |
786 SessionCookiesBrowserClosePopupLast) { | 782 SessionCookiesBrowserClosePopupLast) { |
787 StoreDataWithPage("session_cookies.html"); | 783 StoreDataWithPage("session_cookies.html"); |
788 Browser* popup = new Browser(Browser::CreateParams( | 784 Browser* popup = new Browser( |
789 Browser::TYPE_POPUP, | 785 Browser::CreateParams(Browser::TYPE_POPUP, browser()->profile())); |
790 browser()->profile(), | |
791 chrome::HOST_DESKTOP_TYPE_NATIVE)); | |
792 popup->window()->Show(); | 786 popup->window()->Show(); |
793 CloseBrowserSynchronously(browser()); | 787 CloseBrowserSynchronously(browser()); |
794 Browser* new_browser = QuitBrowserAndRestore(popup, false); | 788 Browser* new_browser = QuitBrowserAndRestore(popup, false); |
795 if (browser_defaults::kBrowserAliveWithNoWindows) | 789 if (browser_defaults::kBrowserAliveWithNoWindows) |
796 NavigateAndCheckStoredData(new_browser, "session_cookies.html"); | 790 NavigateAndCheckStoredData(new_browser, "session_cookies.html"); |
797 else | 791 else |
798 StoreDataWithPage(new_browser, "session_cookies.html"); | 792 StoreDataWithPage(new_browser, "session_cookies.html"); |
799 } | 793 } |
800 | 794 |
801 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, CookiesClearedOnBrowserClose) { | 795 IN_PROC_BROWSER_TEST_F(NoSessionRestoreTest, CookiesClearedOnBrowserClose) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 CookieSettingsFactory::GetForProfile(new_browser->profile()) | 838 CookieSettingsFactory::GetForProfile(new_browser->profile()) |
845 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); | 839 ->SetDefaultCookieSetting(CONTENT_SETTING_SESSION_ONLY); |
846 // ... even if background mode is active. | 840 // ... even if background mode is active. |
847 EnableBackgroundMode(); | 841 EnableBackgroundMode(); |
848 new_browser = QuitBrowserAndRestore(new_browser, true); | 842 new_browser = QuitBrowserAndRestore(new_browser, true); |
849 StoreDataWithPage(new_browser, "cookies.html"); | 843 StoreDataWithPage(new_browser, "cookies.html"); |
850 DisableBackgroundMode(); | 844 DisableBackgroundMode(); |
851 new_browser = QuitBrowserAndRestore(new_browser, true); | 845 new_browser = QuitBrowserAndRestore(new_browser, true); |
852 StoreDataWithPage(new_browser, "cookies.html"); | 846 StoreDataWithPage(new_browser, "cookies.html"); |
853 } | 847 } |
OLD | NEW |