diff options
Diffstat (limited to 'content/browser/web_contents/web_contents_impl_unittest.cc')
-rw-r--r-- | content/browser/web_contents/web_contents_impl_unittest.cc | 383 |
1 files changed, 247 insertions, 136 deletions
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc index 3a82a88..bc0a10a 100644 --- a/content/browser/web_contents/web_contents_impl_unittest.cc +++ b/content/browser/web_contents/web_contents_impl_unittest.cc @@ -159,9 +159,13 @@ class TestInterstitialPage : public InterstitialPageImpl { CommandReceived(); } - void TestDidNavigate(int page_id, const GURL& url) { + void TestDidNavigate(int page_id, + int nav_entry_id, + bool did_create_new_entry, + const GURL& url) { FrameHostMsg_DidCommitProvisionalLoad_Params params; - InitNavigateParams(¶ms, page_id, url, ui::PAGE_TRANSITION_TYPED); + InitNavigateParams(¶ms, page_id, nav_entry_id, did_create_new_entry, + url, ui::PAGE_TRANSITION_TYPED); DidNavigate(GetMainFrame()->GetRenderViewHost(), params); } @@ -350,8 +354,8 @@ TEST_F(WebContentsImplTest, UpdateTitle) { NavigationControllerImpl& cont = static_cast<NavigationControllerImpl&>(controller()); FrameHostMsg_DidCommitProvisionalLoad_Params params; - InitNavigateParams( - ¶ms, 0, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED); + InitNavigateParams(¶ms, 0, 0, true, GURL(url::kAboutBlankURL), + ui::PAGE_TRANSITION_TYPED); LoadCommittedDetails details; cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); @@ -393,13 +397,15 @@ TEST_F(WebContentsImplTest, NTPViewSource) { cont.LoadURL( kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = cont.GetPendingEntry()->GetUniqueID(); rvh()->GetDelegate()->RenderViewCreated(rvh()); // Did we get the expected message? EXPECT_TRUE(process()->sink().GetFirstMessageMatching( ViewMsg_EnableViewSourceMode::ID)); FrameHostMsg_DidCommitProvisionalLoad_Params params; - InitNavigateParams(¶ms, 0, kGURL, ui::PAGE_TRANSITION_TYPED); + InitNavigateParams(¶ms, 0, entry_id, true, kGURL, + ui::PAGE_TRANSITION_TYPED); LoadCommittedDetails details; cont.RendererDidNavigate(contents()->GetMainFrame(), params, &details); // Also check title and url. @@ -439,6 +445,7 @@ TEST_F(WebContentsImplTest, SimpleNavigation) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); main_test_rfh()->PrepareForCommit(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(instance1, orig_rfh->GetSiteInstance()); @@ -450,7 +457,8 @@ TEST_F(WebContentsImplTest, SimpleNavigation) { site_instance()); // DidNavigate from the page - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); EXPECT_EQ(instance1, orig_rfh->GetSiteInstance()); @@ -485,8 +493,10 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); // Keep the number of active frames in orig_rfh's SiteInstance non-zero so // that orig_rfh doesn't get deleted when it gets swapped out. @@ -501,6 +511,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) { const GURL url2("http://www.yahoo.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)) { orig_rfh->PrepareForCommit(); @@ -522,8 +533,8 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) { } // DidNavigate from the pending page - contents()->TestDidNavigate( - pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(pending_rfh, 1, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance2 = contents()->GetSiteInstance(); // Keep the number of active frames in pending_rfh's SiteInstance @@ -546,6 +557,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) { // stored in the NavigationEntry, so it should be the same as at the start. // We should use the same RFH as before, swapping it back in. controller().GoBack(); + entry_id = controller().GetPendingEntry()->GetUniqueID(); if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)) { contents()->GetMainFrame()->PrepareForCommit(); @@ -563,7 +575,8 @@ TEST_F(WebContentsImplTest, CrossSiteBoundaries) { } // DidNavigate from the back action - contents()->TestDidNavigate(goback_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(goback_rfh, 1, entry_id, false, url2, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(goback_rfh, contents()->GetMainFrame()); EXPECT_EQ(instance1, contents()->GetSiteInstance()); @@ -592,8 +605,10 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh->GetRenderViewHost(), contents()->GetRenderViewHost()); @@ -607,6 +622,7 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { const GURL url2("http://www.yahoo.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); TestRenderFrameHost* new_rfh = contents()->GetMainFrame(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); @@ -615,7 +631,8 @@ TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { EXPECT_EQ(orig_rvh_delete_count, 1); // DidNavigate from the new page - contents()->TestDidNavigate(new_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(new_rfh, 1, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance2 = contents()->GetSiteInstance(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); @@ -639,8 +656,10 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); // Open a new contents with the same SiteInstance, navigated to the same site. scoped_ptr<TestWebContents> contents2( @@ -648,20 +667,22 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) { contents2->GetController().LoadURL(url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID(); contents2->GetMainFrame()->PrepareForCommit(); // Need this page id to be 2 since the site instance is the same (which is the // scope of page IDs) and we want to consider this a new page. - contents2->TestDidNavigate( - contents2->GetMainFrame(), 2, url, ui::PAGE_TRANSITION_TYPED); + contents2->TestDidNavigate(contents2->GetMainFrame(), 2, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); // Navigate first contents to a new site. const GURL url2a("http://www.yahoo.com"); controller().LoadURL( url2a, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); TestRenderFrameHost* pending_rfh_a = contents()->GetPendingMainFrame(); - contents()->TestDidNavigate( - pending_rfh_a, 1, url2a, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(pending_rfh_a, 1, entry_id, true, url2a, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance2a = contents()->GetSiteInstance(); EXPECT_NE(instance1, instance2a); @@ -670,6 +691,7 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) { contents2->GetController().LoadURL(url2b, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID(); TestRenderFrameHost* rfh2 = contents2->GetMainFrame(); rfh2->PrepareForCommit(); TestRenderFrameHost* pending_rfh_b = contents2->GetPendingMainFrame(); @@ -679,8 +701,8 @@ TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) { // NOTE(creis): We used to be in danger of showing a crash page here if the // second contents hadn't navigated somewhere first (bug 1145430). That case // is now covered by the CrossSiteBoundariesAfterCrash test. - contents2->TestDidNavigate( - pending_rfh_b, 2, url2b, ui::PAGE_TRANSITION_TYPED); + contents2->TestDidNavigate(pending_rfh_b, 2, entry_id, true, url2b, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance2b = contents2->GetSiteInstance(); EXPECT_NE(instance1, instance2b); @@ -706,9 +728,10 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) { const GURL native_url("non-site-url://stuffandthings"); controller().LoadURL( native_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate( - orig_rfh, 1, native_url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, native_url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); @@ -723,12 +746,14 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(native_url, contents()->GetLastCommittedURL()); EXPECT_EQ(url, contents()->GetVisibleURL()); EXPECT_FALSE(contents()->GetPendingMainFrame()); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 2, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); // Keep the number of active frames in orig_rfh's SiteInstance // non-zero so that orig_rfh doesn't get deleted when it gets @@ -744,6 +769,7 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) { const GURL url2("http://www.yahoo.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)) { orig_rfh->PrepareForCommit(); @@ -765,8 +791,8 @@ TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) { } // DidNavigate from the pending page. - contents()->TestDidNavigate( - pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(pending_rfh, 1, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); SiteInstance* new_instance = contents()->GetSiteInstance(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); @@ -813,9 +839,10 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) { ASSERT_EQ(0u, entries.size()); ASSERT_EQ(1, controller().GetEntryCount()); controller().GoToIndex(0); + entry = controller().GetPendingEntry(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate( - orig_rfh, 0, native_url, ui::PAGE_TRANSITION_RELOAD); + contents()->TestDidNavigate(orig_rfh, 0, entry->GetUniqueID(), false, + native_url, ui::PAGE_TRANSITION_RELOAD); EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); EXPECT_EQ(GURL(), contents()->GetSiteInstance()->GetSiteURL()); EXPECT_FALSE(orig_instance->HasSite()); @@ -825,8 +852,10 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry = controller().GetPendingEntry(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 2, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 2, entry->GetUniqueID(), true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); // Cleanup. @@ -858,9 +887,10 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) { ASSERT_EQ(0u, entries.size()); ASSERT_EQ(1, controller().GetEntryCount()); controller().GoToIndex(0); + entry = controller().GetPendingEntry(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate( - orig_rfh, 0, regular_url, ui::PAGE_TRANSITION_RELOAD); + contents()->TestDidNavigate(orig_rfh, 0, entry->GetUniqueID(), false, + regular_url, ui::PAGE_TRANSITION_RELOAD); EXPECT_EQ(orig_instance, contents()->GetSiteInstance()); EXPECT_TRUE(orig_instance->HasSite()); @@ -868,9 +898,11 @@ TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry = controller().GetPendingEntry(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate( - contents()->GetPendingMainFrame(), 2, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(contents()->GetPendingMainFrame(), 2, + entry->GetUniqueID(), true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_NE(orig_instance, contents()->GetSiteInstance()); // Cleanup. @@ -886,8 +918,10 @@ TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); // Start to navigate first tab to a new site, so that it has a pending RVH. const GURL url2("http://www.yahoo.com"); @@ -917,9 +951,10 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate( - orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); // Open a related contents to a second site. scoped_ptr<TestWebContents> contents2( @@ -928,12 +963,15 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { contents2->GetController().LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID(); contents2->GetMainFrame()->PrepareForCommit(); + // The first RVH in contents2 isn't live yet, so we shortcut the cross site // pending. TestRenderFrameHost* rfh2 = contents2->GetMainFrame(); EXPECT_FALSE(contents2->CrossProcessNavigationPending()); - contents2->TestDidNavigate(rfh2, 2, url2, ui::PAGE_TRANSITION_TYPED); + contents2->TestDidNavigate(rfh2, 2, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance2 = contents2->GetSiteInstance(); EXPECT_NE(instance1, instance2); EXPECT_FALSE(contents2->CrossProcessNavigationPending()); @@ -942,8 +980,8 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { // SiteInstances, because we don't intercept Blink navigations. orig_rfh->SendRendererInitiatedNavigationRequest(url2, true); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate( - orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 2, 0, true, url2, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance3 = contents()->GetSiteInstance(); EXPECT_EQ(instance1, instance3); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); @@ -953,10 +991,11 @@ TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { const GURL url3("http://mail.yahoo.com"); controller().LoadURL( url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate( - orig_rfh, 3, url3, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 3, entry_id, true, url3, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance4 = contents()->GetSiteInstance(); EXPECT_EQ(instance1, instance4); } @@ -971,8 +1010,10 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); @@ -991,6 +1032,7 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) { // Navigate again, but simulate an onbeforeunload approval. controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); now = base::TimeTicks::Now(); orig_rfh->PrepareForCommit(); @@ -1001,8 +1043,8 @@ TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) { // We won't hear DidNavigate until the onunload handler has finished running. // DidNavigate from the pending page. - contents()->TestDidNavigate( - pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(pending_rfh, 1, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); SiteInstance* instance2 = contents()->GetSiteInstance(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); @@ -1021,8 +1063,10 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); @@ -1035,7 +1079,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) { EXPECT_TRUE(contents()->CrossProcessNavigationPending()); // Suppose the original renderer navigates before the new one is ready. - orig_rfh->SendNavigate(2, GURL("http://www.google.com/foo")); + orig_rfh->SendNavigate(2, 0, true, GURL("http://www.google.com/foo")); // Verify that the pending navigation is cancelled. EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); @@ -1051,9 +1095,11 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { const GURL url1("chrome://blah"); controller().LoadURL( url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); TestRenderFrameHost* ntp_rfh = contents()->GetMainFrame(); ntp_rfh->PrepareForCommit(); - contents()->TestDidNavigate(ntp_rfh, 1, url1, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(ntp_rfh, 1, entry_id, true, url1, + ui::PAGE_TRANSITION_TYPED); NavigationEntry* entry1 = controller().GetLastCommittedEntry(); SiteInstance* instance1 = contents()->GetSiteInstance(); @@ -1069,6 +1115,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { const GURL url2("http://www.google.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); EXPECT_TRUE(contents()->CrossProcessNavigationPending()); TestRenderFrameHost* google_rfh = contents()->GetPendingMainFrame(); @@ -1078,8 +1125,8 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { ntp_rfh->PrepareForCommit(); // DidNavigate from the pending page. - contents()->TestDidNavigate( - google_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(google_rfh, 1, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); NavigationEntry* entry2 = controller().GetLastCommittedEntry(); SiteInstance* instance2 = contents()->GetSiteInstance(); @@ -1097,10 +1144,11 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { const GURL url3("http://news.google.com"); controller().LoadURL( url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate( - google_rfh, 2, url3, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(google_rfh, 2, entry_id, true, url3, + ui::PAGE_TRANSITION_TYPED); NavigationEntry* entry3 = controller().GetLastCommittedEntry(); SiteInstance* instance3 = contents()->GetSiteInstance(); @@ -1114,6 +1162,7 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { // Go back within the site. controller().GoBack(); + NavigationEntry* goback_entry = controller().GetPendingEntry(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(entry2, controller().GetPendingEntry()); @@ -1131,7 +1180,8 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationBackPreempted) { FrameHostMsg_BeforeUnload_ACK(0, true, now, now)); // DidNavigate from the first back. This aborts the second back's pending RFH. - contents()->TestDidNavigate(google_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(google_rfh, 1, goback_entry->GetUniqueID(), false, + url2, ui::PAGE_TRANSITION_TYPED); // We should commit this page and forget about the second back. EXPECT_FALSE(contents()->CrossProcessNavigationPending()); @@ -1158,8 +1208,10 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); @@ -1171,8 +1223,9 @@ TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) { // Simulate a sub-frame navigation arriving and ensure the RVH is still // waiting for a before unload response. TestRenderFrameHost* child_rfh = orig_rfh->AppendChild("subframe"); - child_rfh->SendNavigateWithTransition( - 1, GURL("http://google.com/frame"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); + child_rfh->SendNavigateWithTransition(1, 0, false, + GURL("http://google.com/frame"), + ui::PAGE_TRANSITION_AUTO_SUBFRAME); EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); // Now simulate the onbeforeunload approval and verify the navigation is @@ -1191,6 +1244,7 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) { const GURL url("chrome://blah"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry1_id = controller().GetPendingEntry()->GetUniqueID(); TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); @@ -1198,6 +1252,7 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) { const GURL url2("http://www.yahoo.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry2_id = controller().GetPendingEntry()->GetUniqueID(); TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); EXPECT_TRUE(contents()->CrossProcessNavigationPending()); EXPECT_TRUE(orig_rfh->IsWaitingForBeforeUnloadACK()); @@ -1205,13 +1260,14 @@ TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) { // Suppose the first navigation tries to commit now, with a // FrameMsg_Stop in flight. This should not cancel the pending navigation, // but it should act as if the beforeunload ack arrived. - orig_rfh->SendNavigate(1, GURL("chrome://blah")); + orig_rfh->SendNavigate(1, entry1_id, true, GURL("chrome://blah")); EXPECT_TRUE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); EXPECT_FALSE(orig_rfh->IsWaitingForBeforeUnloadACK()); // The pending navigation should be able to commit successfully. - contents()->TestDidNavigate(pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(pending_rfh, 1, entry2_id, true, url2, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(pending_rfh, contents()->GetMainFrame()); } @@ -1225,12 +1281,14 @@ TEST_F(WebContentsImplTest, NavigationEntryContentState) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); NavigationEntry* entry = controller().GetLastCommittedEntry(); EXPECT_EQ(nullptr, entry); // Committed entry should have page state after DidNavigate. orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); entry = controller().GetLastCommittedEntry(); EXPECT_TRUE(entry->GetPageState().IsValid()); @@ -1238,19 +1296,23 @@ TEST_F(WebContentsImplTest, NavigationEntryContentState) { const GURL url2("http://images.google.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); entry = controller().GetLastCommittedEntry(); EXPECT_TRUE(entry->GetPageState().IsValid()); // Committed entry should have page state after DidNavigate. orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 2, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); entry = controller().GetLastCommittedEntry(); EXPECT_TRUE(entry->GetPageState().IsValid()); // Now go back. Committed entry should still have page state. controller().GoBack(); + entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, false, url, + ui::PAGE_TRANSITION_TYPED); entry = controller().GetLastCommittedEntry(); EXPECT_TRUE(entry->GetPageState().IsValid()); } @@ -1261,15 +1323,12 @@ TEST_F(WebContentsImplTest, NavigationEntryContentState) { TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) { TestRenderFrameHost* orig_rfh = contents()->GetMainFrame(); - // When opening a new window, it is navigated to about:blank internally. - // Currently, this results in two DidNavigate events. + // Navigate to about:blank. const GURL url(url::kAboutBlankURL); orig_rfh->SendRendererInitiatedNavigationRequest(url, false); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); - orig_rfh->SendRendererInitiatedNavigationRequest(url, false); - orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, 0, true, url, + ui::PAGE_TRANSITION_TYPED); // Should have a page state here. NavigationEntry* entry = controller().GetLastCommittedEntry(); @@ -1285,10 +1344,12 @@ TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) { const GURL new_url("http://www.google.com"); controller().LoadURL(new_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry = controller().GetPendingEntry(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, new_url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 2, entry->GetUniqueID(), true, new_url, + ui::PAGE_TRANSITION_TYPED); NavigationEntryImpl* entry_impl2 = NavigationEntryImpl::FromNavigationEntry( controller().GetLastCommittedEntry()); EXPECT_EQ(site_instance_id, entry_impl2->site_instance()->GetId()); @@ -1307,8 +1368,10 @@ TEST_F(WebContentsImplTest, NavigationExitsFullscreen) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); // Toggle fullscreen mode on (as if initiated via IPC from renderer). @@ -1325,10 +1388,11 @@ TEST_F(WebContentsImplTest, NavigationExitsFullscreen) { const GURL url2("http://www.yahoo.com"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); contents()->GetMainFrame()->PrepareForCommit(); TestRenderFrameHost* const pending_rfh = contents()->GetPendingMainFrame(); - contents()->TestDidNavigate( - pending_rfh, 1, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(pending_rfh, 1, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); // Confirm fullscreen has exited. EXPECT_FALSE(orig_rvh->IsFullscreenGranted()); @@ -1350,17 +1414,21 @@ TEST_F(WebContentsImplTest, HistoryNavigationExitsFullscreen) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); - contents()->TestDidNavigate(orig_rfh, 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, url, + ui::PAGE_TRANSITION_TYPED); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); // Now, navigate to another page on the same site. const GURL url2("http://www.google.com/search?q=kittens"); controller().LoadURL( url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); - contents()->TestDidNavigate(orig_rfh, 2, url2, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 2, entry_id, true, url2, + ui::PAGE_TRANSITION_TYPED); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); // Sanity-check: Confirm we're not starting out in fullscreen mode. @@ -1381,11 +1449,12 @@ TEST_F(WebContentsImplTest, HistoryNavigationExitsFullscreen) { controller().GoBack(); else controller().GoForward(); + entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); - contents()->TestDidNavigate( - orig_rfh, i + 1, url, ui::PAGE_TRANSITION_FORWARD_BACK); + contents()->TestDidNavigate(orig_rfh, i + 1, entry_id, false, url, + ui::PAGE_TRANSITION_FORWARD_BACK); // Confirm fullscreen has exited. EXPECT_FALSE(orig_rvh->IsFullscreenGranted()); @@ -1420,9 +1489,10 @@ TEST_F(WebContentsImplTest, CrashExitsFullscreen) { const GURL url("http://www.google.com"); controller().LoadURL( url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); main_test_rfh()->PrepareForCommit(); - contents()->TestDidNavigate( - contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(contents()->GetMainFrame(), 1, entry_id, true, + url, ui::PAGE_TRANSITION_TYPED); // Toggle fullscreen mode on (as if initiated via IPC from renderer). EXPECT_FALSE(test_rvh()->IsFullscreenGranted()); @@ -1456,12 +1526,13 @@ TEST_F(WebContentsImplTest, ShowInterstitialFromBrowserWithNewNavigationDontProceed) { // Navigate to a page. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); - // Initiate a browser navigation that will trigger the interstitial + // Initiate a browser navigation that will trigger the interstitial. controller().LoadURL(GURL("http://www.evil.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + NavigationEntry* entry = controller().GetPendingEntry(); // Show an interstitial. TestInterstitialPage::InterstitialState state = @@ -1472,16 +1543,17 @@ TEST_F(WebContentsImplTest, new TestInterstitialPage(contents(), true, url2, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // The interstitial should not show until its navigation has committed. EXPECT_FALSE(interstitial->is_showing()); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); // Let's commit the interstitial navigation. - interstitial->TestDidNavigate(1, url2); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_TRUE(contents()->ShowingInterstitialPage()); EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); - NavigationEntry* entry = controller().GetVisibleEntry(); + entry = controller().GetVisibleEntry(); ASSERT_NE(nullptr, entry); EXPECT_TRUE(entry->GetURL() == url2); @@ -1503,10 +1575,10 @@ TEST_F(WebContentsImplTest, // as when clicking on a link in the page) that shows an interstitial and // creates a new navigation entry, then hiding it without proceeding. TEST_F(WebContentsImplTest, - ShowInterstitiaFromRendererlWithNewNavigationDontProceed) { + ShowInterstitialFromRendererWithNewNavigationDontProceed) { // Navigate to a page. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial (no pending entry, the interstitial would have been @@ -1519,12 +1591,13 @@ TEST_F(WebContentsImplTest, new TestInterstitialPage(contents(), true, url2, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // The interstitial should not show until its navigation has committed. EXPECT_FALSE(interstitial->is_showing()); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); // Let's commit the interstitial navigation. - interstitial->TestDidNavigate(1, url2); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_TRUE(contents()->ShowingInterstitialPage()); EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); @@ -1552,7 +1625,7 @@ TEST_F(WebContentsImplTest, TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationDontProceed) { // Navigate to a page. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial. @@ -1569,7 +1642,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationDontProceed) { EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); // Let's commit the interstitial navigation. - interstitial->TestDidNavigate(1, url2); + interstitial->TestDidNavigate(1, 0, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_TRUE(contents()->ShowingInterstitialPage()); EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); @@ -1599,7 +1672,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialFromBrowserNewNavigationProceed) { // Navigate to a page. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Initiate a browser navigation that will trigger the interstitial @@ -1615,12 +1688,13 @@ TEST_F(WebContentsImplTest, new TestInterstitialPage(contents(), true, url2, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // The interstitial should not show until its navigation has committed. EXPECT_FALSE(interstitial->is_showing()); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); // Let's commit the interstitial navigation. - interstitial->TestDidNavigate(1, url2); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_TRUE(contents()->ShowingInterstitialPage()); EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); @@ -1640,7 +1714,7 @@ TEST_F(WebContentsImplTest, // Simulate the navigation to the page, that's when the interstitial gets // hidden. GURL url3("http://www.thepage.com"); - contents()->GetMainFrame()->SendNavigate(2, url3); + contents()->GetMainFrame()->SendNavigate(2, 0, true, url3); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); @@ -1661,7 +1735,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialFromRendererNewNavigationProceed) { // Navigate to a page. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial. @@ -1673,12 +1747,13 @@ TEST_F(WebContentsImplTest, new TestInterstitialPage(contents(), true, url2, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // The interstitial should not show until its navigation has committed. EXPECT_FALSE(interstitial->is_showing()); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); // Let's commit the interstitial navigation. - interstitial->TestDidNavigate(1, url2); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_TRUE(contents()->ShowingInterstitialPage()); EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); @@ -1698,7 +1773,7 @@ TEST_F(WebContentsImplTest, // Simulate the navigation to the page, that's when the interstitial gets // hidden. GURL url3("http://www.thepage.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(2, url3); + main_test_rfh()->NavigateAndCommitRendererInitiated(2, true, url3); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); @@ -1718,7 +1793,7 @@ TEST_F(WebContentsImplTest, TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationProceed) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial. @@ -1735,7 +1810,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialNoNewNavigationProceed) { EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); // Let's commit the interstitial navigation. - interstitial->TestDidNavigate(1, url2); + interstitial->TestDidNavigate(1, 0, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_TRUE(contents()->ShowingInterstitialPage()); EXPECT_TRUE(contents()->GetInterstitialPage() == interstitial); @@ -1772,11 +1847,12 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenNavigate) { new TestInterstitialPage(contents(), true, url, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, url); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url); // While interstitial showing, navigate to a new URL. const GURL url2("http://www.yahoo.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url2); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url2); EXPECT_EQ(TestInterstitialPage::CANCELED, state); @@ -1788,8 +1864,9 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenNavigate) { TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); + NavigationEntry* entry = controller().GetLastCommittedEntry(); // Show interstitial. TestInterstitialPage::InterstitialState state = @@ -1801,17 +1878,20 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(2, interstitial_url); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(2, interstitial_entry_id, true, + interstitial_url); // While the interstitial is showing, go back. controller().GoBack(); main_test_rfh()->PrepareForCommit(); - contents()->GetMainFrame()->SendNavigate(1, url1); + contents()->GetMainFrame()->SendNavigate(1, entry->GetUniqueID(), false, + url1); // Make sure we are back to the original page and that the interstitial is // gone. EXPECT_EQ(TestInterstitialPage::CANCELED, state); - NavigationEntry* entry = controller().GetVisibleEntry(); + entry = controller().GetVisibleEntry(); ASSERT_TRUE(entry); EXPECT_EQ(url1.spec(), entry->GetURL().spec()); @@ -1824,8 +1904,9 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenGoBack) { TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); + NavigationEntry* entry = controller().GetLastCommittedEntry(); // Show interstitial. TestInterstitialPage::InterstitialState state = @@ -1837,7 +1918,9 @@ TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(2, interstitial_url); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(2, interstitial_entry_id, true, + interstitial_url); // Crash the renderer contents()->GetMainFrame()->GetProcess()->SimulateCrash(); @@ -1845,12 +1928,13 @@ TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { // While the interstitial is showing, go back. controller().GoBack(); main_test_rfh()->PrepareForCommit(); - contents()->GetMainFrame()->SendNavigate(1, url1); + contents()->GetMainFrame()->SendNavigate(1, entry->GetUniqueID(), false, + url1); // Make sure we are back to the original page and that the interstitial is // gone. EXPECT_EQ(TestInterstitialPage::CANCELED, state); - NavigationEntry* entry = controller().GetVisibleEntry(); + entry = controller().GetVisibleEntry(); ASSERT_TRUE(entry); EXPECT_EQ(url1.spec(), entry->GetURL().spec()); @@ -1863,7 +1947,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenGoBack) { TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenNavigate) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Show interstitial. @@ -1876,11 +1960,13 @@ TEST_F(WebContentsImplTest, ShowInterstitialCrashRendererThenNavigate) { &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // Crash the renderer contents()->GetMainFrame()->GetProcess()->SimulateCrash(); - interstitial->TestDidNavigate(2, interstitial_url); + interstitial->TestDidNavigate(2, interstitial_entry_id, true, + interstitial_url); } // Test navigating to a page that shows an interstitial, then close the @@ -1895,7 +1981,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenCloseTab) { new TestInterstitialPage(contents(), true, url, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, url); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url); // Now close the contents. DeleteContents(); @@ -1917,7 +2004,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenCloseAndShutdown) { new TestInterstitialPage(contents(), true, url, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, url); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url); TestRenderFrameHost* rfh = static_cast<TestRenderFrameHost*>(interstitial->GetMainFrame()); @@ -1939,7 +2027,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialThenCloseAndShutdown) { TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { // Navigate to a page so we have a navigation entry in the controller. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial. @@ -1951,7 +2039,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { new TestInterstitialPage(contents(), true, url2, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, url2); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); // Run a command. EXPECT_EQ(0, interstitial->command_received_count()); @@ -1974,7 +2063,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialProceedMultipleCommands) { TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { // Navigate to a page so we have a navigation entry in the controller. GURL start_url("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, start_url); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, start_url); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial. @@ -1986,7 +2075,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); TestInterstitialPageStateGuard state_guard1(interstitial1); interstitial1->Show(); - interstitial1->TestDidNavigate(1, url1); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial1->TestDidNavigate(1, interstitial_entry_id, true, url1); // Now show another interstitial. TestInterstitialPage::InterstitialState state2 = @@ -1997,7 +2087,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); TestInterstitialPageStateGuard state_guard2(interstitial2); interstitial2->Show(); - interstitial2->TestDidNavigate(1, url2); + interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial2->TestDidNavigate(1, interstitial_entry_id, true, url2); // Showing interstitial2 should have caused interstitial1 to go away. EXPECT_EQ(TestInterstitialPage::CANCELED, state1); @@ -2010,7 +2101,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { // Let's make sure interstitial2 is working as intended. interstitial2->Proceed(); GURL landing_url("http://www.thepage.com"); - contents()->GetMainFrame()->SendNavigate(2, landing_url); + contents()->GetMainFrame()->SendNavigate(2, 0, true, landing_url); EXPECT_FALSE(contents()->ShowingInterstitialPage()); EXPECT_EQ(nullptr, contents()->GetInterstitialPage()); @@ -2027,7 +2118,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialOnInterstitial) { TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { // Navigate to a page so we have a navigation entry in the controller. GURL start_url("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, start_url); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, start_url); EXPECT_EQ(1, controller().GetEntryCount()); // Show an interstitial. @@ -2039,7 +2130,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { new TestInterstitialPage(contents(), true, url1, &state1, &deleted1); TestInterstitialPageStateGuard state_guard1(interstitial1); interstitial1->Show(); - interstitial1->TestDidNavigate(1, url1); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial1->TestDidNavigate(1, interstitial_entry_id, true, url1); // Take action. The interstitial won't be hidden until the navigation is // committed. @@ -2056,7 +2148,8 @@ TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { new TestInterstitialPage(contents(), true, url2, &state2, &deleted2); TestInterstitialPageStateGuard state_guard2(interstitial2); interstitial2->Show(); - interstitial2->TestDidNavigate(1, url2); + interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial2->TestDidNavigate(1, interstitial_entry_id, true, url2); // Showing interstitial2 should have caused interstitial1 to go away. EXPECT_EQ(TestInterstitialPage::UNDECIDED, state2); @@ -2067,7 +2160,7 @@ TEST_F(WebContentsImplTest, ShowInterstitialProceedShowInterstitial) { // Let's make sure interstitial2 is working as intended. interstitial2->Proceed(); GURL landing_url("http://www.thepage.com"); - contents()->GetMainFrame()->SendNavigate(2, landing_url); + contents()->GetMainFrame()->SendNavigate(2, 0, true, landing_url); RunAllPendingInMessageLoop(); EXPECT_TRUE(deleted2); @@ -2092,6 +2185,7 @@ TEST_F(WebContentsImplTest, NavigateBeforeInterstitialShows) { &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // Let's simulate a navigation initiated from the browser before the // interstitial finishes loading. @@ -2103,7 +2197,8 @@ TEST_F(WebContentsImplTest, NavigateBeforeInterstitialShows) { ASSERT_FALSE(deleted); // Now let's make the interstitial navigation commit. - interstitial->TestDidNavigate(1, interstitial_url); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, + interstitial_url); // After it loaded the interstitial should be gone. EXPECT_EQ(TestInterstitialPage::CANCELED, state); @@ -2137,6 +2232,7 @@ TEST_F(WebContentsImplTest, TwoQuickInterstitials) { &state2, &deleted2); TestInterstitialPageStateGuard state_guard2(interstitial2); interstitial2->Show(); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); // The first interstitial should have been closed and deleted. EXPECT_EQ(TestInterstitialPage::CANCELED, state1); @@ -2148,7 +2244,8 @@ TEST_F(WebContentsImplTest, TwoQuickInterstitials) { ASSERT_FALSE(deleted2); // Make the interstitial navigation commit it should be showing. - interstitial2->TestDidNavigate(1, interstitial_url); + interstitial2->TestDidNavigate(1, interstitial_entry_id, true, + interstitial_url); EXPECT_EQ(interstitial2, contents()->GetInterstitialPage()); } @@ -2175,7 +2272,8 @@ TEST_F(WebContentsImplTest, InterstitialCrasher) { interstitial = new TestInterstitialPage(contents(), true, url, &state, &deleted); interstitial->Show(); - interstitial->TestDidNavigate(1, url); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url); // Simulate a renderer crash. interstitial->TestRenderViewTerminated( base::TERMINATION_STATUS_PROCESS_CRASHED, -1); @@ -2204,7 +2302,8 @@ TEST_F(WebContentsImplTest, NewInterstitialDoesNotCancelPendingEntry) { new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, kGURL); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, kGURL); // Initiate a new navigation from the browser that also triggers an // interstitial. @@ -2217,7 +2316,8 @@ TEST_F(WebContentsImplTest, NewInterstitialDoesNotCancelPendingEntry) { new TestInterstitialPage(contents(), true, kGURL, &state2, &deleted2); TestInterstitialPageStateGuard state_guard2(interstitial2); interstitial2->Show(); - interstitial2->TestDidNavigate(1, kGURL); + interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial2->TestDidNavigate(1, interstitial_entry_id, true, kGURL); // Make sure we still have an entry. NavigationEntry* entry = contents()->GetController().GetPendingEntry(); @@ -2241,10 +2341,11 @@ TEST_F(WebContentsImplTest, NoJSMessageOnInterstitials) { // Start a navigation to a page contents()->GetController().LoadURL( kGURL, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); main_test_rfh()->PrepareForCommit(); // DidNavigate from the page - contents()->TestDidNavigate( - contents()->GetMainFrame(), 1, kGURL, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(contents()->GetMainFrame(), 1, entry_id, true, + kGURL, ui::PAGE_TRANSITION_TYPED); // Simulate showing an interstitial while the page is showing. TestInterstitialPage::InterstitialState state = @@ -2254,7 +2355,8 @@ TEST_F(WebContentsImplTest, NoJSMessageOnInterstitials) { new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, kGURL); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, kGURL); // While the interstitial is showing, let's simulate the hidden page // attempting to show a JS message. @@ -2271,7 +2373,7 @@ TEST_F(WebContentsImplTest, NoJSMessageOnInterstitials) { TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { // Navigate to a page. GURL url1("http://www.google.com"); - main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1); + main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1); EXPECT_EQ(1, controller().GetEntryCount()); // Initiate a browser navigation that will trigger the interstitial @@ -2287,7 +2389,8 @@ TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { new TestInterstitialPage(contents(), true, url2, &state, &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, url2); + int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url2); EXPECT_TRUE(interstitial->is_showing()); EXPECT_EQ(2, controller().GetEntryCount()); @@ -2336,7 +2439,9 @@ TEST_F(WebContentsImplTest, CopyStateFromAndPruneTargetInterstitial) { &deleted); TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); - interstitial->TestDidNavigate(1, url3); + int interstitial_entry_id = + other_controller.GetTransientEntry()->GetUniqueID(); + interstitial->TestDidNavigate(1, interstitial_entry_id, true, url3); EXPECT_TRUE(interstitial->is_showing()); EXPECT_EQ(2, other_controller.GetEntryCount()); @@ -2670,13 +2775,14 @@ TEST_F(WebContentsImplTest, ActiveContentsCountNavigate) { Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = contents->GetController().GetPendingEntry()->GetUniqueID(); if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableBrowserSideNavigation)) { contents->GetMainFrame()->PrepareForCommit(); } EXPECT_TRUE(contents->CrossProcessNavigationPending()); EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); - contents->GetPendingMainFrame()->SendNavigate(1, kUrl); + contents->GetPendingMainFrame()->SendNavigate(1, entry_id, true, kUrl); EXPECT_EQ(1u, instance->GetRelatedActiveContentsCount()); contents.reset(); @@ -2705,6 +2811,7 @@ TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) { Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = contents->GetController().GetPendingEntry()->GetUniqueID(); contents->GetMainFrame()->PrepareForCommit(); EXPECT_TRUE(contents->CrossProcessNavigationPending()); scoped_refptr<SiteInstance> instance_webui( @@ -2716,7 +2823,7 @@ TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) { EXPECT_EQ(0u, instance_webui->GetRelatedActiveContentsCount()); // Commit and contents counts for the new one. - contents->GetPendingMainFrame()->SendNavigate(1, kWebUIUrl); + contents->GetPendingMainFrame()->SendNavigate(1, entry_id, true, kWebUIUrl); EXPECT_EQ(0u, instance->GetRelatedActiveContentsCount()); EXPECT_EQ(1u, instance_webui->GetRelatedActiveContentsCount()); @@ -2772,10 +2879,12 @@ TEST_F(WebContentsImplTest, StartStopEventsBalance) { // The frame should still be loading. controller().LoadURL( main_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); orig_rfh->PrepareForCommit(); orig_rfh->OnMessageReceived( FrameHostMsg_DidStartLoading(orig_rfh->GetRoutingID(), false)); - contents()->TestDidNavigate(orig_rfh, 1, main_url, ui::PAGE_TRANSITION_TYPED); + contents()->TestDidNavigate(orig_rfh, 1, entry_id, true, main_url, + ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->CrossProcessNavigationPending()); EXPECT_EQ(orig_rfh, contents()->GetMainFrame()); EXPECT_TRUE(contents()->IsLoading()); @@ -2791,7 +2900,7 @@ TEST_F(WebContentsImplTest, StartStopEventsBalance) { subframe->PrepareForCommit(); subframe->OnMessageReceived( FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); - subframe->SendNavigateWithTransition(1, initial_url, + subframe->SendNavigateWithTransition(1, 0, false, initial_url, ui::PAGE_TRANSITION_AUTO_SUBFRAME); subframe->OnMessageReceived( FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); @@ -2804,8 +2913,8 @@ TEST_F(WebContentsImplTest, StartStopEventsBalance) { subframe->PrepareForCommit(); subframe->OnMessageReceived( FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); - subframe->SendNavigateWithTransition( - 1, foo_url, ui::PAGE_TRANSITION_AUTO_SUBFRAME); + subframe->SendNavigateWithTransition(1, 0, false, foo_url, + ui::PAGE_TRANSITION_AUTO_SUBFRAME); subframe->OnMessageReceived( FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); } @@ -2830,6 +2939,7 @@ TEST_F(WebContentsImplTest, StartStopEventsBalance) { load_params.frame_tree_node_id = subframe->frame_tree_node()->frame_tree_node_id(); controller().LoadURLWithParams(load_params); + entry_id = controller().GetPendingEntry()->GetUniqueID(); subframe->OnMessageReceived( FrameHostMsg_DidStartLoading(subframe->GetRoutingID(), true)); @@ -2837,8 +2947,8 @@ TEST_F(WebContentsImplTest, StartStopEventsBalance) { // Commit the navigation in the child frame and send the DidStopLoading // message. subframe->PrepareForCommit(); - contents()->TestDidNavigate( - subframe, 3, bar_url, ui::PAGE_TRANSITION_MANUAL_SUBFRAME); + contents()->TestDidNavigate(subframe, 3, entry_id, true, bar_url, + ui::PAGE_TRANSITION_MANUAL_SUBFRAME); subframe->OnMessageReceived( FrameHostMsg_DidStopLoading(subframe->GetRoutingID())); } @@ -2874,6 +2984,7 @@ TEST_F(WebContentsImplTest, NoEarlyStop) { // be a pending RenderFrameHost and the WebContents should be loading. controller().LoadURL( kUrl2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); + int entry_id = controller().GetPendingEntry()->GetUniqueID(); EXPECT_TRUE(contents()->CrossProcessNavigationPending()); TestRenderFrameHost* pending_rfh = contents()->GetPendingMainFrame(); ASSERT_TRUE(pending_rfh); @@ -2897,7 +3008,7 @@ TEST_F(WebContentsImplTest, NoEarlyStop) { // Simulate the commit and DidStopLoading from the renderer-initiated // navigation in the current RenderFrameHost. There should still be a pending // RenderFrameHost and the WebContents should still be loading. - current_rfh->SendNavigate(1, kUrl3); + current_rfh->SendNavigate(1, 0, true, kUrl3); current_rfh->OnMessageReceived( FrameHostMsg_DidStopLoading(current_rfh->GetRoutingID())); EXPECT_EQ(contents()->GetPendingMainFrame(), pending_rfh); @@ -2905,7 +3016,7 @@ TEST_F(WebContentsImplTest, NoEarlyStop) { // Commit the navigation. The formerly pending RenderFrameHost should now be // the current RenderFrameHost and the WebContents should still be loading. - contents()->TestDidNavigate(pending_rfh, 1, kUrl2, + contents()->TestDidNavigate(pending_rfh, 1, entry_id, true, kUrl2, ui::PAGE_TRANSITION_TYPED); EXPECT_FALSE(contents()->GetPendingMainFrame()); TestRenderFrameHost* new_current_rfh = contents()->GetMainFrame(); |