| 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/files/file_path.h" | 6 #include "base/files/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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 | 978 |
| 979 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { | 979 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) { |
| 980 // Simulate what prerendering does: create a new WebContents with the same | 980 // Simulate what prerendering does: create a new WebContents with the same |
| 981 // SessionStorageNamespace as an existing tab, then replace the tab with it. | 981 // SessionStorageNamespace as an existing tab, then replace the tab with it. |
| 982 { | 982 { |
| 983 content::NavigationController* controller = | 983 content::NavigationController* controller = |
| 984 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 984 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 985 ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace()); | 985 ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace()); |
| 986 | 986 |
| 987 content::SessionStorageNamespaceMap session_storage_namespace_map; | 987 content::SessionStorageNamespaceMap session_storage_namespace_map; |
| 988 session_storage_namespace_map[""] = | 988 session_storage_namespace_map[std::string()] = |
| 989 controller->GetDefaultSessionStorageNamespace(); | 989 controller->GetDefaultSessionStorageNamespace(); |
| 990 scoped_ptr<content::WebContents> web_contents( | 990 scoped_ptr<content::WebContents> web_contents( |
| 991 content::WebContents::CreateWithSessionStorage( | 991 content::WebContents::CreateWithSessionStorage( |
| 992 content::WebContents::CreateParams(browser()->profile()), | 992 content::WebContents::CreateParams(browser()->profile()), |
| 993 session_storage_namespace_map)); | 993 session_storage_namespace_map)); |
| 994 | 994 |
| 995 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 995 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
| 996 scoped_ptr<content::WebContents> old_web_contents( | 996 scoped_ptr<content::WebContents> old_web_contents( |
| 997 tab_strip_model->ReplaceWebContentsAt( | 997 tab_strip_model->ReplaceWebContentsAt( |
| 998 tab_strip_model->active_index(), web_contents.release())); | 998 tab_strip_model->active_index(), web_contents.release())); |
| 999 // Navigate with the new tab. | 999 // Navigate with the new tab. |
| 1000 ui_test_utils::NavigateToURL(browser(), url2_); | 1000 ui_test_utils::NavigateToURL(browser(), url2_); |
| 1001 // old_web_contents goes out of scope. | 1001 // old_web_contents goes out of scope. |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 // Check that the sessionStorage data is going to be persisted. | 1004 // Check that the sessionStorage data is going to be persisted. |
| 1005 content::NavigationController* controller = | 1005 content::NavigationController* controller = |
| 1006 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); | 1006 &browser()->tab_strip_model()->GetActiveWebContents()->GetController(); |
| 1007 EXPECT_TRUE( | 1007 EXPECT_TRUE( |
| 1008 controller->GetDefaultSessionStorageNamespace()->should_persist()); | 1008 controller->GetDefaultSessionStorageNamespace()->should_persist()); |
| 1009 | 1009 |
| 1010 // Quit and restore. Check that no extra tabs were created. | 1010 // Quit and restore. Check that no extra tabs were created. |
| 1011 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 1011 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 1012 ASSERT_EQ(1u, native_browser_list->size()); | 1012 ASSERT_EQ(1u, native_browser_list->size()); |
| 1013 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); | 1013 EXPECT_EQ(1, new_browser->tab_strip_model()->count()); |
| 1014 } | 1014 } |
| OLD | NEW |