| Index: content/browser/web_contents/web_contents_impl_browsertest.cc
 | 
| diff --git a/content/browser/web_contents/web_contents_impl_browsertest.cc b/content/browser/web_contents/web_contents_impl_browsertest.cc
 | 
| index c010c171de36c26d81c0f182ba118a29341bcb4d..7fb10684a46add625b5bc1a10973229f86461ea7 100644
 | 
| --- a/content/browser/web_contents/web_contents_impl_browsertest.cc
 | 
| +++ b/content/browser/web_contents/web_contents_impl_browsertest.cc
 | 
| @@ -4,6 +4,7 @@
 | 
|  
 | 
|  #include "base/macros.h"
 | 
|  #include "base/run_loop.h"
 | 
| +#include "base/strings/pattern.h"
 | 
|  #include "base/strings/utf_string_conversions.h"
 | 
|  #include "base/values.h"
 | 
|  #include "build/build_config.h"
 | 
| @@ -845,6 +846,90 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, ViewSourceWebUI) {
 | 
|                    ->IsViewSourceMode());
 | 
|  }
 | 
|  
 | 
| +namespace {
 | 
| +const char kDataUrlWarningPattern[] =
 | 
| +    "Upcoming versions will block content-initiated top frame navigations*";
 | 
| +
 | 
| +// This class listens for console messages other than the data: URL warning. It
 | 
| +// fails the test if it sees a data: URL warning.
 | 
| +class NoDataURLWarningConsoleObserverDelegate : public ConsoleObserverDelegate {
 | 
| + public:
 | 
| +  using ConsoleObserverDelegate::ConsoleObserverDelegate;
 | 
| +  // WebContentsDelegate method:
 | 
| +  bool DidAddMessageToConsole(WebContents* source,
 | 
| +                              int32_t level,
 | 
| +                              const base::string16& message,
 | 
| +                              int32_t line_no,
 | 
| +                              const base::string16& source_id) override {
 | 
| +    std::string ascii_message = base::UTF16ToASCII(message);
 | 
| +    EXPECT_FALSE(base::MatchPattern(ascii_message, kDataUrlWarningPattern));
 | 
| +    return ConsoleObserverDelegate::DidAddMessageToConsole(
 | 
| +        source, level, message, line_no, source_id);
 | 
| +  }
 | 
| +};
 | 
| +
 | 
| +}  // namespace
 | 
| +
 | 
| +// Test that a direct navigation to a data URL doesn't show a console warning.
 | 
| +IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, DataURLDirectNavigation) {
 | 
| +  ASSERT_TRUE(embedded_test_server()->Start());
 | 
| +  const GURL kUrl(embedded_test_server()->GetURL("/simple_page.html"));
 | 
| +
 | 
| +  NoDataURLWarningConsoleObserverDelegate console_delegate(
 | 
| +      shell()->web_contents(), "FINISH");
 | 
| +  shell()->web_contents()->SetDelegate(&console_delegate);
 | 
| +
 | 
| +  NavigateToURL(
 | 
| +      shell(),
 | 
| +      GURL("data:text/html,<html><script>console.log('FINISH');</script>"));
 | 
| +  console_delegate.Wait();
 | 
| +  EXPECT_TRUE(shell()->web_contents()->GetURL().SchemeIs(url::kDataScheme));
 | 
| +  EXPECT_FALSE(
 | 
| +      base::MatchPattern(console_delegate.message(), kDataUrlWarningPattern));
 | 
| +}
 | 
| +
 | 
| +// Test that window.open to a data URL shows a console warning.
 | 
| +IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
 | 
| +                       DataURLWindowOpen_ShouldWarn) {
 | 
| +  ASSERT_TRUE(embedded_test_server()->Start());
 | 
| +  const GURL kUrl(embedded_test_server()->GetURL("/simple_page.html"));
 | 
| +  NavigateToURL(shell(), kUrl);
 | 
| +
 | 
| +  ShellAddedObserver new_shell_observer;
 | 
| +  EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
 | 
| +                            "window.open('data:text/plain,test');"));
 | 
| +  Shell* new_shell = new_shell_observer.GetShell();
 | 
| +
 | 
| +  ConsoleObserverDelegate console_delegate(
 | 
| +      new_shell->web_contents(),
 | 
| +      "Upcoming versions will block content-initiated top frame navigations*");
 | 
| +  new_shell->web_contents()->SetDelegate(&console_delegate);
 | 
| +  console_delegate.Wait();
 | 
| +  EXPECT_TRUE(new_shell->web_contents()->GetURL().SchemeIs(url::kDataScheme));
 | 
| +}
 | 
| +
 | 
| +// Test that a content initiated navigation to a data URL shows a console
 | 
| +// warning.
 | 
| +IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, DataURLRedirect_ShouldWarn) {
 | 
| +  ASSERT_TRUE(embedded_test_server()->Start());
 | 
| +  const GURL kUrl(embedded_test_server()->GetURL("/simple_page.html"));
 | 
| +  NavigateToURL(shell(), kUrl);
 | 
| +
 | 
| +  ConsoleObserverDelegate console_delegate(
 | 
| +      shell()->web_contents(),
 | 
| +      "Upcoming versions will block content-initiated top frame navigations*");
 | 
| +  shell()->web_contents()->SetDelegate(&console_delegate);
 | 
| +  EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
 | 
| +                            "window.location.href = 'data:text/plain,test';"));
 | 
| +  console_delegate.Wait();
 | 
| +  EXPECT_TRUE(shell()
 | 
| +                  ->web_contents()
 | 
| +                  ->GetController()
 | 
| +                  .GetLastCommittedEntry()
 | 
| +                  ->GetURL()
 | 
| +                  .SchemeIs(url::kDataScheme));
 | 
| +}
 | 
| +
 | 
|  IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, NewNamedWindow) {
 | 
|    ASSERT_TRUE(embedded_test_server()->Start());
 | 
|  
 | 
| 
 |