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

Unified Diff: content/browser/web_contents/navigation_controller_impl_unittest.cc

Issue 10831116: Move SessionStorageNamespace entirely into NavigationController and support StoragePartitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix content shell Created 8 years, 5 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
Index: content/browser/web_contents/navigation_controller_impl_unittest.cc
diff --git a/content/browser/web_contents/navigation_controller_impl_unittest.cc b/content/browser/web_contents/navigation_controller_impl_unittest.cc
index f2f5017488727319674da65813aafe22290b81d3..ff2f92511e8650255f2f5a6a50ca7e34d854bc33 100644
--- a/content/browser/web_contents/navigation_controller_impl_unittest.cc
+++ b/content/browser/web_contents/navigation_controller_impl_unittest.cc
@@ -38,6 +38,7 @@ using content::NavigationController;
using content::NavigationEntry;
using content::NavigationEntryImpl;
using content::RenderViewHostImplTestHarness;
+using content::SessionStorageNamespaceMap;
using content::SiteInstance;
using content::TestNotificationTracker;
using content::TestRenderViewHost;
@@ -1578,9 +1579,10 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
entry->SetTitle(ASCIIToUTF16("Title"));
entry->SetContentState("state");
entries.push_back(entry);
- WebContentsImpl our_contents(
- browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL, NULL);
- NavigationControllerImpl& our_controller = our_contents.GetControllerImpl();
+ scoped_ptr<WebContentsImpl> our_contents(
+ WebContentsImpl::Create(browser_context(), NULL, MSG_ROUTING_NONE,
+ NULL));
+ NavigationControllerImpl& our_controller = our_contents->GetController();
our_controller.Restore(0, true, &entries);
ASSERT_EQ(0u, entries.size());
@@ -1645,9 +1647,10 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
entry->SetTitle(ASCIIToUTF16("Title"));
entry->SetContentState("state");
entries.push_back(entry);
- WebContentsImpl our_contents(
- browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL, NULL);
- NavigationControllerImpl& our_controller = our_contents.GetControllerImpl();
+ scoped_ptr<WebContentsImpl> our_contents(
+ WebContentsImpl::Create(browser_context(), NULL, MSG_ROUTING_NONE,
+ NULL));
+ NavigationControllerImpl& our_controller = our_contents->GetController();
our_controller.Restore(0, true, &entries);
ASSERT_EQ(0u, entries.size());
@@ -1675,7 +1678,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
// This pending navigation may have caused a different navigation to fail,
// which causes the pending entry to be cleared.
TestRenderViewHost* rvh =
- static_cast<TestRenderViewHost*>(our_contents.GetRenderViewHost());
+ static_cast<TestRenderViewHost*>(our_contents->GetRenderViewHost());
ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params;
fail_load_params.frame_id = 1;
fail_load_params.is_main_frame = true;
@@ -2114,8 +2117,7 @@ TEST_F(NavigationControllerTest, CopyStateFrom) {
scoped_ptr<TestWebContents> other_contents(
static_cast<TestWebContents*>(CreateTestWebContents()));
- NavigationControllerImpl& other_controller =
- other_contents->GetControllerImpl();
+ NavigationControllerImpl& other_controller = other_contents->GetController();
other_controller.CopyStateFrom(controller);
// other_controller should now contain 2 urls.
@@ -2134,6 +2136,25 @@ TEST_F(NavigationControllerTest, CopyStateFrom) {
SiteInstance* instance1 =
GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0));
EXPECT_EQ(0, other_contents->GetMaxPageIDForSiteInstance(instance1));
+
+ // Ensure the SessionStorageNamespaceMaps are the same size and have
+ // the same partitons loaded.
+ //
+ // TODO(ajwong): We should load up a url from a different partition above.
+ const SessionStorageNamespaceMap& session_storage_namespace_map =
+ controller.GetSessionStorageNamespaceMap();
+ const SessionStorageNamespaceMap& other_session_storage_namespace_map =
+ other_controller.GetSessionStorageNamespaceMap();
Charlie Reis 2012/08/02 23:06:47 nit: indent
awong 2012/08/03 00:31:04 Done.
+ EXPECT_EQ(session_storage_namespace_map.size(),
+ other_session_storage_namespace_map.size());
+ for (SessionStorageNamespaceMap::const_iterator it =
+ session_storage_namespace_map.begin();
+ it != session_storage_namespace_map.end();
+ ++it) {
+ SessionStorageNamespaceMap::const_iterator other =
+ other_session_storage_namespace_map.find(it->first);
+ EXPECT_TRUE(other != other_session_storage_namespace_map.end());
Charlie Reis 2012/08/02 23:06:47 EXPECT_NE?
awong 2012/08/03 00:31:04 Done.
+ }
}
// Tests CopyStateFromAndPrune with 2 urls in source, 1 in dest.
@@ -2158,8 +2179,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune) {
scoped_ptr<TestWebContents> other_contents(
static_cast<TestWebContents*>(CreateTestWebContents()));
- NavigationControllerImpl& other_controller =
- other_contents->GetControllerImpl();
+ NavigationControllerImpl& other_controller = other_contents->GetController();
other_contents->NavigateAndCommit(url3);
other_contents->ExpectSetHistoryLengthAndPrune(
GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2,
@@ -2204,8 +2224,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune2) {
scoped_ptr<TestWebContents> other_contents(
static_cast<TestWebContents*>(CreateTestWebContents()));
- NavigationControllerImpl& other_controller =
- other_contents->GetControllerImpl();
+ NavigationControllerImpl& other_controller = other_contents->GetController();
other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1);
other_controller.CopyStateFromAndPrune(&controller);
@@ -2239,8 +2258,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPrune3) {
scoped_ptr<TestWebContents> other_contents(
static_cast<TestWebContents*>(CreateTestWebContents()));
- NavigationControllerImpl& other_controller =
- other_contents->GetControllerImpl();
+ NavigationControllerImpl& other_controller = other_contents->GetController();
other_controller.LoadURL(
url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
other_contents->ExpectSetHistoryLengthAndPrune(NULL, 1, -1);
@@ -2290,8 +2308,7 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPruneMaxEntries) {
scoped_ptr<TestWebContents> other_contents(
static_cast<TestWebContents*>(CreateTestWebContents()));
- NavigationControllerImpl& other_controller =
- other_contents->GetControllerImpl();
+ NavigationControllerImpl& other_controller = other_contents->GetController();
other_contents->NavigateAndCommit(url4);
other_contents->ExpectSetHistoryLengthAndPrune(
GetSiteInstanceFromEntry(other_controller.GetEntryAtIndex(0)), 2,

Powered by Google App Engine
This is Rietveld 408576698