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

Unified Diff: chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc

Issue 138923002: Add support for showing CSS with distilled articles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added browsertest, changed to use CSP object-src instead of frame-src Created 6 years, 11 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 | components/dom_distiller/content/dom_distiller_viewer_source.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | components/dom_distiller/content/dom_distiller_viewer_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698