Chromium Code Reviews| Index: chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc |
| diff --git a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc |
| index e132ecbb35fec6987d5cfbba9566353e9ebb1516..145de0acb21bad1e8eb67b3244541f7940578c72 100644 |
| --- a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc |
| +++ b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc |
| @@ -202,4 +202,36 @@ void DomDistillerViewerSourceBrowserTest::ViewSingleDistilledPage() { |
| EXPECT_EQ("text/html", observer.web_contents()->GetContentsMimeType()); |
| } |
| +// The DomDistillerViewerSource renders untrusted content, so ensure no bindings |
| +// are enabled when the CSS resource is loaded. This CSS might be bundle with |
| +// Chrome or provided by an extension. |
| +IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
| + NoWebUIBindingsDisplayCSS) { |
| + // Ensure the source is registered. |
| + // TODO(nyquist): Remove when the source is always registered on startup. |
| + DomDistillerViewerSource* source = |
| + new DomDistillerViewerSource(NULL, chrome::kDomDistillerScheme); |
| + content::URLDataSource::Add(browser()->profile(), source); |
| + |
| + // Setup observer to inspect the RenderViewHost after committed navigation. |
| + content::WebContents* contents = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + LoadSuccessObserver observer(contents); |
| + |
| + // Navigate to a URL which the source should respond to with CSS. |
| + std::string url_without_scheme = "://foobar/readability.css"; |
| + GURL url(chrome::kDomDistillerScheme + url_without_scheme); |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + // A navigation should have succeeded to the correct URL. |
| + ASSERT_FALSE(observer.load_failed()); |
| + ASSERT_TRUE(observer.finished_load()); |
| + ASSERT_EQ(url, observer.validated_url()); |
| + // Ensure no bindings. |
| + const content::RenderViewHost* render_view_host = observer.render_view_host(); |
| + ASSERT_EQ(0, render_view_host->GetEnabledBindings()); |
| + // The MIME-type should always be text/html. |
|
cjhopman
2014/01/28 22:01:00
comment doesn't match code
nyquist
2014/01/28 22:09:06
Done.
|
| + EXPECT_EQ("text/css", observer.web_contents()->GetContentsMimeType()); |
| +} |
| + |
| } // namespace dom_distiller |