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

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

Issue 2099623002: Add a content_browsertest for LoadDataWithBaseURL + Back. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compile Created 4 years, 6 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 | no next file » | 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 5e7aeb68c53a3c74b713d8b1651556e77801ea51..db04043c2448e9185a310c03b2598e8418142e0d 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -132,6 +132,69 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) {
EXPECT_EQ(data_url, reload_entry->GetURL());
}
+// Verify which page loads when going back to a LoadDataWithBaseURL entry.
+// See https://crbug.com/612196.
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ LoadDataWithBaseURLTitleAfterBack) {
+ const GURL base_url("http://baseurl");
+ const GURL history_url(
+ embedded_test_server()->GetURL("/navigation_controller/form.html"));
+ const std::string data1 = "<html><title>One</title><body>foo</body></html>";
+ const GURL data_url1 = GURL("data:text/html;charset=utf-8," + data1);
+
+ NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ {
+ TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
+ shell()->LoadDataWithBaseURL(history_url, data1, base_url);
+ same_tab_observer.Wait();
+ }
+
+ // Verify the last committed NavigationEntry.
+ NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(base_url, entry->GetBaseURLForDataURL());
+ EXPECT_EQ(history_url, entry->GetVirtualURL());
+ EXPECT_EQ(history_url, entry->GetHistoryURLForDataURL());
+ EXPECT_EQ(data_url1, entry->GetURL());
+
+ // Navigate again to a different data URL.
+ const std::string data2 = "<html><title>Two</title><body>bar</body></html>";
+ const GURL data_url2 = GURL("data:text/html;charset=utf-8," + data2);
+ {
+ TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
+ // Load data, not loaddatawithbaseurl.
+ EXPECT_TRUE(NavigateToURL(shell(), data_url2));
+ same_tab_observer.Wait();
+ }
+
+ // Go back.
+ TestNavigationObserver back_load_observer(shell()->web_contents());
+ controller.GoBack();
+ back_load_observer.Wait();
+
+ // Check title.
+ // TODO(creis): The default navigation path incorrectly loads the history_url
+ // and claims it loaded the data_url (due to a bug where GoToEntry does not
+ // handle this case). This is confusing. When using subframe
+ // FrameNavigationEntries, we load the data URL when going back, as expected.
+ if (SiteIsolationPolicy::UseSubframeNavigationEntries())
Charlie Reis 2016/06/24 17:02:12 Here's the bit where I switch the test's expectati
+ EXPECT_EQ("One", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
+ else
+ EXPECT_EQ("form", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
+
+ // Verify the last committed NavigationEntry.
+ NavigationEntryImpl* back_entry = controller.GetLastCommittedEntry();
+ EXPECT_EQ(base_url, back_entry->GetBaseURLForDataURL());
+ EXPECT_EQ(history_url, back_entry->GetVirtualURL());
+ EXPECT_EQ(history_url, back_entry->GetHistoryURLForDataURL());
+ EXPECT_EQ(data_url1, back_entry->GetOriginalRequestURL());
+ EXPECT_EQ(data_url1, back_entry->GetURL());
+
+ EXPECT_EQ(data_url1,
+ shell()->web_contents()->GetMainFrame()->GetLastCommittedURL());
+}
+
#if defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
LoadDataWithInvalidBaseURL) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698