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

Unified Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 1777903003: Ensure the NavigationHandle's nav entry ID is updated during transfers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix else branch Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
index 81e71a0c95388d93b912c59c1f77cbbb2f466105..c32b3566c1c58b369ec84668f0ed832f36ab74e8 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -2914,6 +2914,63 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
DoReplaceStateWhilePending(shell(), url, url, "simple_page_1.html");
}
+// Ensure that a pending NavigationEntry for a different navigation doesn't
+// cause a commit to be incorrectly treated as a replacement.
+// See https://crbug.com/593153.
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ OtherCommitDuringPendingEntryWithReplacement) {
+ NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+
+ // Load an initial page.
+ GURL start_url(embedded_test_server()->GetURL(
+ "/navigation_controller/simple_page_1.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), start_url));
+ int entry_count = controller.GetEntryCount();
+ EXPECT_EQ(1, controller.GetEntryCount());
+ EXPECT_EQ(start_url, controller.GetLastCommittedEntry()->GetURL());
+
+ // Start a cross-process navigation with replacement, which never completes.
+ GURL foo_url(embedded_test_server()->GetURL(
+ "foo.com", "/navigation_controller/page_with_links.html"));
+ NavigationStallDelegate stall_delegate(foo_url);
+ ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate);
+ NavigationController::LoadURLParams params(foo_url);
+ params.should_replace_current_entry = true;
+ controller.LoadURLWithParams(params);
+
+ // That should be the pending entry.
+ NavigationEntryImpl* entry = controller.GetPendingEntry();
+ ASSERT_NE(nullptr, entry);
+ EXPECT_EQ(foo_url, entry->GetURL());
+ EXPECT_EQ(entry_count, controller.GetEntryCount());
+
+ {
+ // Now the existing page uses history.pushState() while the pending entry
+ // for the other navigation still exists.
+ FrameNavigateParamsCapturer capturer(root);
+ capturer.set_wait_for_load(false);
+ std::string script = "history.pushState({}, '', 'pushed')";
+ EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script));
+ capturer.Wait();
+ EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type);
+ EXPECT_TRUE(capturer.details().is_in_page);
+ }
+
+ // The in-page navigation should not have replaced the previous entry.
+ GURL push_state_url(
+ embedded_test_server()->GetURL("/navigation_controller/pushed"));
+ EXPECT_EQ(entry_count + 1, controller.GetEntryCount());
+ EXPECT_EQ(push_state_url, controller.GetLastCommittedEntry()->GetURL());
+ EXPECT_EQ(start_url, controller.GetEntryAtIndex(0)->GetURL());
+
+ ResourceDispatcherHost::Get()->SetDelegate(nullptr);
+}
+
// Ensure the renderer process does not get confused about the current entry
// due to subframes and replaced entries. See https://crbug.com/480201.
// TODO(creis): Re-enable for Site Isolation FYI bots: https://crbug.com/502317.

Powered by Google App Engine
This is Rietveld 408576698