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

Side by Side Diff: content/browser/tab_contents/tab_contents_unittest.cc

Issue 9264049: Allow SiteInstance for about:blank in new tab to be reused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/tab_contents/tab_contents.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "content/browser/mock_content_browser_client.h" 7 #include "content/browser/mock_content_browser_client.h"
8 #include "content/browser/renderer_host/render_view_host.h" 8 #include "content/browser/renderer_host/render_view_host.h"
9 #include "content/browser/renderer_host/render_widget_host_view.h" 9 #include "content/browser/renderer_host/render_widget_host_view.h"
10 #include "content/browser/renderer_host/test_render_view_host.h" 10 #include "content/browser/renderer_host/test_render_view_host.h"
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 entry = controller().GetLastCommittedEntry(); 965 entry = controller().GetLastCommittedEntry();
966 EXPECT_FALSE(entry->GetContentState().empty()); 966 EXPECT_FALSE(entry->GetContentState().empty());
967 967
968 // Now go back. Committed entry should still have content state. 968 // Now go back. Committed entry should still have content state.
969 controller().GoBack(); 969 controller().GoBack();
970 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); 970 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED);
971 entry = controller().GetLastCommittedEntry(); 971 entry = controller().GetLastCommittedEntry();
972 EXPECT_FALSE(entry->GetContentState().empty()); 972 EXPECT_FALSE(entry->GetContentState().empty());
973 } 973 }
974 974
975 // Test that NavigationEntries have the correct content state after opening 975 // Test that NavigationEntries have the correct content state and SiteInstance
976 // a new window to about:blank. Prevents regression for bug 1116137. 976 // state after opening a new window to about:blank. Prevents regression for
977 // bugs b/1116137 and http://crbug.com/111975.
977 TEST_F(TabContentsTest, NavigationEntryContentStateNewWindow) { 978 TEST_F(TabContentsTest, NavigationEntryContentStateNewWindow) {
978 TestRenderViewHost* orig_rvh = rvh(); 979 TestRenderViewHost* orig_rvh = rvh();
979 980
980 // When opening a new window, it is navigated to about:blank internally. 981 // When opening a new window, it is navigated to about:blank internally.
981 // Currently, this results in two DidNavigate events. 982 // Currently, this results in two DidNavigate events.
982 const GURL url(chrome::kAboutBlankURL); 983 const GURL url(chrome::kAboutBlankURL);
983 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); 984 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED);
984 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED); 985 contents()->TestDidNavigate(orig_rvh, 1, url, content::PAGE_TRANSITION_TYPED);
985 986
986 // Should have a content state here. 987 // Should have a content state here.
987 NavigationEntry* entry = controller().GetLastCommittedEntry(); 988 NavigationEntry* entry = controller().GetLastCommittedEntry();
988 EXPECT_FALSE(entry->GetContentState().empty()); 989 EXPECT_FALSE(entry->GetContentState().empty());
990
991 // The SiteInstance should be available for other navigations to use.
992 NavigationEntryImpl* entry_impl =
993 NavigationEntryImpl::FromNavigationEntry(entry);
994 EXPECT_FALSE(entry_impl->site_instance()->HasSite());
995 int32 site_instance_id = entry_impl->site_instance()->GetId();
996
997 // Navigating to a normal page should not cause a process swap.
998 const GURL newUrl("http://www.google.com");
darin (slow to review) 2012/01/30 22:12:38 nit: new_url
999 controller().LoadURL(
1000 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
1001 EXPECT_FALSE(contents()->cross_navigation_pending());
1002 EXPECT_EQ(orig_rvh, contents()->GetRenderViewHost());
1003 contents()->TestDidNavigate(orig_rvh, 1, newUrl,
1004 content::PAGE_TRANSITION_TYPED);
1005 NavigationEntryImpl* entry_impl2 = NavigationEntryImpl::FromNavigationEntry(
1006 controller().GetLastCommittedEntry());
1007 EXPECT_EQ(site_instance_id, entry_impl2->site_instance()->GetId());
1008 EXPECT_TRUE(entry_impl2->site_instance()->HasSite());
989 } 1009 }
990 1010
991 //////////////////////////////////////////////////////////////////////////////// 1011 ////////////////////////////////////////////////////////////////////////////////
992 // Interstitial Tests 1012 // Interstitial Tests
993 //////////////////////////////////////////////////////////////////////////////// 1013 ////////////////////////////////////////////////////////////////////////////////
994 1014
995 // Test navigating to a page (with the navigation initiated from the browser, 1015 // Test navigating to a page (with the navigation initiated from the browser,
996 // as when a URL is typed in the location bar) that shows an interstitial and 1016 // as when a URL is typed in the location bar) that shows an interstitial and
997 // creates a new navigation entry, then hiding it without proceeding. 1017 // creates a new navigation entry, then hiding it without proceeding.
998 TEST_F(TabContentsTest, 1018 TEST_F(TabContentsTest,
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 1858
1839 // It should have a transient entry. 1859 // It should have a transient entry.
1840 EXPECT_TRUE(other_controller.GetTransientEntry()); 1860 EXPECT_TRUE(other_controller.GetTransientEntry());
1841 1861
1842 // And the interstitial should be showing. 1862 // And the interstitial should be showing.
1843 EXPECT_TRUE(other_contents->ShowingInterstitialPage()); 1863 EXPECT_TRUE(other_contents->ShowingInterstitialPage());
1844 1864
1845 // And the interstitial should do a reload on don't proceed. 1865 // And the interstitial should do a reload on don't proceed.
1846 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed()); 1866 EXPECT_TRUE(other_contents->GetInterstitialPage()->reload_on_dont_proceed());
1847 } 1867 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698