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

Unified Diff: chrome/browser/tab_contents/web_contents_unittest.cc

Issue 8785004: Change NavigationController::LoadURL to take a Referrer class instead of a GURL as referrer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years 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 | « chrome/browser/sidebar/sidebar_container.cc ('k') | chrome/browser/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/web_contents_unittest.cc
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index df1cc98ad0d733adff82cb3534a5ebc82341b8bb..5722e5ef28e7ad325b5ae263a0c881378d8ccd0e 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -225,7 +225,8 @@ TEST_F(TabContentsTest, NTPViewSource) {
process()->sink().ClearMessages();
controller().LoadURL(
- kGURL, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ kGURL, content::Referrer(), content::PAGE_TRANSITION_TYPED,
+ std::string());
rvh()->delegate()->RenderViewCreated(rvh());
// Did we get the expected message?
EXPECT_TRUE(process()->sink().GetFirstMessageMatching(
@@ -248,7 +249,7 @@ TEST_F(TabContentsTest, SimpleNavigation) {
// Navigate to URL
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_EQ(instance1, orig_rvh->site_instance());
// Controller's pending entry will have a NULL site instance until we assign
@@ -274,7 +275,8 @@ TEST_F(TabContentsTest, NavigateToExcessivelyLongURL) {
content::kMaxURLChars + 1, 'a'));
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_GENERATED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_GENERATED,
+ std::string());
EXPECT_TRUE(controller().GetActiveEntry() == NULL);
}
@@ -290,7 +292,7 @@ TEST_F(TabContentsTest, CrossSiteBoundaries) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -301,7 +303,7 @@ TEST_F(TabContentsTest, CrossSiteBoundaries) {
// Navigate to new site
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(contents()->cross_navigation_pending());
TestRenderViewHost* pending_rvh = contents()->pending_rvh();
int pending_rvh_delete_count = 0;
@@ -367,7 +369,7 @@ TEST_F(TabContentsTest, CrossSiteBoundariesAfterCrash) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -381,7 +383,7 @@ TEST_F(TabContentsTest, CrossSiteBoundariesAfterCrash) {
// Navigate to new site. We should not go into PENDING.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
TestRenderViewHost* new_rvh = rvh();
EXPECT_FALSE(contents()->cross_navigation_pending());
EXPECT_TRUE(contents()->pending_rvh() == NULL);
@@ -414,7 +416,7 @@ TEST_F(TabContentsTest, NavigateTwoTabsCrossSite) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -425,14 +427,16 @@ TEST_F(TabContentsTest, NavigateTwoTabsCrossSite) {
// is the scope of page IDs) and we want to consider
// this a new page.
contents2.transition_cross_site = true;
- contents2.controller().LoadURL(url, GURL(), content::PAGE_TRANSITION_TYPED,
+ contents2.controller().LoadURL(url, content::Referrer(),
+ content::PAGE_TRANSITION_TYPED,
std::string());
contents2.TestDidNavigate(contents2.render_view_host(), params1);
// Navigate first tab to a new site
const GURL url2a("http://www.yahoo.com");
controller().LoadURL(
- url2a, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2a, content::Referrer(), content::PAGE_TRANSITION_TYPED,
+ std::string());
orig_rvh->SendShouldCloseACK(true);
TestRenderViewHost* pending_rvh_a = contents()->pending_rvh();
ViewHostMsg_FrameNavigate_Params params2a;
@@ -443,7 +447,8 @@ TEST_F(TabContentsTest, NavigateTwoTabsCrossSite) {
// Navigate second tab to the same site as the first tab
const GURL url2b("http://mail.yahoo.com");
- contents2.controller().LoadURL(url2b, GURL(), content::PAGE_TRANSITION_TYPED,
+ contents2.controller().LoadURL(url2b, content::Referrer(),
+ content::PAGE_TRANSITION_TYPED,
std::string());
TestRenderViewHost* rvh2 =
static_cast<TestRenderViewHost*>(contents2.render_view_host());
@@ -476,7 +481,7 @@ TEST_F(TabContentsTest, CrossSiteComparesAgainstCurrentPage) {
// Navigate to URL.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -485,7 +490,8 @@ TEST_F(TabContentsTest, CrossSiteComparesAgainstCurrentPage) {
TestTabContents contents2(profile(), instance1);
contents2.transition_cross_site = true;
const GURL url2("http://www.yahoo.com");
- contents2.controller().LoadURL(url2, GURL(), content::PAGE_TRANSITION_TYPED,
+ contents2.controller().LoadURL(url2, content::Referrer(),
+ content::PAGE_TRANSITION_TYPED,
std::string());
// The first RVH in contents2 isn't live yet, so we shortcut the cross site
// pending.
@@ -512,7 +518,7 @@ TEST_F(TabContentsTest, CrossSiteComparesAgainstCurrentPage) {
// compare against the current URL, not the SiteInstance's site.
const GURL url3("http://mail.yahoo.com");
controller().LoadURL(
- url3, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_FALSE(contents()->cross_navigation_pending());
ViewHostMsg_FrameNavigate_Params params4;
InitNavigateParams(&params4, 3, url3, content::PAGE_TRANSITION_TYPED);
@@ -531,7 +537,7 @@ TEST_F(TabContentsTest, CrossSiteUnloadHandlers) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -541,7 +547,7 @@ TEST_F(TabContentsTest, CrossSiteUnloadHandlers) {
// Navigate to new site, but simulate an onbeforeunload denial.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack());
orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, false));
EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack());
@@ -550,7 +556,7 @@ TEST_F(TabContentsTest, CrossSiteUnloadHandlers) {
// Navigate again, but simulate an onbeforeunload approval.
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack());
orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true));
EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack());
@@ -584,7 +590,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationPreempted) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -594,7 +600,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationPreempted) {
// Navigate to new site, simulating an onbeforeunload approval.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack());
orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true));
EXPECT_TRUE(contents()->cross_navigation_pending());
@@ -617,7 +623,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) {
// Start with NTP, which gets a new RVH with WebUI bindings.
const GURL url1("chrome://newtab");
controller().LoadURL(
- url1, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url1, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
TestRenderViewHost* ntp_rvh = rvh();
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url1, content::PAGE_TRANSITION_TYPED);
@@ -634,7 +640,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) {
// Navigate to new site.
const GURL url2("http://www.google.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(contents()->cross_navigation_pending());
TestRenderViewHost* google_rvh = contents()->pending_rvh();
@@ -661,7 +667,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationBackPreempted) {
// Navigate to third page on same site.
const GURL url3("http://news.google.com");
controller().LoadURL(
- url3, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url3, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_FALSE(contents()->cross_navigation_pending());
ViewHostMsg_FrameNavigate_Params params3;
InitNavigateParams(&params3, 2, url3, content::PAGE_TRANSITION_TYPED);
@@ -716,7 +722,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationNotPreemptedByFrame) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -726,7 +732,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationNotPreemptedByFrame) {
// Start navigating to new site.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
// Simulate a sub-frame navigation arriving and ensure the RVH is still
// waiting for a before unload response.
@@ -751,14 +757,14 @@ TEST_F(TabContentsTest, CrossSiteNotPreemptedDuringBeforeUnload) {
// Navigate to NTP URL.
const GURL url("chrome://newtab");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
TestRenderViewHost* orig_rvh = rvh();
EXPECT_FALSE(contents()->cross_navigation_pending());
// Navigate to new site, with the beforeunload request in flight.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
TestRenderViewHost* pending_rvh = contents()->pending_rvh();
EXPECT_TRUE(contents()->cross_navigation_pending());
EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack());
@@ -791,7 +797,7 @@ TEST_F(TabContentsTest, CrossSiteCantPreemptAfterUnload) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -801,7 +807,7 @@ TEST_F(TabContentsTest, CrossSiteCantPreemptAfterUnload) {
// Navigate to new site, simulating an onbeforeunload approval.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true));
EXPECT_TRUE(contents()->cross_navigation_pending());
TestRenderViewHost* pending_rvh = static_cast<TestRenderViewHost*>(
@@ -845,7 +851,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationCanceled) {
// Navigate to URL. First URL should use first RenderViewHost.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ViewHostMsg_FrameNavigate_Params params1;
InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
contents()->TestDidNavigate(orig_rvh, params1);
@@ -855,7 +861,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationCanceled) {
// Navigate to new site, simulating an onbeforeunload approval.
const GURL url2("http://www.yahoo.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack());
orig_rvh->TestOnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true));
EXPECT_TRUE(contents()->cross_navigation_pending());
@@ -866,7 +872,7 @@ TEST_F(TabContentsTest, CrossSiteNavigationCanceled) {
// Suppose the navigation doesn't get a chance to commit, and the user
// navigates in the current RVH's SiteInstance.
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
// Verify that the pending navigation is cancelled and the renderer is no
// longer swapped out.
@@ -887,7 +893,7 @@ TEST_F(TabContentsTest, NavigationEntryContentState) {
// Navigate to URL. There should be no committed entry yet.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
NavigationEntry* entry = controller().GetLastCommittedEntry();
EXPECT_TRUE(entry == NULL);
@@ -901,7 +907,7 @@ TEST_F(TabContentsTest, NavigationEntryContentState) {
// Navigate to same site.
const GURL url2("http://images.google.com");
controller().LoadURL(
- url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url2, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
entry = controller().GetLastCommittedEntry();
EXPECT_FALSE(entry->content_state().empty());
@@ -975,7 +981,7 @@ TEST_F(TabContentsTest,
EXPECT_EQ(1, controller().entry_count());
// Initiate a browser navigation that will trigger the interstitial
- controller().LoadURL(GURL("http://www.evil.com"), GURL(),
+ controller().LoadURL(GURL("http://www.evil.com"), content::Referrer(),
content::PAGE_TRANSITION_TYPED, std::string());
// Show an interstitial.
@@ -1112,7 +1118,7 @@ TEST_F(TabContentsTest,
EXPECT_EQ(1, controller().entry_count());
// Initiate a browser navigation that will trigger the interstitial
- controller().LoadURL(GURL("http://www.evil.com"), GURL(),
+ controller().LoadURL(GURL("http://www.evil.com"), content::Referrer(),
content::PAGE_TRANSITION_TYPED, std::string());
// Show an interstitial.
@@ -1556,7 +1562,7 @@ TEST_F(TabContentsTest, NavigateBeforeInterstitialShows) {
// interstitial finishes loading.
const GURL url("http://www.google.com");
controller().LoadURL(
- url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
ASSERT_FALSE(deleted);
EXPECT_FALSE(interstitial->is_showing());
@@ -1647,7 +1653,8 @@ TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) {
// Start a navigation to a page
contents()->controller().LoadURL(
- kGURL, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ kGURL, content::Referrer(), content::PAGE_TRANSITION_TYPED,
+ std::string());
// Simulate that navigation triggering an interstitial.
TestInterstitialPage::InterstitialState state =
@@ -1662,7 +1669,8 @@ TEST_F(TabContentsTest, NewInterstitialDoesNotCancelPendingEntry) {
// Initiate a new navigation from the browser that also triggers an
// interstitial.
contents()->controller().LoadURL(
- kGURL, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ kGURL, content::Referrer(), content::PAGE_TRANSITION_TYPED,
+ std::string());
TestInterstitialPage::InterstitialState state2 =
TestInterstitialPage::UNDECIDED;
bool deleted2 = false;
@@ -1692,7 +1700,8 @@ TEST_F(TabContentsTest, NoJSMessageOnInterstitials) {
// Start a navigation to a page
contents()->controller().LoadURL(
- kGURL, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
+ kGURL, content::Referrer(), content::PAGE_TRANSITION_TYPED,
+ std::string());
// DidNavigate from the page
ViewHostMsg_FrameNavigate_Params params;
InitNavigateParams(&params, 1, kGURL, content::PAGE_TRANSITION_TYPED);
@@ -1728,7 +1737,7 @@ TEST_F(TabContentsTest, CopyStateFromAndPruneSourceInterstitial) {
EXPECT_EQ(1, controller().entry_count());
// Initiate a browser navigation that will trigger the interstitial
- controller().LoadURL(GURL("http://www.evil.com"), GURL(),
+ controller().LoadURL(GURL("http://www.evil.com"), content::Referrer(),
content::PAGE_TRANSITION_TYPED, std::string());
// Show an interstitial.
« no previous file with comments | « chrome/browser/sidebar/sidebar_container.cc ('k') | chrome/browser/tabs/tab_strip_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698