summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/devtools/devtools_manager_unittest.cc10
-rw-r--r--content/browser/frame_host/navigation_controller_impl.cc131
-rw-r--r--content/browser/frame_host/navigation_controller_impl.h9
-rw-r--r--content/browser/frame_host/navigation_controller_impl_browsertest.cc92
-rw-r--r--content/browser/frame_host/navigation_controller_impl_unittest.cc425
-rw-r--r--content/browser/frame_host/navigation_entry_impl.cc6
-rw-r--r--content/browser/frame_host/navigation_entry_impl.h1
-rw-r--r--content/browser/frame_host/navigation_request.cc4
-rw-r--r--content/browser/frame_host/navigator_impl.cc4
-rw-r--r--content/browser/frame_host/navigator_impl_unittest.cc63
-rw-r--r--content/browser/frame_host/render_frame_host_manager_unittest.cc54
-rw-r--r--content/browser/renderer_host/render_view_host_unittest.cc8
-rw-r--r--content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc9
-rw-r--r--content/browser/web_contents/web_contents_impl_unittest.cc383
14 files changed, 867 insertions, 332 deletions
diff --git a/content/browser/devtools/devtools_manager_unittest.cc b/content/browser/devtools/devtools_manager_unittest.cc
index 5231d5e..7dcb3a7 100644
--- a/content/browser/devtools/devtools_manager_unittest.cc
+++ b/content/browser/devtools/devtools_manager_unittest.cc
@@ -251,9 +251,10 @@ TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) {
const GURL url("http://www.google.com");
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int pending_id = controller().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
- contents()->TestDidNavigate(
- contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED);
+ contents()->TestDidNavigate(contents()->GetMainFrame(), 1, pending_id, true,
+ url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
TestDevToolsClientHost client_host;
@@ -272,9 +273,10 @@ TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) {
// Interrupt pending navigation and navigate back to the original site.
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ pending_id = controller().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
- contents()->TestDidNavigate(
- contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED);
+ contents()->TestDidNavigate(contents()->GetMainFrame(), 1, pending_id, false,
+ url, ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(client_host.agent_host(),
DevToolsAgentHost::GetOrCreateFor(web_contents()).get());
diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc
index 8c9f033..1953f51 100644
--- a/content/browser/frame_host/navigation_controller_impl.cc
+++ b/content/browser/frame_host/navigation_controller_impl.cc
@@ -819,6 +819,13 @@ bool NavigationControllerImpl::RendererDidNavigate(
// Do navigation-type specific actions. These will make and commit an entry.
details->type = ClassifyNavigation(rfh, params);
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSitePerProcess)) {
+ // For site-per-process, both ClassifyNavigation methods get it wrong (see
+ // http://crbug.com/464014) so don't worry about a mismatch if that's the
+ // case.
+ DCHECK_EQ(details->type, ClassifyNavigationWithoutPageID(rfh, params));
+ }
// is_in_page must be computed before the entry gets committed.
details->is_in_page = AreURLsInPageNavigation(rfh->GetLastCommittedURL(),
@@ -1063,6 +1070,121 @@ NavigationType NavigationControllerImpl::ClassifyNavigation(
return NAVIGATION_TYPE_EXISTING_PAGE;
}
+NavigationType NavigationControllerImpl::ClassifyNavigationWithoutPageID(
+ RenderFrameHostImpl* rfh,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const {
+ if (params.did_create_new_entry) {
+ // A new entry. We may or may not have a pending entry for the page, and
+ // this may or may not be the main frame.
+ if (ui::PageTransitionIsMainFrame(params.transition)) {
+ // TODO(avi): I want to use |if (!rfh->GetParent())| here but lots of unit
+ // tests fake auto subframe commits by sending the main frame a
+ // PAGE_TRANSITION_AUTO_SUBFRAME transition. Fix those, and adjust here.
+ return NAVIGATION_TYPE_NEW_PAGE;
+ }
+
+ // When this is a new subframe navigation, we should have a committed page
+ // in which it's a subframe. This may not be the case when an iframe is
+ // navigated on a popup navigated to about:blank (the iframe would be
+ // written into the popup by script on the main page). For these cases,
+ // there isn't any navigation stuff we can do, so just ignore it.
+ if (!GetLastCommittedEntry())
+ return NAVIGATION_TYPE_NAV_IGNORE;
+
+ // Valid subframe navigation.
+ return NAVIGATION_TYPE_NEW_SUBFRAME;
+ }
+
+ // We only clear the session history when navigating to a new page.
+ DCHECK(!params.history_list_was_cleared);
+
+ if (!ui::PageTransitionIsMainFrame(params.transition)) {
+ // All manual subframes would be did_create_new_entry and handled above, so
+ // we know this is auto.
+ if (GetLastCommittedEntry()) {
+ return NAVIGATION_TYPE_AUTO_SUBFRAME;
+ } else {
+ // We ignore subframes created in non-committed pages; we'd appreciate if
+ // people stopped doing that.
+ return NAVIGATION_TYPE_NAV_IGNORE;
+ }
+ }
+
+ if (params.nav_entry_id == 0) {
+ // This is a renderer-initiated navigation (nav_entry_id == 0), but didn't
+ // create a new page.
+
+ // Just like above in the did_create_new_entry case, it's possible to
+ // scribble onto an uncommitted page. Again, there isn't any navigation
+ // stuff that we can do, so ignore it here as well.
+ if (!GetLastCommittedEntry())
+ return NAVIGATION_TYPE_NAV_IGNORE;
+
+ if (params.was_within_same_page) {
+ // This is history.replaceState(), which is renderer-initiated yet within
+ // the same page.
+ return NAVIGATION_TYPE_IN_PAGE;
+ } else {
+ // This is history.reload() or a client-side redirect.
+ return NAVIGATION_TYPE_EXISTING_PAGE;
+ }
+ }
+
+ if (pending_entry_ && pending_entry_index_ == -1 &&
+ pending_entry_->GetUniqueID() == params.nav_entry_id) {
+ // In this case, we have a pending entry for a load of a new URL but Blink
+ // didn't do a new navigation (params.did_create_new_entry). This happens
+ // when you press enter in the URL bar to reload. We will create a pending
+ // entry, but Blink will convert it to a reload since it's the same page and
+ // not create a new entry for it (the user doesn't want to have a new
+ // back/forward entry when they do this). Therefore we want to just ignore
+ // the pending entry and go back to where we were (the "existing entry").
+ return NAVIGATION_TYPE_SAME_PAGE;
+ }
+
+ if (params.intended_as_new_entry) {
+ // This was intended to be a navigation to a new entry but the pending entry
+ // got cleared in the meanwhile. Classify as EXISTING_PAGE because we may or
+ // may not have a pending entry.
+ return NAVIGATION_TYPE_EXISTING_PAGE;
+ }
+
+ if (params.url_is_unreachable && failed_pending_entry_id_ != 0 &&
+ params.nav_entry_id == failed_pending_entry_id_) {
+ // If the renderer was going to a new pending entry that got cleared because
+ // of an error, this is the case of the user trying to retry a failed load
+ // by pressing return. Classify as EXISTING_PAGE because we probably don't
+ // have a pending entry.
+ return NAVIGATION_TYPE_EXISTING_PAGE;
+ }
+
+ // Now we know that the notification is for an existing page. Find that entry.
+ int existing_entry_index = GetEntryIndexWithUniqueID(params.nav_entry_id);
+ if (existing_entry_index == -1) {
+ // The page was not found. It could have been pruned because of the limit on
+ // back/forward entries (not likely since we'll usually tell it to navigate
+ // to such entries). It could also mean that the renderer is smoking crack.
+ // TODO(avi): Crash the renderer like we do in the old ClassifyNavigation?
+ NOTREACHED() << "Could not find nav entry with id " << params.nav_entry_id;
+ return NAVIGATION_TYPE_NAV_IGNORE;
+ }
+
+ // Any top-level navigations with the same base (minus the reference fragment)
+ // are in-page navigations. (We weeded out subframe navigations above.) Most
+ // of the time this doesn't matter since Blink doesn't tell us about subframe
+ // navigations that don't actually navigate, but it can happen when there is
+ // an encoding override (it always sends a navigation request).
+ NavigationEntryImpl* existing_entry = entries_[existing_entry_index].get();
+ if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url,
+ params.was_within_same_page, rfh)) {
+ return NAVIGATION_TYPE_IN_PAGE;
+ }
+
+ // Since we weeded out "new" navigations above, we know this is an existing
+ // (back/forward) navigation.
+ return NAVIGATION_TYPE_EXISTING_PAGE;
+}
+
void NavigationControllerImpl::RendererDidNavigateToNewPage(
RenderFrameHostImpl* rfh,
const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
@@ -1824,6 +1946,15 @@ int NavigationControllerImpl::GetEntryIndexWithPageID(
return -1;
}
+int NavigationControllerImpl::GetEntryIndexWithUniqueID(
+ int nav_entry_id) const {
+ for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) {
+ if (entries_[i]->GetUniqueID() == nav_entry_id)
+ return i;
+ }
+ return -1;
+}
+
NavigationEntryImpl* NavigationControllerImpl::GetTransientEntry() const {
if (transient_entry_index_ == -1)
return NULL;
diff --git a/content/browser/frame_host/navigation_controller_impl.h b/content/browser/frame_host/navigation_controller_impl.h
index da3bbd3..85469401 100644
--- a/content/browser/frame_host/navigation_controller_impl.h
+++ b/content/browser/frame_host/navigation_controller_impl.h
@@ -107,6 +107,9 @@ class CONTENT_EXPORT NavigationControllerImpl
int GetEntryIndexWithPageID(SiteInstance* instance,
int32 page_id) const;
+ // Return the index of the entry with the given unique id, or -1 if not found.
+ int GetEntryIndexWithUniqueID(int nav_entry_id) const;
+
// Return the entry with the corresponding instance and page_id, or NULL if
// not found.
NavigationEntryImpl* GetEntryWithPageID(
@@ -231,6 +234,12 @@ class CONTENT_EXPORT NavigationControllerImpl
NavigationType ClassifyNavigation(
RenderFrameHostImpl* rfh,
const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const;
+ // This does the same as above (hopefully), but does so without any use of
+ // deprecated page id values. Once it bakes and is verified to behave the
+ // same, it will replace it. http://crbug.com/369661
+ NavigationType ClassifyNavigationWithoutPageID(
+ RenderFrameHostImpl* rfh,
+ const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const;
// Causes the controller to load the specified entry. The function assumes
// ownership of the pointer since it is put in the navigation list.
diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
index 7a89b26..01d1c34 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -1070,4 +1070,96 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
ResourceDispatcherHost::Get()->SetDelegate(nullptr);
}
+namespace {
+
+class FailureWatcher : public WebContentsObserver {
+ public:
+ // Observes failure for the specified |node|.
+ explicit FailureWatcher(FrameTreeNode* node)
+ : WebContentsObserver(
+ node->current_frame_host()->delegate()->GetAsWebContents()),
+ frame_tree_node_id_(node->frame_tree_node_id()),
+ message_loop_runner_(new MessageLoopRunner) {}
+
+ void Wait() {
+ message_loop_runner_->Run();
+ }
+
+ private:
+ void DidFailLoad(RenderFrameHost* render_frame_host,
+ const GURL& validated_url,
+ int error_code,
+ const base::string16& error_description) override {
+ RenderFrameHostImpl* rfh =
+ static_cast<RenderFrameHostImpl*>(render_frame_host);
+ if (rfh->frame_tree_node()->frame_tree_node_id() != frame_tree_node_id_)
+ return;
+
+ message_loop_runner_->Quit();
+ }
+
+ void DidFailProvisionalLoad(
+ RenderFrameHost* render_frame_host,
+ const GURL& validated_url,
+ int error_code,
+ const base::string16& error_description) override {
+ RenderFrameHostImpl* rfh =
+ static_cast<RenderFrameHostImpl*>(render_frame_host);
+ if (rfh->frame_tree_node()->frame_tree_node_id() != frame_tree_node_id_)
+ return;
+
+ message_loop_runner_->Quit();
+ }
+
+ // The id of the FrameTreeNode whose navigations to observe.
+ int frame_tree_node_id_;
+
+ // The MessageLoopRunner used to spin the message loop.
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+};
+
+} // namespace
+
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ StopCausesFailureDespiteJavaScriptURL) {
+ NavigationControllerImpl& controller =
+ static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ FrameTreeNode* root =
+ static_cast<WebContentsImpl*>(shell()->web_contents())->
+ GetFrameTree()->root();
+
+ // Start with a normal page.
+ GURL url1(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_1.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), url1));
+
+ // Have the user decide to go to a different page which is very slow.
+ StallDelegate stall_delegate;
+ ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate);
+ GURL url2(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_2.html"));
+ controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+
+ // That should be the pending entry.
+ NavigationEntryImpl* entry = controller.GetPendingEntry();
+ ASSERT_NE(nullptr, entry);
+ EXPECT_EQ(url2, entry->GetURL());
+
+ // Loading a JavaScript URL shouldn't affect the ability to stop.
+ {
+ FailureWatcher watcher(root);
+ GURL js("javascript:(function(){})()");
+ controller.LoadURL(js, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ // This LoadURL ends up purging the pending entry, which is why this is
+ // tricky.
+ EXPECT_EQ(nullptr, controller.GetPendingEntry());
+ shell()->web_contents()->Stop();
+ watcher.Wait();
+ }
+
+ ResourceDispatcherHost::Get()->SetDelegate(nullptr);
+}
+
} // namespace content
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index b44a1b0..4a27b9a 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -317,7 +317,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[0], true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, urls[0]);
+ main_test_rfh()->SendNavigate(0, 0, true, urls[0]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(urls[0], controller.GetVisibleEntry()->GetVirtualURL());
@@ -328,7 +328,7 @@ TEST_F(NavigationControllerTest, GoToOffset) {
for (int i = 1; i <= 4; ++i) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(urls[i], true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(i, urls[i]);
+ main_test_rfh()->SendNavigate(i, 0, true, urls[i]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(urls[i], controller.GetVisibleEntry()->GetVirtualURL());
@@ -360,11 +360,12 @@ TEST_F(NavigationControllerTest, GoToOffset) {
for (int test = 0; test < NUM_TESTS; ++test) {
int offset = test_offsets[test];
controller.GoToOffset(offset);
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
url_index += offset;
// Check that the GoToOffset will land on the expected page.
EXPECT_EQ(urls[url_index], controller.GetPendingEntry()->GetVirtualURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, urls[url_index]);
+ main_test_rfh()->SendNavigate(url_index, entry_id, false, urls[url_index]);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Check that we can go to any valid offset into the history.
@@ -386,6 +387,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
// Creating a pending notification should not have issued any of the
// notifications we're listening for.
EXPECT_EQ(0U, notifications.size());
@@ -409,7 +411,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -431,6 +433,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
// Load another...
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// The load should now be pending.
EXPECT_EQ(controller.GetEntryCount(), 1);
@@ -449,7 +452,7 @@ TEST_F(NavigationControllerTest, LoadURL) {
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
main_test_rfh()->PrepareForCommit();
- contents()->GetPendingMainFrame()->SendNavigate(1, url2);
+ contents()->GetPendingMainFrame()->SendNavigate(1, entry_id, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -489,20 +492,22 @@ TEST_F(NavigationControllerTest, LoadURLSameTime) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Load another...
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// Simulate the beforeunload ack for the cross-site transition, and then the
// commit.
main_test_rfh()->PrepareForCommit();
- contents()->GetPendingMainFrame()->SendNavigate(1, url2);
+ contents()->GetPendingMainFrame()->SendNavigate(1, entry_id, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -619,9 +624,10 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -631,9 +637,10 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -667,6 +674,8 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = controller.GetPendingEntry()->GetUniqueID();
+ params.did_create_new_entry = true;
params.url = url1;
params.transition = ui::PAGE_TRANSITION_TYPED;
params.is_post = true;
@@ -684,7 +693,8 @@ TEST_F(NavigationControllerTest, LoadURL_SamePage_DifferentMethod) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, controller.GetPendingEntry()->GetUniqueID(),
+ false, url1);
// We should not have produced a new session history entry.
ASSERT_EQ(controller.GetVisibleEntry(), entry);
@@ -705,9 +715,10 @@ TEST_F(NavigationControllerTest, LoadURL_Discarded) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -745,16 +756,17 @@ TEST_F(NavigationControllerTest, LoadURL_NoPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// Do a new navigation without making a pending one.
const GURL kNewURL("http://see");
- main_test_rfh()->NavigateAndCommitRendererInitiated(99, kNewURL);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(99, true, kNewURL);
- // There should no longer be any pending entry, and the third navigation we
+ // There should no longer be any pending entry, and the second navigation we
// just made should be committed.
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -776,8 +788,9 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
const GURL kExistingURL1("http://eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -794,7 +807,7 @@ TEST_F(NavigationControllerTest, LoadURL_NewPending) {
const GURL kNewURL("http://see");
main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true);
main_test_rfh()->PrepareForCommit();
- contents()->GetMainFrame()->SendNavigate(3, kNewURL);
+ contents()->GetMainFrame()->SendNavigate(3, 0, true, kNewURL);
// There should no longer be any pending entry, and the third navigation we
// just made should be committed.
@@ -817,16 +830,18 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kExistingURL2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -841,9 +856,9 @@ TEST_F(NavigationControllerTest, LoadURL_ExistingPending) {
const GURL kNewURL("http://foo/see");
main_test_rfh()->SendRendererInitiatedNavigationRequest(kNewURL, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, kNewURL);
+ main_test_rfh()->SendNavigate(3, 0, true, kNewURL);
- // There should no longer be any pending entry, and the third navigation we
+ // There should no longer be any pending entry, and the new navigation we
// just made should be committed.
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -864,10 +879,11 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kExistingURL1("http://privileged");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
// Pretend it has bindings so we can tell if we incorrectly copy it.
main_test_rfh()->GetRenderViewHost()->AllowBindings(2);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -875,9 +891,10 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kExistingURL2("http://foo/eh");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame();
- foo_rfh->SendNavigate(1, kExistingURL2);
+ foo_rfh->SendNavigate(1, entry_id, true, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -894,9 +911,9 @@ TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
const GURL kNewURL("http://foo/bee");
foo_rfh->SendRendererInitiatedNavigationRequest(kNewURL, true);
foo_rfh->PrepareForCommit();
- foo_rfh->SendNavigate(3, kNewURL);
+ foo_rfh->SendNavigate(3, 0, true, kNewURL);
- // There should no longer be any pending entry, and the third navigation we
+ // There should no longer be any pending entry, and the new navigation we
// just made should be committed.
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -918,21 +935,24 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
const GURL kExistingURL1("http://foo/eh");
controller.LoadURL(
kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, kExistingURL1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL kExistingURL2("http://foo/bee");
controller.LoadURL(
kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kExistingURL2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, kExistingURL2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// A back navigation comes in from the renderer...
controller.GoToOffset(-1);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// ...while the user tries to navigate to a new page...
const GURL kNewURL("http://foo/see");
@@ -944,7 +964,7 @@ TEST_F(NavigationControllerTest, LoadURL_BackPreemptsPending) {
// ...and the back navigation commits.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kExistingURL1);
+ main_test_rfh()->SendNavigate(0, entry_id, false, kExistingURL1);
// There should no longer be any pending entry, and the back navigation should
// be committed.
@@ -982,10 +1002,10 @@ TEST_F(NavigationControllerTest, LoadURL_IgnorePreemptsPending) {
EXPECT_EQ(1, delegate->navigation_state_change_count());
// Before that commits, a document.write and location.reload can cause the
- // renderer to send a FrameNavigate with page_id -1.
+ // renderer to send a FrameNavigate with page_id -1 and nav_entry_id 0.
main_test_rfh()->SendRendererInitiatedNavigationRequest(kExistingURL, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(-1, kExistingURL);
+ main_test_rfh()->SendNavigate(-1, 0, false, kExistingURL);
// This should clear the pending entry and notify of a navigation state
// change, so that we do not keep displaying kNewURL.
@@ -1061,8 +1081,9 @@ TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) {
const GURL kExistingURL("http://foo/eh");
controller.LoadURL(kExistingURL, content::Referrer(),
ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kExistingURL);
+ main_test_rfh()->SendNavigate(1, entry_id, true, kExistingURL);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1134,14 +1155,16 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
EXPECT_EQ(NavigationEntryImpl::kInvalidBindings,
controller.GetPendingEntry()->bindings());
+ int entry1_id = controller.GetPendingEntry()->GetUniqueID();
// Commit.
TestRenderFrameHost* orig_rfh = contents()->GetMainFrame();
orig_rfh->PrepareForCommit();
- orig_rfh->SendNavigate(0, url1);
+ orig_rfh->SendNavigate(0, entry1_id, true, url1);
EXPECT_EQ(controller.GetEntryCount(), 1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
+ entry1_id = controller.GetLastCommittedEntry()->GetUniqueID();
// Manually increase the number of active frames in the SiteInstance
// that orig_rfh belongs to, to prevent it from being destroyed when
@@ -1154,10 +1177,11 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// privileged url.
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
orig_rfh->PrepareForCommit();
TestRenderFrameHost* new_rfh = contents()->GetPendingMainFrame();
new_rfh->GetRenderViewHost()->AllowBindings(1);
- new_rfh->SendNavigate(1, url2);
+ new_rfh->SendNavigate(1, entry_id, true, url2);
// The second load should be committed, and bindings should be remembered.
EXPECT_EQ(controller.GetEntryCount(), 2);
@@ -1168,7 +1192,7 @@ TEST_F(NavigationControllerTest, LoadURL_WithBindings) {
// Going back, the first entry should still appear unprivileged.
controller.GoBack();
new_rfh->PrepareForCommit();
- orig_rfh->SendNavigate(0, url1);
+ orig_rfh->SendNavigate(0, entry1_id, false, url1);
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(0, controller.GetLastCommittedEntry()->bindings());
}
@@ -1182,13 +1206,16 @@ TEST_F(NavigationControllerTest, Reload) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
ASSERT_TRUE(controller.GetVisibleEntry());
controller.GetVisibleEntry()->SetTitle(base::ASCIIToUTF16("Title"));
+ entry_id = controller.GetLastCommittedEntry()->GetUniqueID();
+
controller.Reload(true);
EXPECT_EQ(0U, notifications.size());
@@ -1209,7 +1236,7 @@ TEST_F(NavigationControllerTest, Reload) {
EXPECT_TRUE(controller.GetVisibleEntry()->GetTitle().empty());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1238,16 +1265,18 @@ TEST_F(NavigationControllerTest, Reload_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
+ entry_id = controller.GetLastCommittedEntry()->GetUniqueID();
controller.Reload(true);
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1270,8 +1299,9 @@ TEST_F(NavigationControllerTest, ReloadWithGuest) {
const GURL url1("http://foo1");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
ASSERT_TRUE(controller.GetVisibleEntry());
// Make the entry believe its RenderProcessHost is a guest.
@@ -1304,12 +1334,14 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
// Load up the original URL, but get redirected.
controller.LoadURL(
original_url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
- main_test_rfh()->SendNavigateWithOriginalRequestURL(
- 0, final_url, original_url);
+ main_test_rfh()->SendNavigateWithOriginalRequestURL(0, entry_id, true,
+ final_url, original_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
+ entry_id = controller.GetLastCommittedEntry()->GetUniqueID();
// The NavigationEntry should save both the original URL and the final
// redirected URL.
@@ -1339,7 +1371,7 @@ TEST_F(NavigationControllerTest, ReloadOriginalRequestURL) {
// Send that the navigation has proceeded; say it got redirected again.
main_test_rfh()->PrepareForCommitWithServerRedirect(final_url);
- main_test_rfh()->SendNavigate(0, final_url);
+ main_test_rfh()->SendNavigate(0, entry_id, false, final_url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1365,13 +1397,15 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
const GURL url0("http://foo/0");
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url0);
// Set up the pending entry.
const GURL url1("http://foo/1");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// Set up some sample values.
const unsigned char* raw_data =
@@ -1397,7 +1431,7 @@ TEST_F(NavigationControllerTest, ResetEntryValuesAfterCommit) {
// Fake a commit response.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url1);
// Certain values that are only used for pending entries get reset after
// commit.
@@ -1417,6 +1451,7 @@ TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
const GURL url2("http://foo2");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
// Set up some redirect values.
std::vector<GURL> redirects;
@@ -1430,7 +1465,8 @@ TEST_F(NavigationControllerTest, RedirectsAreNotResetByCommit) {
// Normal navigation will preserve redirects in the committed entry.
main_test_rfh()->PrepareForCommitWithServerRedirect(url2);
- main_test_rfh()->SendNavigateWithRedirects(0, url1, redirects);
+ main_test_rfh()->SendNavigateWithRedirects(0, entry_id, true, url1,
+ redirects);
NavigationEntryImpl* committed_entry = controller.GetLastCommittedEntry();
ASSERT_EQ(1U, committed_entry->GetRedirectChain().size());
EXPECT_EQ(url2, committed_entry->GetRedirectChain()[0]);
@@ -1443,16 +1479,17 @@ TEST_F(NavigationControllerTest, Back) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, url2);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
// We should now have a pending navigation to go back.
@@ -1465,14 +1502,14 @@ TEST_F(NavigationControllerTest, Back) {
EXPECT_FALSE(controller.CanGoToOffset(-1));
EXPECT_TRUE(controller.CanGoForward());
EXPECT_TRUE(controller.CanGoToOffset(1));
- EXPECT_FALSE(controller.CanGoToOffset(2)); // Cannot go foward 2 steps.
+ EXPECT_FALSE(controller.CanGoToOffset(2)); // Cannot go forward 2 steps.
// Timestamp for entry 1 should be on or after that of entry 0.
EXPECT_FALSE(controller.GetEntryAtIndex(0)->GetTimestamp().is_null());
EXPECT_GE(controller.GetEntryAtIndex(1)->GetTimestamp(),
controller.GetEntryAtIndex(0)->GetTimestamp());
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url2);
+ main_test_rfh()->SendNavigate(0, entry_id, false, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1506,15 +1543,18 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry1_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry1_id, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
+ entry1_id = controller.GetLastCommittedEntry()->GetUniqueID();
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1531,7 +1571,7 @@ TEST_F(NavigationControllerTest, Back_GeneratesNewPage) {
EXPECT_TRUE(controller.CanGoForward());
main_test_rfh()->PrepareForCommitWithServerRedirect(url3);
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry1_id, true, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1557,12 +1597,12 @@ TEST_F(NavigationControllerTest, Back_NewPending) {
const GURL kUrl3("http://foo3");
// First navigate two places so we have some back history.
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, kUrl1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, kUrl1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
// controller.LoadURL(kUrl2, ui::PAGE_TRANSITION_TYPED);
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, kUrl2);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, kUrl2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1590,19 +1630,20 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
// First navigate three places so we have some back history.
main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(0, 0, true, kUrl1);
main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl2, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kUrl2);
+ main_test_rfh()->SendNavigate(1, 0, true, kUrl2);
main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl3, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, kUrl3);
+ main_test_rfh()->SendNavigate(2, 0, true, kUrl3);
// With nothing pending, say we get a renderer back navigation request to the
// second entry.
controller.GoToOffset(-1);
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, kUrl2);
+ main_test_rfh()->SendNavigate(1, entry_id, false, kUrl2);
// We know all the entries have the same site instance, so we can just grab
// a random one for looking up other entries.
@@ -1617,8 +1658,9 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
// Now go forward to the last item again and say it was committed.
controller.GoForward();
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, kUrl3);
+ main_test_rfh()->SendNavigate(2, entry_id, false, kUrl3);
// Now start going back one to the second page. It will be pending.
controller.GoBack();
@@ -1628,8 +1670,9 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) {
// Now have the renderer request a navigation back to the first page. This
// will not match the pending one.
controller.GoToOffset(-2);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(0, entry_id, false, kUrl1);
// The committed navigation should clear the pending entry.
EXPECT_EQ(-1, controller.GetPendingEntryIndex());
@@ -1650,19 +1693,21 @@ TEST_F(NavigationControllerTest, Forward) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, 0, true, url2);
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
controller.GoBack();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry1->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1687,7 +1732,7 @@ TEST_F(NavigationControllerTest, Forward) {
controller.GetEntryAtIndex(1)->GetTimestamp());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry2->GetUniqueID(), false, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1721,18 +1766,20 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(url1, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, 0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
navigation_entry_committed_counter_ = 0;
main_test_rfh()->SendRendererInitiatedNavigationRequest(url2, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, 0, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
navigation_entry_committed_counter_ = 0;
controller.GoBack();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry1->GetUniqueID(), false, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1749,7 +1796,7 @@ TEST_F(NavigationControllerTest, Forward_GeneratesNewPage) {
EXPECT_FALSE(controller.CanGoForward());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry2->GetUniqueID(), true, url3);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_LIST_PRUNED));
@@ -1776,11 +1823,14 @@ TEST_F(NavigationControllerTest, Redirect) {
// First request.
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(0U, notifications.size());
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry_id;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT;
params.redirects.push_back(GURL("http://foo1"));
@@ -1800,10 +1850,15 @@ TEST_F(NavigationControllerTest, Redirect) {
// Second request.
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
+
+ params.nav_entry_id = entry_id;
+ params.did_create_new_entry = false;
+
EXPECT_EQ(0U, notifications.size());
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
&details));
@@ -1836,12 +1891,15 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
// First request as POST.
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
controller.GetVisibleEntry()->SetHasPostData(true);
EXPECT_EQ(0U, notifications.size());
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry_id;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT;
params.redirects.push_back(GURL("http://foo1"));
@@ -1861,11 +1919,14 @@ TEST_F(NavigationControllerTest, PostThenRedirect) {
// Second request.
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
+ params.nav_entry_id = entry_id;
+ params.did_create_new_entry = false;
params.is_post = false;
EXPECT_EQ(0U, notifications.size());
@@ -1899,6 +1960,7 @@ TEST_F(NavigationControllerTest, ImmediateRedirect) {
// First request
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
@@ -1906,6 +1968,8 @@ TEST_F(NavigationControllerTest, ImmediateRedirect) {
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry_id;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_SERVER_REDIRECT;
params.redirects.push_back(GURL("http://foo1"));
@@ -1943,13 +2007,15 @@ TEST_F(NavigationControllerTest, NewSubframe) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo1");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
const GURL url2("http://foo2");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
params.should_update_history = false;
@@ -1985,7 +2051,7 @@ TEST_F(NavigationControllerTest, AutoSubframe) {
RegisterForAllNavNotifications(&notifications, &controller);
const GURL url1("http://foo/1");
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -1998,6 +2064,8 @@ TEST_F(NavigationControllerTest, AutoSubframe) {
{
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
params.should_update_history = false;
@@ -2084,14 +2152,17 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Main page.
const GURL url1("http://foo1");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
navigation_entry_committed_counter_ = 0;
// First manual subframe navigation.
const GURL url2("http://foo2");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
params.should_update_history = false;
@@ -2103,6 +2174,7 @@ TEST_F(NavigationControllerTest, BackSubframe) {
LoadCommittedDetails details;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
&details));
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(2, controller.GetEntryCount());
@@ -2110,6 +2182,8 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Second manual subframe navigation should also make a new entry.
const GURL url3("http://foo3");
params.page_id = 2;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url3;
params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2122,6 +2196,8 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Go back one.
controller.GoBack();
params.page_id = 1;
+ params.nav_entry_id = entry2->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2136,6 +2212,8 @@ TEST_F(NavigationControllerTest, BackSubframe) {
// Go back one more.
controller.GoBack();
params.page_id = 0;
+ params.nav_entry_id = entry1->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url1;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2156,15 +2234,15 @@ TEST_F(NavigationControllerTest, LinkClick) {
const GURL url1("http://foo1");
const GURL url2("http://foo2");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, url2);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
- // Should not have produced a new session history entry.
+ // Should have produced a new session history entry.
EXPECT_EQ(controller.GetEntryCount(), 2);
EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 1);
EXPECT_EQ(controller.GetPendingEntryIndex(), -1);
@@ -2181,7 +2259,7 @@ TEST_F(NavigationControllerTest, InPage) {
// Main page.
const GURL url1("http://foo");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -2189,6 +2267,8 @@ TEST_F(NavigationControllerTest, InPage) {
// hint provided in the params.
FrameHostMsg_DidCommitProvisionalLoad_Params self_params;
self_params.page_id = 0;
+ self_params.nav_entry_id = 0;
+ self_params.did_create_new_entry = false;
self_params.url = url1;
self_params.transition = ui::PAGE_TRANSITION_LINK;
self_params.should_update_history = false;
@@ -2200,6 +2280,7 @@ TEST_F(NavigationControllerTest, InPage) {
LoadCommittedDetails details;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), self_params,
&details));
+ NavigationEntry* entry1 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(details.is_in_page);
@@ -2210,6 +2291,8 @@ TEST_F(NavigationControllerTest, InPage) {
const GURL url2("http://foo#a");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2221,6 +2304,7 @@ TEST_F(NavigationControllerTest, InPage) {
// This should generate a new entry.
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
&details));
+ NavigationEntry* entry2 = controller.GetLastCommittedEntry();
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(details.is_in_page);
@@ -2232,6 +2316,8 @@ TEST_F(NavigationControllerTest, InPage) {
controller.GoBack();
back_params.url = url1;
back_params.page_id = 0;
+ back_params.nav_entry_id = entry1->GetUniqueID();
+ back_params.did_create_new_entry = false;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), back_params,
&details));
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -2241,11 +2327,13 @@ TEST_F(NavigationControllerTest, InPage) {
EXPECT_EQ(0, controller.GetCurrentEntryIndex());
EXPECT_EQ(back_params.url, controller.GetVisibleEntry()->GetURL());
- // Go forward
+ // Go forward.
FrameHostMsg_DidCommitProvisionalLoad_Params forward_params(params);
controller.GoForward();
forward_params.url = url2;
forward_params.page_id = 1;
+ forward_params.nav_entry_id = entry2->GetUniqueID();
+ forward_params.did_create_new_entry = false;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), forward_params,
&details));
EXPECT_EQ(1U, navigation_entry_committed_counter_);
@@ -2272,6 +2360,8 @@ TEST_F(NavigationControllerTest, InPage) {
// Finally, navigate to an unrelated URL to make sure in_page is not sticky.
const GURL url3("http://bar");
params.page_id = 2;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url3;
navigation_entry_committed_counter_ = 0;
EXPECT_TRUE(controller.RendererDidNavigate(main_test_rfh(), params,
@@ -2290,7 +2380,7 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
// Main page.
const GURL url1("http://foo");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -2298,6 +2388,8 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
const GURL url2("http://foo#a");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0; // Same page_id
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url2;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2331,7 +2423,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Load an initial page.
{
const GURL url("http://foo/");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
}
@@ -2339,7 +2431,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
// Navigate to a new page.
{
const GURL url("http://foo2/");
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
}
@@ -2349,6 +2441,8 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
const GURL url("http://foo2/#a");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1; // Same page_id
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.redirects.push_back(url);
@@ -2374,6 +2468,8 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
const GURL url("http://foo3/");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 2; // New page_id
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT;
params.redirects.push_back(GURL("http://foo2/#a"));
@@ -2397,8 +2493,9 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
{
const GURL url("http://foo2/");
controller.GoBack();
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url);
+ main_test_rfh()->SendNavigate(1, entry_id, false, url);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL());
@@ -2411,6 +2508,8 @@ TEST_F(NavigationControllerTest, PushStateWithoutPreviousEntry)
FrameHostMsg_DidCommitProvisionalLoad_Params params;
GURL url("http://foo");
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.page_state = PageState::CreateFromURL(url);
params.was_within_same_page = true;
@@ -2465,8 +2564,9 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
GURL url(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, entry_id, true, url);
}
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
@@ -2478,8 +2578,9 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
GURL url(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, entry_id, true, url);
url_index++;
// We should have got a pruned navigation.
@@ -2490,20 +2591,21 @@ TEST_F(NavigationControllerTest, EnforceMaxNavigationCount) {
// We expect http://www.a.com/0 to be gone.
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(),
- GURL("http:////www.a.com/1"));
+ GURL("http://www.a.com/1"));
// More navigations.
for (int i = 0; i < 3; i++) {
- url = GURL(base::StringPrintf("http:////www.a.com/%d", url_index));
+ url = GURL(base::StringPrintf("http://www.a.com/%d", url_index));
controller.LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(url_index, url);
+ main_test_rfh()->SendNavigate(url_index, entry_id, true, url);
url_index++;
}
EXPECT_EQ(controller.GetEntryCount(), kMaxEntryCount);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(),
- GURL("http:////www.a.com/4"));
+ GURL("http://www.a.com/4"));
NavigationControllerImpl::set_max_entry_count_for_testing(original_count);
}
@@ -2557,6 +2659,8 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
// Say we navigated to that entry.
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = our_controller.GetPendingEntry()->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2605,6 +2709,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
// Before navigating to the restored entry, it should have a restore_type
// and no SiteInstance.
+ entry = our_controller.GetEntryAtIndex(0);
EXPECT_EQ(NavigationEntryImpl::RESTORE_LAST_SESSION_EXITED_CLEANLY,
our_controller.GetEntryAtIndex(0)->restore_type());
EXPECT_FALSE(our_controller.GetEntryAtIndex(0)->site_instance());
@@ -2634,6 +2739,8 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) {
// Now the pending restored entry commits.
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = entry->GetUniqueID();
+ params.did_create_new_entry = false;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.should_update_history = false;
@@ -2662,19 +2769,21 @@ TEST_F(NavigationControllerTest, Interstitial) {
const GURL url1("http://foo");
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
// Now navigate somewhere with an interstitial.
const GURL url2("http://bar");
controller.LoadURL(url2, Referrer(), ui::PAGE_TRANSITION_TYPED,
std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
controller.GetPendingEntry()->set_page_type(PAGE_TYPE_INTERSTITIAL);
// At this point the interstitial will be displayed and the load will still
// be pending. If the user continues, the load will commit.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url2);
// The page should be a normal page again.
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
@@ -2694,24 +2803,29 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url2);
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry_id, true, url3);
controller.LoadURL(
url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url4);
+ main_test_rfh()->SendNavigate(3, entry_id, true, url4);
controller.LoadURL(
url5, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(4, url5);
+ main_test_rfh()->SendNavigate(4, entry_id, true, url5);
// Try to remove the last entry. Will fail because it is the current entry.
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
@@ -2721,12 +2835,13 @@ TEST_F(NavigationControllerTest, RemoveEntry) {
// Go back, but don't commit yet. Check that we can't delete the current
// and pending entries.
controller.GoBack();
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2));
// Now commit and delete the last entry.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url4);
+ main_test_rfh()->SendNavigate(3, entry_id, false, url4);
EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
EXPECT_EQ(4, controller.GetEntryCount());
EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
@@ -2756,20 +2871,24 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url2);
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry_id, true, url3);
// Go back, but don't commit yet. Check that we can't delete the current
// and pending entries.
controller.GoBack();
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_FALSE(controller.RemoveEntryAtIndex(2));
EXPECT_FALSE(controller.RemoveEntryAtIndex(1));
@@ -2784,7 +2903,7 @@ TEST_F(NavigationControllerTest, RemoveEntryWithPending) {
// Now commit and ensure we land on the right entry.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url2);
+ main_test_rfh()->SendNavigate(1, entry_id, false, url2);
EXPECT_EQ(2, controller.GetEntryCount());
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_FALSE(controller.GetPendingEntry());
@@ -2806,12 +2925,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url0);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url1);
notifications.Reset();
@@ -2837,8 +2958,9 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Navigate.
controller.LoadURL(
url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url2);
+ main_test_rfh()->SendNavigate(2, entry_id, true, url2);
// We should have navigated, transient entry should be gone.
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
@@ -2851,7 +2973,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->SendRendererInitiatedNavigationRequest(url3, true);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, 0, true, url3);
// Transient entry should be gone.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 4);
@@ -2859,12 +2981,13 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Initiate a navigation, add a transient then commit navigation.
controller.LoadURL(
url4, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
transient_entry = new NavigationEntryImpl;
transient_entry->SetURL(transient_url);
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(4, url4);
+ main_test_rfh()->SendNavigate(4, entry_id, true, url4);
EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(controller.GetEntryCount(), 5);
@@ -2882,8 +3005,9 @@ TEST_F(NavigationControllerTest, TransientEntry) {
// Suppose the page requested a history navigation backward.
controller.GoToOffset(-1);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, entry_id, false, url3);
// Add a transient and go to an entry before the current one.
transient_entry = new NavigationEntryImpl;
@@ -2891,13 +3015,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
controller.GoToIndex(1);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// The navigation should have been initiated, transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
// Visible entry does not update for history navigations until commit.
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry_id, false, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
// Add a transient and go to an entry after the current one.
@@ -2906,13 +3031,14 @@ TEST_F(NavigationControllerTest, TransientEntry) {
controller.SetTransientEntry(transient_entry);
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
controller.GoToIndex(3);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// The navigation should have been initiated, transient entry should be gone.
// Because of the transient entry that is removed, going to index 3 makes us
// land on url2 (which is visible after the commit).
EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url2);
+ main_test_rfh()->SendNavigate(2, entry_id, false, url2);
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
// Add a transient and go forward.
@@ -2922,12 +3048,13 @@ TEST_F(NavigationControllerTest, TransientEntry) {
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
EXPECT_TRUE(controller.CanGoForward());
controller.GoForward();
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
// We should have navigated, transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url2, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3);
+ main_test_rfh()->SendNavigate(3, entry_id, false, url3);
EXPECT_EQ(url3, controller.GetVisibleEntry()->GetURL());
// Add a transient and do an in-page navigation, replacing the current entry.
@@ -2938,7 +3065,7 @@ TEST_F(NavigationControllerTest, TransientEntry) {
main_test_rfh()->SendRendererInitiatedNavigationRequest(url3_ref, false);
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(3, url3_ref);
+ main_test_rfh()->SendNavigate(3, 0, false, url3_ref);
// Transient entry should be gone.
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_EQ(url3_ref, controller.GetVisibleEntry()->GetURL());
@@ -2962,8 +3089,9 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// Load |url0|, and start a pending navigation to |url1|.
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url0);
controller.LoadURL(
url1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
@@ -2978,6 +3106,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// the transient entry for |transient_url|, and start a navigation to
// |transient_url|.
controller.Reload(true);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_FALSE(controller.GetTransientEntry());
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(transient_url, controller.GetVisibleEntry()->GetURL());
@@ -2986,7 +3115,7 @@ TEST_F(NavigationControllerTest, ReloadTransient) {
// Load of |transient_url| completes.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, transient_url);
+ main_test_rfh()->SendNavigate(1, entry_id, true, transient_url);
ASSERT_EQ(controller.GetEntryCount(), 2);
EXPECT_EQ(controller.GetEntryAtIndex(0)->GetURL(), url0);
EXPECT_EQ(controller.GetEntryAtIndex(1)->GetURL(), transient_url);
@@ -3025,7 +3154,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL());
// Once it commits, the URL and virtual URL should reflect the actual page.
- main_test_rfh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, 0, true, url2);
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL());
@@ -3045,7 +3174,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
main_test_rfh()->PrepareForCommit();
navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false);
EXPECT_TRUE(controller.GetPendingEntry()->should_replace_entry());
- main_test_rfh()->SendNavigate(0, url2);
+ main_test_rfh()->SendNavigate(0, 0, false, url2);
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetURL());
}
@@ -3064,16 +3193,18 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
// should update before commit.
controller.LoadURL(
url0, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(url0, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL());
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url0);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url0);
// For link clicks (renderer-initiated navigations), the pending entry should
// update before commit but the visible should not.
NavigationController::LoadURLParams load_url_params(url1);
load_url_params.is_renderer_initiated = true;
controller.LoadURLWithParams(load_url_params);
+ entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(url0, controller.GetVisibleEntry()->GetURL());
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated());
@@ -3081,7 +3212,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLUntilCommit) {
// After commit, both visible should be updated, there should be no pending
// entry, and we should no longer treat the entry as renderer-initiated.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(1, url1);
+ main_test_rfh()->SendNavigate(1, entry_id, true, url1);
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_FALSE(controller.GetLastCommittedEntry()->is_renderer_initiated());
@@ -3239,6 +3370,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) {
load_url_params.transition_type = ui::PAGE_TRANSITION_LINK;
load_url_params.is_renderer_initiated = true;
controller.LoadURLWithParams(load_url_params);
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL());
EXPECT_TRUE(controller.GetPendingEntry()->is_renderer_initiated());
EXPECT_TRUE(controller.IsInitialNavigation());
@@ -3246,7 +3378,7 @@ TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) {
// Simulate a commit and then starting a new pending navigation.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(0, url1);
+ main_test_rfh()->SendNavigate(0, entry_id, true, url1);
NavigationController::LoadURLParams load_url2_params(url2);
load_url2_params.transition_type = ui::PAGE_TRANSITION_LINK;
load_url2_params.is_renderer_initiated = true;
@@ -3276,16 +3408,15 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
// was the first document in the given frame, but we don't have enough
// information to identify that case currently.
const GURL blank_url(url::kAboutBlankURL);
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, blank_url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, blank_url);
EXPECT_TRUE(controller.IsURLInPageNavigation(url, true,
main_test_rfh()));
// Navigate to URL with no refs.
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, false, url);
// Reloading the page is not an in-page navigation.
- EXPECT_FALSE(controller.IsURLInPageNavigation(url, false,
- main_test_rfh()));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(url, false, main_test_rfh()));
const GURL other_url("http://www.google.com/add.html");
EXPECT_FALSE(controller.IsURLInPageNavigation(other_url, false,
main_test_rfh()));
@@ -3294,7 +3425,7 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
main_test_rfh()));
// Navigate to URL with refs.
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, url_with_ref);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, url_with_ref);
// Reloading the page is not an in-page navigation.
EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref, false,
@@ -3332,14 +3463,14 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
EXPECT_TRUE(prefs.allow_universal_access_from_file_urls);
// Allow in page navigation if existing URL is file scheme.
const GURL file_url("file:///foo/index.html");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, file_url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, false, file_url);
EXPECT_EQ(0, rph->bad_msg_count());
EXPECT_TRUE(controller.IsURLInPageNavigation(different_origin_url, true,
main_test_rfh()));
EXPECT_EQ(0, rph->bad_msg_count());
// Don't honor allow_universal_access_from_file_urls if existing URL is
// not file scheme.
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, false, url);
EXPECT_FALSE(controller.IsURLInPageNavigation(different_origin_url, true,
main_test_rfh()));
EXPECT_EQ(1, rph->bad_msg_count());
@@ -3366,7 +3497,7 @@ TEST_F(NavigationControllerTest, SameSubframe) {
NavigationControllerImpl& controller = controller_impl();
// Navigate the main frame.
const GURL url("http://www.google.com/");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url);
// We should be at the first navigation entry.
EXPECT_EQ(controller.GetEntryCount(), 1);
@@ -3376,6 +3507,8 @@ TEST_F(NavigationControllerTest, SameSubframe) {
const GURL subframe("http://www.google.com/#");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 0;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = subframe;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
params.should_update_history = false;
@@ -3521,6 +3654,8 @@ TEST_F(NavigationControllerTest, SubframeWhilePending) {
const GURL url1_sub("http://foo/subframe");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = controller.GetLastCommittedEntry()->GetPageID();
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = url1_sub;
params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME;
params.should_update_history = false;
@@ -3818,8 +3953,8 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPruneTargetPending2) {
// Simulate a client redirect, which has the same page ID as entry 2a.
other_controller.LoadURL(
url2b, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
- other_controller.GetPendingEntry()->SetPageID(
- other_controller.GetLastCommittedEntry()->GetPageID());
+ NavigationEntry* entry = other_controller.GetPendingEntry();
+ entry->SetPageID(other_controller.GetLastCommittedEntry()->GetPageID());
other_contents->ExpectSetHistoryOffsetAndLength(1, 2);
other_controller.CopyStateFromAndPrune(&controller, false);
@@ -3838,7 +3973,9 @@ TEST_F(NavigationControllerTest, CopyStateFromAndPruneTargetPending2) {
EXPECT_EQ(url2b, other_controller.GetPendingEntry()->GetURL());
// Let the pending entry commit.
- other_contents->CommitPendingNavigation();
+ other_contents->TestDidNavigate(other_contents->GetMainFrame(),
+ entry->GetPageID(), 0, false, url2b,
+ ui::PAGE_TRANSITION_LINK);
// The max page ID map should be copied over and updated with the max page ID
// from the current tab.
@@ -4199,6 +4336,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
// Create a pending entry that is not in the entry list.
controller.LoadURL(
url3, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller.GetPendingEntry()->GetUniqueID();
EXPECT_TRUE(controller.GetPendingEntry());
EXPECT_EQ(2, controller.GetEntryCount());
@@ -4215,7 +4353,7 @@ TEST_F(NavigationControllerTest, PruneAllButLastCommittedForPendingNotInList) {
// Try to commit the pending entry.
main_test_rfh()->PrepareForCommit();
- main_test_rfh()->SendNavigate(2, url3);
+ main_test_rfh()->SendNavigate(2, entry_id, true, url3);
EXPECT_EQ(-1, controller.GetPendingEntryIndex());
EXPECT_FALSE(controller.GetPendingEntry());
EXPECT_EQ(2, controller.GetEntryCount());
@@ -4257,7 +4395,7 @@ TEST_F(NavigationControllerTest, IsInitialNavigation) {
// After commit, it stays false.
const GURL url1("http://foo1");
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, url1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, url1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
EXPECT_FALSE(controller.IsInitialNavigation());
@@ -4280,7 +4418,8 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller);
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, kPageWithFavicon);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(
+ 0, true, kPageWithFavicon);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -4299,9 +4438,10 @@ TEST_F(NavigationControllerTest, ClearFaviconOnRedirect) {
false);
main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigateWithTransition(
- 0, // same page ID.
- kPageWithoutFavicon,
- ui::PAGE_TRANSITION_CLIENT_REDIRECT);
+ 0, // same page ID.
+ 0, // nav_entry_id
+ false, // no new entry
+ kPageWithoutFavicon, ui::PAGE_TRANSITION_CLIENT_REDIRECT);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -4323,7 +4463,7 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
TestNotificationTracker notifications;
RegisterForAllNavNotifications(&notifications, &controller);
- main_test_rfh()->NavigateAndCommitRendererInitiated(0, kUrl1);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(0, true, kUrl1);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -4337,14 +4477,13 @@ TEST_F(NavigationControllerTest, BackNavigationDoesNotClearFavicon) {
favicon_status.valid = true;
// Navigate to another page and go back to the original page.
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, kUrl2);
+ main_test_rfh()->NavigateAndCommitRendererInitiated(1, true, kUrl2);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
main_test_rfh()->SendRendererInitiatedNavigationRequest(kUrl1, false);
main_test_rfh()->PrepareForCommit();
main_test_rfh()->SendNavigateWithTransition(
- 0,
- kUrl1,
+ 0, controller.GetEntryAtIndex(0)->GetUniqueID(), false, kUrl1,
ui::PAGE_TRANSITION_FORWARD_BACK);
EXPECT_EQ(1U, navigation_entry_committed_counter_);
navigation_entry_committed_counter_ = 0;
@@ -4445,7 +4584,8 @@ TEST_F(NavigationControllerTest, MAYBE_PurgeScreenshot) {
TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
// Navigate.
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, GURL("http://foo"));
+ main_test_rfh()->NavigateAndCommitRendererInitiated(
+ 1, true, GURL("http://foo"));
// Set title and favicon.
base::string16 title(base::ASCIIToUTF16("Title"));
@@ -4459,6 +4599,8 @@ TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
FrameHostMsg_DidCommitProvisionalLoad_Params params;
GURL kUrl2("http://foo#foo");
params.page_id = 2;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = kUrl2;
params.page_state = PageState::CreateFromURL(kUrl2);
params.was_within_same_page = true;
@@ -4537,6 +4679,8 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
GURL url("http://foo");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.transition = ui::PAGE_TRANSITION_FORM_SUBMIT;
params.gesture = NavigationGestureUser;
@@ -4551,6 +4695,8 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
// history.replaceState() is called.
GURL replace_url("http://foo#foo");
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = replace_url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.gesture = NavigationGestureUser;
@@ -4572,6 +4718,8 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
GURL url("http://foo");
FrameHostMsg_DidCommitProvisionalLoad_Params params;
params.page_id = 1;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = true;
params.url = url;
params.transition = ui::PAGE_TRANSITION_LINK;
params.gesture = NavigationGestureUser;
@@ -4580,7 +4728,8 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
params.is_post = true;
params.post_id = 2;
params.url_is_unreachable = true;
- // Navigate to new page
+
+ // Navigate to new page.
{
LoadCommittedDetails details;
controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
@@ -4591,6 +4740,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
// Navigate to existing page.
{
+ params.did_create_new_entry = false;
LoadCommittedDetails details;
controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
EXPECT_EQ(PAGE_TYPE_ERROR,
@@ -4603,6 +4753,7 @@ TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
// same-page transition.
controller_impl().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ params.nav_entry_id = controller_impl().GetPendingEntry()->GetUniqueID();
params.transition = ui::PAGE_TRANSITION_TYPED;
{
LoadCommittedDetails details;
diff --git a/content/browser/frame_host/navigation_entry_impl.cc b/content/browser/frame_host/navigation_entry_impl.cc
index 7e930dc..fb0d41f 100644
--- a/content/browser/frame_host/navigation_entry_impl.cc
+++ b/content/browser/frame_host/navigation_entry_impl.cc
@@ -412,6 +412,7 @@ StartNavigationParams NavigationEntryImpl::ConstructStartNavigationParams()
RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams(
base::TimeTicks navigation_start,
+ bool intended_as_new_entry,
int pending_history_list_offset,
int current_history_list_offset,
int current_history_list_length) const {
@@ -436,8 +437,9 @@ RequestNavigationParams NavigationEntryImpl::ConstructRequestNavigationParams(
return RequestNavigationParams(
GetIsOverridingUserAgent(), navigation_start, redirects,
GetCanLoadLocalResources(), base::Time::Now(), GetPageState(),
- GetPageID(), pending_offset_to_send, current_offset_to_send,
- current_length_to_send, should_clear_history_list());
+ GetPageID(), GetUniqueID(), intended_as_new_entry, pending_offset_to_send,
+ current_offset_to_send, current_length_to_send,
+ should_clear_history_list());
}
void NavigationEntryImpl::ResetForCommit() {
diff --git a/content/browser/frame_host/navigation_entry_impl.h b/content/browser/frame_host/navigation_entry_impl.h
index 4f47b8a..f665819 100644
--- a/content/browser/frame_host/navigation_entry_impl.h
+++ b/content/browser/frame_host/navigation_entry_impl.h
@@ -131,6 +131,7 @@ class CONTENT_EXPORT NavigationEntryImpl
StartNavigationParams ConstructStartNavigationParams() const;
RequestNavigationParams ConstructRequestNavigationParams(
base::TimeTicks navigation_start,
+ bool intended_as_new_entry,
int pending_offset_to_send,
int current_offset_to_send,
int current_length_to_send) const;
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index f46eecb..cd443de 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -90,7 +90,9 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
BeginNavigationParams(method, headers.ToString(),
LoadFlagFromNavigationType(navigation_type), false),
entry.ConstructRequestNavigationParams(
- navigation_start, controller->GetIndexOfEntry(&entry),
+ navigation_start,
+ controller->GetPendingEntryIndex() == -1,
+ controller->GetIndexOfEntry(&entry),
controller->GetLastCommittedEntryIndex(),
controller->GetEntryCount()),
request_body, true, &entry));
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 91c3a6d..d3f94c7 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -328,7 +328,9 @@ bool NavigatorImpl::NavigateToEntry(
entry.ConstructCommonNavigationParams(navigation_type),
entry.ConstructStartNavigationParams(),
entry.ConstructRequestNavigationParams(
- navigation_start, controller_->GetIndexOfEntry(&entry),
+ navigation_start,
+ controller_->GetPendingEntryIndex() == -1,
+ controller_->GetIndexOfEntry(&entry),
controller_->GetLastCommittedEntryIndex(),
controller_->GetEntryCount()));
} else {
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index d265010..8dc64af 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -50,12 +50,17 @@ class NavigatorTestWithBrowserSideNavigation
return static_cast<TestNavigationURLLoader*>(request->loader_for_testing());
}
- void RequestNavigation(FrameTreeNode* node, const GURL& url) {
- RequestNavigationWithParameters(node, url, Referrer(),
- ui::PAGE_TRANSITION_LINK);
+ // Requests a navigation of the specified FrameTreeNode to the specified URL;
+ // returns the unique ID of the pending NavigationEntry.
+ int RequestNavigation(FrameTreeNode* node, const GURL& url) {
+ return RequestNavigationWithParameters(node, url, Referrer(),
+ ui::PAGE_TRANSITION_LINK);
}
- void RequestNavigationWithParameters(
+ // Requests a navigation of the specified FrameTreeNode to the specified URL,
+ // using other specified parameters; returns the unique ID of the pending
+ // NavigationEntry.
+ int RequestNavigationWithParameters(
FrameTreeNode* node,
const GURL& url,
const Referrer& referrer,
@@ -66,6 +71,7 @@ class NavigatorTestWithBrowserSideNavigation
load_params.transition_type = transition_type;
controller().LoadURLWithParams(load_params);
+ return controller().GetPendingEntry()->GetUniqueID();
}
TestRenderFrameHost* GetSpeculativeRenderFrameHost(FrameTreeNode* node) {
@@ -105,7 +111,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Start a browser-initiated navigation.
int32 site_instance_id = main_test_rfh()->GetSiteInstance()->GetId();
FrameTreeNode* node = main_test_rfh()->frame_tree_node();
- RequestNavigation(node, kUrl);
+ int entry_id = RequestNavigation(node, kUrl);
NavigationRequest* request = node->navigation_request();
ASSERT_TRUE(request);
EXPECT_EQ(kUrl, request->common_params().url);
@@ -126,7 +132,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state());
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl);
+ main_test_rfh()->SendNavigate(0, entry_id, true, kUrl);
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl),
main_test_rfh()->GetSiteInstance()->GetSiteURL());
@@ -179,7 +185,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state());
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, 0, true, kUrl2);
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
EXPECT_EQ(SiteInstanceImpl::GetSiteForURL(browser_context(), kUrl2),
main_test_rfh()->GetSiteInstance()->GetSiteURL());
@@ -224,7 +230,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_EQ(NavigationRequest::RESPONSE_STARTED, request->state());
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, 0, true, kUrl2);
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, main_test_rfh()->rfh_state());
EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL());
EXPECT_FALSE(node->navigation_request());
@@ -414,7 +420,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) {
// Navigate to a different site.
process()->sink().ClearMessages();
- RequestNavigation(node, kUrl2);
+ int entry_id = RequestNavigation(node, kUrl2);
NavigationRequest* main_request = node->navigation_request();
ASSERT_TRUE(main_request);
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
@@ -433,7 +439,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteNavigation) {
EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh()));
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
- speculative_rfh->SendNavigate(0, kUrl2);
+ speculative_rfh->SendNavigate(0, entry_id, true, kUrl2);
RenderFrameHostImpl* final_rfh = main_test_rfh();
EXPECT_EQ(speculative_rfh, final_rfh);
@@ -455,7 +461,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) {
// Navigate to a URL on the same site.
process()->sink().ClearMessages();
- RequestNavigation(node, kUrl1);
+ int entry_id = RequestNavigation(node, kUrl1);
main_test_rfh()->SendBeforeUnloadACK(true);
NavigationRequest* main_request = node->navigation_request();
ASSERT_TRUE(main_request);
@@ -478,7 +484,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, RedirectCrossSite) {
EXPECT_TRUE(DidRenderFrameHostRequestCommit(final_speculative_rfh));
// Commit the navigation.
- final_speculative_rfh->SendNavigate(0, kUrl2);
+ final_speculative_rfh->SendNavigate(0, entry_id, true, kUrl2);
RenderFrameHostImpl* final_rfh = main_test_rfh();
ASSERT_TRUE(final_rfh);
EXPECT_NE(rfh, final_rfh);
@@ -523,7 +529,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Request navigation to the 2nd URL; the NavigationRequest must have been
// replaced by a new one with a different URL.
- RequestNavigation(node, kUrl2);
+ int entry_id = RequestNavigation(node, kUrl2);
main_test_rfh()->SendBeforeUnloadACK(true);
NavigationRequest* request2 = node->navigation_request();
ASSERT_TRUE(request2);
@@ -547,7 +553,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- speculative_rfh->SendNavigate(0, kUrl2);
+ speculative_rfh->SendNavigate(0, entry_id, true, kUrl2);
// Confirm that the commit corresponds to the new request.
ASSERT_TRUE(main_test_rfh());
@@ -608,7 +614,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, 0, true, kUrl2);
// Confirm that the commit corresponds to the new request.
ASSERT_TRUE(main_test_rfh());
@@ -656,7 +662,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl1);
+ main_test_rfh()->SendNavigate(1, 0, true, kUrl1);
EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL());
}
@@ -674,7 +680,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Start a browser-initiated navigation to the 1st URL.
process()->sink().ClearMessages();
- RequestNavigation(node, kUrl1);
+ int entry_id = RequestNavigation(node, kUrl1);
NavigationRequest* request1 = node->navigation_request();
ASSERT_TRUE(request1);
EXPECT_EQ(kUrl1, request1->common_params().url);
@@ -704,7 +710,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- speculative_rfh->SendNavigate(0, kUrl1);
+ speculative_rfh->SendNavigate(0, entry_id, true, kUrl1);
EXPECT_EQ(kUrl1, contents()->GetLastCommittedURL());
}
@@ -752,7 +758,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(main_test_rfh()));
// Commit the navigation.
- main_test_rfh()->SendNavigate(0, kUrl2);
+ main_test_rfh()->SendNavigate(1, 0, true, kUrl2);
EXPECT_EQ(kUrl2, contents()->GetLastCommittedURL());
// The SiteInstance did not change.
@@ -768,6 +774,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
FrameTreeNode* node = main_test_rfh()->frame_tree_node();
controller().Reload(false);
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
// A NavigationRequest should have been generated.
NavigationRequest* main_request = node->navigation_request();
ASSERT_TRUE(main_request != NULL);
@@ -776,7 +783,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, Reload) {
main_test_rfh()->PrepareForCommit();
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
- main_test_rfh()->SendNavigate(0, kUrl);
+ main_test_rfh()->SendNavigate(0, entry_id, false, kUrl);
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
// Now do a shift+reload.
@@ -802,7 +809,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Begin navigating to another site.
const GURL kUrl("http://google.com/");
process()->sink().ClearMessages();
- RequestNavigation(node, kUrl);
+ int entry_id = RequestNavigation(node, kUrl);
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
// Receive the beforeUnload ACK.
@@ -827,7 +834,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_FALSE(node->render_manager()->pending_frame_host());
// Invoke OnDidCommitProvisionalLoad.
- speculative_rfh->SendNavigate(0, kUrl);
+ speculative_rfh->SendNavigate(0, entry_id, true, kUrl);
EXPECT_EQ(site_instance_id, main_test_rfh()->GetSiteInstance()->GetId());
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
EXPECT_FALSE(node->render_manager()->pending_frame_host());
@@ -846,7 +853,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// Begin navigating to another site.
const GURL kUrl("http://google.com/");
process()->sink().ClearMessages();
- RequestNavigation(node, kUrl);
+ int entry_id = RequestNavigation(node, kUrl);
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
// Receive the beforeUnload ACK.
@@ -895,7 +902,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_NE(site_instance_id, redirect_site_instance_id);
// Invoke OnDidCommitProvisionalLoad.
- speculative_rfh->SendNavigate(0, kUrlRedirect);
+ speculative_rfh->SendNavigate(0, entry_id, true, kUrlRedirect);
// Check that the speculative RenderFrameHost was swapped in.
EXPECT_EQ(redirect_site_instance_id,
@@ -931,7 +938,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
// should be reused.
process()->sink().ClearMessages();
rfh1->GetProcess()->sink().ClearMessages();
- RequestNavigation(node, kUrl1);
+ int entry_id = RequestNavigation(node, kUrl1);
EXPECT_FALSE(GetSpeculativeRenderFrameHost(node));
main_test_rfh()->SendBeforeUnloadACK(true);
@@ -948,7 +955,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation,
EXPECT_TRUE(DidRenderFrameHostRequestCommit(rfh1));
EXPECT_FALSE(DidRenderFrameHostRequestCommit(main_test_rfh()));
- rfh1->SendNavigate(1, kUrl1);
+ rfh1->SendNavigate(1, entry_id, true, kUrl1);
EXPECT_EQ(rfh1, main_test_rfh());
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
EXPECT_FALSE(rfhm->IsOnSwappedOutList(rfh1));
@@ -964,7 +971,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) {
FrameTreeNode* node = main_test_rfh()->frame_tree_node();
// Navigate to a data url.
- RequestNavigation(node, kUrl2);
+ int entry_id = RequestNavigation(node, kUrl2);
NavigationRequest* navigation_request = node->navigation_request();
ASSERT_TRUE(navigation_request);
EXPECT_EQ(NavigationRequest::WAITING_FOR_RENDERER_RESPONSE,
@@ -978,7 +985,7 @@ TEST_F(NavigatorTestWithBrowserSideNavigation, DataUrls) {
EXPECT_FALSE(navigation_request->loader_for_testing());
TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node);
ASSERT_TRUE(speculative_rfh);
- speculative_rfh->SendNavigate(0, kUrl2);
+ speculative_rfh->SendNavigate(0, entry_id, true, kUrl2);
EXPECT_EQ(main_test_rfh(), speculative_rfh);
// Go back to the initial site.
diff --git a/content/browser/frame_host/render_frame_host_manager_unittest.cc b/content/browser/frame_host/render_frame_host_manager_unittest.cc
index c5ea0e6..8088ea8 100644
--- a/content/browser/frame_host/render_frame_host_manager_unittest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_unittest.cc
@@ -262,6 +262,7 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
// for us.
controller().LoadURL(
url, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
// Simulate the BeforeUnload_ACK that is received from the current renderer
// for a cross-site navigation.
@@ -288,7 +289,7 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
// state is being checked.
RenderFrameHostDeletedObserver rfh_observer(old_rfh);
RenderViewHostDeletedObserver rvh_observer(old_rfh->GetRenderViewHost());
- active_rfh->SendNavigate(max_page_id + 1, url);
+ active_rfh->SendNavigate(max_page_id + 1, entry_id, true, url);
// Make sure that we start to run the unload handler at the time of commit.
bool expecting_rfh_shutdown = false;
@@ -351,6 +352,7 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
// Navigate to a cross-site URL.
contents()->GetController().LoadURL(
kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = contents()->GetController().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
@@ -366,7 +368,7 @@ class RenderFrameHostManagerTest : public RenderViewHostImplTestHarness {
// BeforeUnload finishes.
ntp_rfh->SendBeforeUnloadACK(true);
- dest_rfh->SendNavigate(101, kDestUrl);
+ dest_rfh->SendNavigate(101, entry_id, true, kDestUrl);
ntp_rfh->OnSwappedOut();
EXPECT_TRUE(ntp_rfh->is_swapped_out());
@@ -435,21 +437,23 @@ TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) {
// we use the committed one.
contents2->GetController().LoadURL(
kChromeUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID();
contents2->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* ntp_rfh2 = contents2->GetMainFrame();
EXPECT_FALSE(contents2->CrossProcessNavigationPending());
- ntp_rfh2->SendNavigate(100, kChromeUrl);
+ ntp_rfh2->SendNavigate(100, entry_id, true, kChromeUrl);
// The second one is the opposite, creating a cross-site transition and
// requiring a beforeunload ack.
contents2->GetController().LoadURL(
kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID();
contents2->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents2->CrossProcessNavigationPending());
TestRenderFrameHost* dest_rfh2 = contents2->GetPendingMainFrame();
ASSERT_TRUE(dest_rfh2);
- dest_rfh2->SendNavigate(101, kDestUrl);
+ dest_rfh2->SendNavigate(101, entry_id, true, kDestUrl);
// The two RFH's should be different in every way.
EXPECT_NE(contents()->GetMainFrame()->GetProcess(), dest_rfh2->GetProcess());
@@ -465,8 +469,10 @@ TEST_F(RenderFrameHostManagerTest, NewTabPageProcesses) {
contents2->GetController().LoadURL(
kChromeUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ entry_id = contents2->GetController().GetPendingEntry()->GetUniqueID();
contents2->GetMainFrame()->PrepareForCommit();
- contents2->GetPendingMainFrame()->SendNavigate(102, kChromeUrl);
+ contents2->GetPendingMainFrame()->SendNavigate(102, entry_id, true,
+ kChromeUrl);
EXPECT_NE(contents()->GetMainFrame()->GetSiteInstance(),
contents2->GetMainFrame()->GetSiteInstance());
@@ -597,9 +603,11 @@ TEST_F(RenderFrameHostManagerTest, UpdateFaviconURLWhilePendingSwapOut) {
// Navigate to a cross-site URL and commit the new page.
controller().LoadURL(
kDestUrl, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
- contents()->TestDidNavigate(rfh2, 1, kDestUrl, ui::PAGE_TRANSITION_TYPED);
+ contents()->TestDidNavigate(rfh2, 1, entry_id, true, kDestUrl,
+ ui::PAGE_TRANSITION_TYPED);
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state());
EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state());
@@ -853,6 +861,7 @@ TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
// GetURL() call.
controller().LoadURL(
kViewSourceUrl, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
// Simulate response from RenderFrame for DispatchBeforeUnload.
contents()->GetMainFrame()->PrepareForCommit();
@@ -861,7 +870,7 @@ TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
RenderFrameHost* last_rfh = contents()->GetPendingMainFrame();
int32 new_id =
contents()->GetMaxPageIDForSiteInstance(last_rfh->GetSiteInstance()) + 1;
- contents()->GetPendingMainFrame()->SendNavigate(new_id, kUrl);
+ contents()->GetPendingMainFrame()->SendNavigate(new_id, entry_id, true, kUrl);
EXPECT_EQ(1, controller().GetLastCommittedEntryIndex());
NavigationEntry* last_committed = controller().GetLastCommittedEntry();
@@ -879,6 +888,7 @@ TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
// Navigate, again.
controller().LoadURL(
kViewSourceUrl, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ entry_id = controller().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
// The same RenderViewHost should be reused.
@@ -886,7 +896,7 @@ TEST_F(RenderFrameHostManagerTest, AlwaysSendEnableViewSourceMode) {
EXPECT_EQ(last_rfh, contents()->GetMainFrame());
// The renderer sends a commit.
- contents()->GetMainFrame()->SendNavigate(new_id, kUrl);
+ contents()->GetMainFrame()->SendNavigate(new_id, entry_id, false, kUrl);
EXPECT_EQ(1, controller().GetLastCommittedEntryIndex());
EXPECT_FALSE(controller().GetPendingEntry());
@@ -1187,7 +1197,9 @@ TEST_F(RenderFrameHostManagerTest, PageDoesBackAndReload) {
// Before that RFH has committed, the evil page reloads itself.
FrameHostMsg_DidCommitProvisionalLoad_Params params;
- params.page_id = 1;
+ params.page_id = 0;
+ params.nav_entry_id = 0;
+ params.did_create_new_entry = false;
params.url = kUrl2;
params.transition = ui::PAGE_TRANSITION_CLIENT_REDIRECT;
params.should_update_history = false;
@@ -1267,7 +1279,8 @@ TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
// The back navigation commits.
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
- rfh1->SendNavigate(entry1->GetPageID(), entry1->GetURL());
+ rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false,
+ entry1->GetURL());
EXPECT_TRUE(rfh2->IsWaitingForUnloadACK());
EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh2->rfh_state());
@@ -1275,7 +1288,8 @@ TEST_F(RenderFrameHostManagerTest, NavigateAfterMissingSwapOutACK) {
contents()->GetController().GoForward();
contents()->GetMainFrame()->PrepareForCommit();
const NavigationEntry* entry2 = contents()->GetController().GetPendingEntry();
- rfh2->SendNavigate(entry2->GetPageID(), entry2->GetURL());
+ rfh2->SendNavigate(entry2->GetPageID(), entry2->GetUniqueID(), false,
+ entry2->GetURL());
EXPECT_EQ(rfh2, main_test_rfh());
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh2->rfh_state());
EXPECT_EQ(RenderFrameHostImpl::STATE_PENDING_SWAP_OUT, rfh1->rfh_state());
@@ -1454,7 +1468,8 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerDuringNavigation) {
// The back navigation commits.
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
- rfh1->SendNavigate(entry1->GetPageID(), entry1->GetURL());
+ rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false,
+ entry1->GetURL());
// Ensure the opener is still cleared.
EXPECT_FALSE(contents()->HasOpener());
@@ -1487,7 +1502,8 @@ TEST_F(RenderFrameHostManagerTest, DisownOpenerAfterNavigation) {
contents()->GetController().GoBack();
contents()->GetMainFrame()->PrepareForCommit();
const NavigationEntry* entry1 = contents()->GetController().GetPendingEntry();
- rfh1->SendNavigate(entry1->GetPageID(), entry1->GetURL());
+ rfh1->SendNavigate(entry1->GetPageID(), entry1->GetUniqueID(), false,
+ entry1->GetURL());
// Disown the opener from rfh2.
rfh2->DidDisownOpener();
@@ -1761,6 +1777,7 @@ TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) {
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
@@ -1773,7 +1790,8 @@ TEST_F(RenderFrameHostManagerTest, DeleteFrameAfterSwapOutACK) {
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
// The new page commits.
- contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED);
+ contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2,
+ ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(rfh2, contents()->GetMainFrame());
EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
@@ -1809,13 +1827,15 @@ TEST_F(RenderFrameHostManagerTest, SwapOutFrameAfterSwapOutACK) {
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
contents()->GetMainFrame()->PrepareForCommit();
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(RenderFrameHostImpl::STATE_DEFAULT, rfh1->rfh_state());
TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
// The new page commits.
- contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED);
+ contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2,
+ ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(rfh2, contents()->GetMainFrame());
EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
@@ -1852,12 +1872,14 @@ TEST_F(RenderFrameHostManagerTest,
// Navigate to new site, simulating onbeforeunload approval.
controller().LoadURL(
kUrl2, Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
+ int entry_id = controller().GetPendingEntry()->GetUniqueID();
rfh1->PrepareForCommit();
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
TestRenderFrameHost* rfh2 = contents()->GetPendingMainFrame();
// The new page commits.
- contents()->TestDidNavigate(rfh2, 1, kUrl2, ui::PAGE_TRANSITION_TYPED);
+ contents()->TestDidNavigate(rfh2, 1, entry_id, true, kUrl2,
+ ui::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(contents()->CrossProcessNavigationPending());
EXPECT_EQ(rfh2, contents()->GetMainFrame());
EXPECT_TRUE(contents()->GetPendingMainFrame() == NULL);
diff --git a/content/browser/renderer_host/render_view_host_unittest.cc b/content/browser/renderer_host/render_view_host_unittest.cc
index 39930dc..d3bb34a 100644
--- a/content/browser/renderer_host/render_view_host_unittest.cc
+++ b/content/browser/renderer_host/render_view_host_unittest.cc
@@ -64,7 +64,8 @@ class RenderViewHostTest : public RenderViewHostImplTestHarness {
// All about URLs reported by the renderer should get rewritten to about:blank.
// See RenderViewHost::OnNavigate for a discussion.
TEST_F(RenderViewHostTest, FilterAbout) {
- main_test_rfh()->NavigateAndCommitRendererInitiated(1, GURL("about:cache"));
+ main_test_rfh()->NavigateAndCommitRendererInitiated(
+ 1, true, GURL("about:cache"));
ASSERT_TRUE(controller().GetVisibleEntry());
EXPECT_EQ(GURL(url::kAboutBlankURL),
controller().GetVisibleEntry()->GetURL());
@@ -234,15 +235,14 @@ TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) {
EXPECT_EQ(0, process()->bad_msg_count());
main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
main_test_rfh()->PrepareForCommit();
- contents()->GetMainFrame()->SendNavigateWithFile(1, url, file_path);
+ contents()->GetMainFrame()->SendNavigateWithFile(1, 1, true, url, file_path);
EXPECT_EQ(1, process()->bad_msg_count());
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
process()->GetID(), file_path);
main_test_rfh()->SendRendererInitiatedNavigationRequest(url, false);
main_test_rfh()->PrepareForCommit();
- contents()->GetMainFrame()->SendNavigateWithFile(process()->GetID(), url,
- file_path);
+ contents()->GetMainFrame()->SendNavigateWithFile(2, 2, true, url, file_path);
EXPECT_EQ(1, process()->bad_msg_count());
}
diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
index 8b6c784..9844e6c 100644
--- a/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
+++ b/content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc
@@ -253,8 +253,9 @@ TEST_F(OverscrollNavigationOverlayTest, CancelAfterSuccessfulNavigation) {
EXPECT_EQ(GetOverlay()->direction_, OverscrollNavigationOverlay::NONE);
EXPECT_TRUE(contents()->CrossProcessNavigationPending());
+ NavigationEntry* pending = contents()->GetController().GetPendingEntry();
main_test_rfh()->SendNavigate(
- 1, contents()->GetController().GetPendingEntry()->GetURL());
+ 0, pending->GetUniqueID(), false, pending->GetURL());
EXPECT_EQ(contents()->GetURL(), third());
}
@@ -268,8 +269,9 @@ TEST_F(OverscrollNavigationOverlayTest, Navigation_PaintUpdate) {
// for the previous page, so we should still be observing.
EXPECT_TRUE(GetOverlay()->web_contents());
+ NavigationEntry* pending = contents()->GetController().GetPendingEntry();
main_test_rfh()->SendNavigate(
- 1, contents()->GetController().GetPendingEntry()->GetURL());
+ 0, pending->GetUniqueID(), false, pending->GetURL());
ReceivePaintUpdate();
// Navigation was committed and the paint update was received - we should no
@@ -291,8 +293,9 @@ TEST_F(OverscrollNavigationOverlayTest, Navigation_LoadingUpdate) {
contents()->TestSetIsLoading(true);
contents()->TestSetIsLoading(false);
EXPECT_FALSE(GetOverlay()->web_contents());
+ NavigationEntry* pending = contents()->GetController().GetPendingEntry();
main_test_rfh()->SendNavigate(
- 1, contents()->GetController().GetPendingEntry()->GetURL());
+ 0, pending->GetUniqueID(), false, pending->GetURL());
EXPECT_EQ(contents()->GetURL(), third());
}
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(&params, page_id, url, ui::PAGE_TRANSITION_TYPED);
+ InitNavigateParams(&params, 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(
- &params, 0, GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_TYPED);
+ InitNavigateParams(&params, 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(&params, 0, kGURL, ui::PAGE_TRANSITION_TYPED);
+ InitNavigateParams(&params, 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();