Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 ASSERT_FALSE(observer.load_failed()); | 195 ASSERT_FALSE(observer.load_failed()); |
| 196 ASSERT_TRUE(observer.finished_load()); | 196 ASSERT_TRUE(observer.finished_load()); |
| 197 ASSERT_EQ(url, observer.validated_url()); | 197 ASSERT_EQ(url, observer.validated_url()); |
| 198 // Ensure no bindings. | 198 // Ensure no bindings. |
| 199 const content::RenderViewHost* render_view_host = observer.render_view_host(); | 199 const content::RenderViewHost* render_view_host = observer.render_view_host(); |
| 200 ASSERT_EQ(0, render_view_host->GetEnabledBindings()); | 200 ASSERT_EQ(0, render_view_host->GetEnabledBindings()); |
| 201 // The MIME-type should always be text/html. | 201 // The MIME-type should always be text/html. |
| 202 EXPECT_EQ("text/html", observer.web_contents()->GetContentsMimeType()); | 202 EXPECT_EQ("text/html", observer.web_contents()->GetContentsMimeType()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // The DomDistillerViewerSource renders untrusted content, so ensure no bindings | |
| 206 // are enabled when the CSS resource is loaded. This CSS might be bundle with | |
| 207 // Chrome or provided by an extension. | |
| 208 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, | |
| 209 NoWebUIBindingsDisplayCSS) { | |
| 210 // Ensure the source is registered. | |
| 211 // TODO(nyquist): Remove when the source is always registered on startup. | |
| 212 DomDistillerViewerSource* source = | |
| 213 new DomDistillerViewerSource(NULL, chrome::kDomDistillerScheme); | |
| 214 content::URLDataSource::Add(browser()->profile(), source); | |
| 215 | |
| 216 // Setup observer to inspect the RenderViewHost after committed navigation. | |
| 217 content::WebContents* contents = | |
| 218 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 219 LoadSuccessObserver observer(contents); | |
| 220 | |
| 221 // Navigate to a URL which the source should respond to with CSS. | |
| 222 std::string url_without_scheme = "://foobar/readability.css"; | |
| 223 GURL url(chrome::kDomDistillerScheme + url_without_scheme); | |
| 224 ui_test_utils::NavigateToURL(browser(), url); | |
| 225 | |
| 226 // A navigation should have succeeded to the correct URL. | |
| 227 ASSERT_FALSE(observer.load_failed()); | |
| 228 ASSERT_TRUE(observer.finished_load()); | |
| 229 ASSERT_EQ(url, observer.validated_url()); | |
| 230 // Ensure no bindings. | |
| 231 const content::RenderViewHost* render_view_host = observer.render_view_host(); | |
| 232 ASSERT_EQ(0, render_view_host->GetEnabledBindings()); | |
| 233 // 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.
| |
| 234 EXPECT_EQ("text/css", observer.web_contents()->GetContentsMimeType()); | |
| 235 } | |
| 236 | |
| 205 } // namespace dom_distiller | 237 } // namespace dom_distiller |
| OLD | NEW |