Prevent bookmarklet and unload tests from being broken by data URL deprecation.
Content-initiated main-frame navigations to data URLs are being blocked
in crbug.com/594215.
BUG=594215
Review-Url: https://codereview.chromium.org/2795903002
Cr-Commit-Position: refs/heads/master@{#461916}
diff --git a/content/browser/bookmarklet_browsertest.cc b/content/browser/bookmarklet_browsertest.cc
index b4ae75a..14d135c 100644
--- a/content/browser/bookmarklet_browsertest.cc
+++ b/content/browser/bookmarklet_browsertest.cc
@@ -14,7 +14,11 @@
namespace content {
class BookmarkletTest : public ContentBrowserTest {
- public:
+ protected:
+ void SetUpOnMainThread() override {
+ ASSERT_TRUE(embedded_test_server()->Start());
+ }
+
void NavigateToStartPage() {
NavigateToURL(shell(), GURL("data:text/html,start page"));
EXPECT_EQ("start page", GetBodyText());
@@ -33,9 +37,11 @@
IN_PROC_BROWSER_TEST_F(BookmarkletTest, Redirect) {
NavigateToStartPage();
- NavigateToURL(shell(), GURL(
- "javascript:location.href='data:text/plain,SUCCESS'"));
- EXPECT_EQ("SUCCESS", GetBodyText());
+ const GURL url(base::StringPrintf(
+ "javascript:location.href='%s'",
+ embedded_test_server()->GetURL("/simple_page.html").spec().c_str()));
+ NavigateToURL(shell(), url);
+ EXPECT_EQ("Basic html test.", GetBodyText());
}
IN_PROC_BROWSER_TEST_F(BookmarkletTest, RedirectVoided) {
@@ -45,9 +51,11 @@
// here is to emphasize that in either case the assignment to location during
// the evaluation of the script should suppress loading the script result.
// Here, because of the void() wrapping there is no script result.
- NavigateToURL(shell(), GURL(
- "javascript:void(location.href='data:text/plain,SUCCESS')"));
- EXPECT_EQ("SUCCESS", GetBodyText());
+ const GURL url(base::StringPrintf(
+ "javascript:void(location.href='%s')",
+ embedded_test_server()->GetURL("/simple_page.html").spec().c_str()));
+ NavigateToURL(shell(), url);
+ EXPECT_EQ("Basic html test.", GetBodyText());
}
// http://crbug.com/177957