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

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

Issue 2284533002: Ensure FrameNavigationEntry is fully updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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 3e2512042c6d48f9d036d0fd8c9f1571b4f5c5a3..05d96342815e3b556e3ec934ad5373811474ccfb 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -4928,4 +4928,64 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, PostViaOpenUrlMsg) {
EXPECT_EQ("text=value\n", body);
}
+// Test that navigations classified as SAME_PAGE properly update all the
+// members of FrameNavigationEntry. If not, it is possible to get a mismatch
+// between the origin and URL of a document as seen in
+// https://crbug.com/630103.
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ EnsureSamePageNavigationUpdatesFrameNavigationEntry) {
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+ FrameTreeNode* root = web_contents->GetFrameTree()->root();
+
+ // Navigate to a simple page and then perform an in-page navigation.
+ GURL start_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), start_url));
+
+ GURL same_page_url(
+ embedded_test_server()->GetURL("a.com", "/title1.html#foo"));
+ EXPECT_TRUE(NavigateToURL(shell(), same_page_url));
+ EXPECT_EQ(2, web_contents->GetController().GetEntryCount());
+
+ // Replace the URL of the current NavigationEntry with one that will cause
+ // a server redirect when loaded.
+ {
+ GURL redirect_dest_url(
+ embedded_test_server()->GetURL("sub.a.com", "/simple_page.html"));
+ TestNavigationObserver observer(web_contents);
+ std::string script = "history.replaceState({}, '', '/server-redirect?" +
+ redirect_dest_url.spec() + "')";
+ EXPECT_TRUE(ExecuteScript(root, script));
+ observer.Wait();
+ }
+
+ // Simulate the user hitting Enter in the omnibox without changing the URL.
+ {
+ TestNavigationObserver observer(web_contents);
+ web_contents->GetController().LoadURL(web_contents->GetLastCommittedURL(),
+ Referrer(), ui::PAGE_TRANSITION_LINK,
+ std::string());
+ observer.Wait();
+ }
+
+ // Prior to fixing the issue, the above omnibox navigation (which is
+ // classified as SAME_PAGE) was leaving the FrameNavigationEntry with the
+ // same document sequence number as the previous entry but updates the URL.
+ // Doing a back session history navigation now will cause the browser to
+ // consider it as in-page because of this matching document sequence number
+ // and lead to a mismatch of origin and URL in the renderer process.
+ {
+ TestNavigationObserver observer(web_contents);
+ web_contents->GetController().GoBack();
+ observer.Wait();
+ }
+
+ // Verify the expected origin through JavaScript. It also has the additional
+ // verification of the process also being still alive.
+ std::string origin;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ web_contents, "domAutomationController.send(document.origin)", &origin));
+ EXPECT_EQ(start_url.GetOrigin().spec(), origin + "/");
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/frame_host/navigation_entry_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698