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

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

Issue 1802383004: Fix in-page navigation after LoadDataWithBaseURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test for LoadDataAsStringWithBaseURL on android 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62a7f942d7b2ab1788e8c97a8ccc640388483cc6..cf9c8c79ecf8fda878cea954f280ea01daf508e6 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -203,6 +203,46 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
}
}
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ FragmentNavigateFromLoadDataWithBaseURL) {
+ const GURL base_url("http://baseurl");
+ const GURL history_url("http://historyurl");
+ const std::string data =
+ "<html><body>"
+ " <p id=\"frag\"><a id=\"fraglink\" href=\"#frag\">in-page nav</a></p>"
+ "</body></html>";
+
+ const NavigationControllerImpl& controller =
+ static_cast<const NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ // Load data and commit.
+ TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
+#if defined(OS_ANDROID)
+ shell()->LoadDataAsStringWithBaseURL(history_url, data, base_url);
+#else
+ shell()->LoadDataWithBaseURL(history_url, data, base_url);
+#endif
+ same_tab_observer.Wait();
+ EXPECT_EQ(1, controller.GetEntryCount());
+ const GURL data_url = controller.GetLastCommittedEntry()->GetURL();
+
+ // Perform a fragment navigation using a javascript: URL.
+ GURL js_url("javascript:document.location = '#frag';");
+ NavigateToURL(shell(), js_url);
+ EXPECT_EQ(2, controller.GetEntryCount());
+ NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
+ // TODO(boliu): These expectations maybe incorrect due to crbug.com/561034.
+ EXPECT_TRUE(entry->GetBaseURLForDataURL().is_empty());
+ EXPECT_TRUE(entry->GetHistoryURLForDataURL().is_empty());
+ EXPECT_EQ(data_url, entry->GetVirtualURL());
+ EXPECT_EQ(data_url, entry->GetURL());
+
+ // Passes if renderer is still alive.
+ EXPECT_TRUE(
+ ExecuteScript(shell()->web_contents(), "console.log('Success');"));
+}
+
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, UniqueIDs) {
const NavigationControllerImpl& controller =
static_cast<const NavigationControllerImpl&>(
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698