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

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

Issue 2165783003: Grant permission to the base url when loadDataWithBaseURL is called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 4 years, 5 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/browser/frame_host/render_frame_host_impl.cc » ('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 df0abf17426c08bb1ce88778bc4da654ebc9f901..5328a6676031cd0b224955f2d8111dbd0222c659 100644
--- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
@@ -195,6 +195,43 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
shell()->web_contents()->GetMainFrame()->GetLastCommittedURL());
}
+IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
+ CrossDomainResourceRequestLoadDataWithBaseUrl) {
+ const GURL base_url("foobar://");
+ const GURL history_url("http://historyurl");
+ const std::string data = "<html><body></body></html>";
+ const GURL data_url = GURL("data:text/html;charset=utf-8," + data);
+
+ const NavigationControllerImpl& controller =
+ static_cast<const NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ // Load data and commit.
+ {
+ TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
+ shell()->LoadDataWithBaseURL(history_url, data, base_url);
+ same_tab_observer.Wait();
+ EXPECT_EQ(1, controller.GetEntryCount());
+ 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_url, entry->GetURL());
+ }
+
+ // Now make an XHR request and check that the renderer isn't killed.
+ std::string script =
+ "var url = 'http://www.example.com';\n"
+ "var xhr = new XMLHttpRequest();\n"
+ "xhr.open('GET', url);\n"
+ "xhr.send();\n";
+ EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
+ // The renderer may not be killed immediately (if it is indeed killed), so
+ // reload, block and verify its liveness.
+ ReloadBlockUntilNavigationsComplete(shell(), 1);
Charlie Reis 2016/07/26 17:57:13 I'm a bit surprised this fails without the fix, bu
+ EXPECT_TRUE(shell()->web_contents()->GetMainFrame()->IsRenderFrameLive());
+}
+
#if defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
LoadDataWithInvalidBaseURL) {
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698