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/browser_side_navigation_browsertest.cc

Issue 2889003002: Change NavigationEntry to use virtual URL in error pages for blocked navigations (Closed)
Patch Set: rebase Created 3 years, 7 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/browser_side_navigation_browsertest.cc
diff --git a/content/browser/browser_side_navigation_browsertest.cc b/content/browser/browser_side_navigation_browsertest.cc
index dbd7bec0da2cec3bbf18f42a64a351a32bc9f1f3..dcfb2c471e1bd87d35a14da9f1bc46e1e0faec16 100644
--- a/content/browser/browser_side_navigation_browsertest.cc
+++ b/content/browser/browser_side_navigation_browsertest.cc
@@ -381,4 +381,45 @@ IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest,
process_exit_observer.Wait();
}
+// Test case to verify that redirects to data: URLs are properly disallowed,
+// even when invoked through a reload.
+// See https://crbug.com/723796.
+//
+// Note: This is PlzNavigate specific test, as the behavior of reloads in the
+// non-PlzNavigate path differs. The WebURLRequest for the reload is generated
+// based on Blink's state instead of the history state in the browser process,
+// which ends up loading the originally blocked URL. With PlzNavigate, the
+// reload uses the NavigationEntry state to create a navigation and commit it.
+IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest,
+ VerifyBlockedErrorPageURL_Reload) {
+ NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>(
+ shell()->web_contents()->GetController());
+
+ GURL start_url(embedded_test_server()->GetURL("/title1.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), start_url));
+ EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
+
+ // Navigate to an URL, which redirects to a data: URL, since it is an
+ // unsafe redirect and will result in a blocked navigation and error page.
+ GURL redirect_to_blank_url(
+ embedded_test_server()->GetURL("/server-redirect?data:text/html,Hello!"));
+ EXPECT_FALSE(NavigateToURL(shell(), redirect_to_blank_url));
+ EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
+ EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType());
+
+ TestNavigationObserver reload_observer(shell()->web_contents());
+ EXPECT_TRUE(ExecuteScript(shell(), "location.reload()"));
+ reload_observer.Wait();
+
+ // The expectation is that about:blank was loaded and the virtual URL is set
+ // to the URL that was blocked.
+ EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
+ EXPECT_FALSE(
+ controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme));
+ EXPECT_TRUE(controller.GetLastCommittedEntry()->GetVirtualURL().SchemeIs(
+ url::kDataScheme));
+ EXPECT_EQ(url::kAboutBlankURL,
+ controller.GetLastCommittedEntry()->GetURL().spec());
+}
+
} // namespace content
« no previous file with comments | « chrome/browser/extensions/navigation_observer.cc ('k') | content/browser/frame_host/data_url_navigation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698