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

Unified Diff: chrome/browser/sessions/session_restore_browsertest.cc

Issue 10969012: Fix: Prerendering was confusing SessionService to not save sessionStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sessions/session_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_restore_browsertest.cc
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index ed7044033254e521ea30c144fc05b7ac6f4349b5..67d6cbe378c76cf9d45f724c224234065b41dc7a 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -852,3 +853,36 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorage) {
EXPECT_EQ(session_storage_persistent_id,
restored_session_storage_persistent_id);
}
+
+IN_PROC_BROWSER_TEST_F(SessionRestoreTest, SessionStorageAfterTabReplace) {
+ // Simulate what prerendering does: create a new TabContents with the same
+ // SessionStorageNamespace as an existing tab, then replace the tab with it.
+ {
+ content::NavigationController* controller =
+ &chrome::GetActiveWebContents(browser())->GetController();
+ ASSERT_TRUE(controller->GetDefaultSessionStorageNamespace());
+
+ content::SessionStorageNamespaceMap session_storage_namespace_map;
+ session_storage_namespace_map[""] =
+ controller->GetDefaultSessionStorageNamespace();
+ scoped_ptr<content::WebContents> web_contents(
+ content::WebContents::CreateWithSessionStorage(
+ browser()->profile(), NULL, MSG_ROUTING_NONE, NULL,
+ session_storage_namespace_map));
+
+ TabStripModel* tab_strip_model = browser()->tab_strip_model();
Avi (use Gerrit) 2012/09/21 12:51:00 Can you note that you don't need any of the helper
marja 2012/09/21 13:15:02 Done.
+ scoped_ptr<TabContents> old_tab_contents(
+ tab_strip_model->ReplaceTabContentsAt(
+ tab_strip_model->active_index(),
+ TabContents::Factory::CreateTabContents(web_contents.release())));
+ // Navigate with the new tab.
+ ui_test_utils::NavigateToURL(browser(), url2_);
+ // old_tab_contents goes out of scope.
+ }
+
+ // Check that the sessionStorage data is going to be persisted.
+ content::NavigationController* controller =
+ &chrome::GetActiveWebContents(browser())->GetController();
+ EXPECT_TRUE(
+ controller->GetDefaultSessionStorageNamespace()->should_persist());
+}
« no previous file with comments | « no previous file | chrome/browser/sessions/session_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698