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 4ca2fc89d5ec075b765227a0aa27d0e68b0ea5a5..b05e395da5461c85aabb8705b665ead269f33729 100644 |
--- a/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc |
+++ b/chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc |
@@ -34,6 +34,7 @@ |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_observer.h" |
#include "content/public/common/isolated_world_ids.h" |
+#include "content/public/common/service_registry.h" |
#include "content/public/test/browser_test_utils.h" |
#include "grit/components_strings.h" |
#include "testing/gmock/include/gmock/gmock.h" |
@@ -65,6 +66,10 @@ const char kGetBodyClass[] = |
"window.domAutomationController.send(" |
"document.body.className)"; |
+const char kTestDistillerObject[] = |
+ "window.domAutomationController.send(" |
+ "typeof distiller == 'object')"; |
+ |
void AddEntry(const ArticleEntry& e, FakeDB<ArticleEntry>::EntryMap* map) { |
(*map)[e.entry_id()] = e; |
} |
@@ -318,7 +323,44 @@ IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
} |
IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
- MultiPageArticle) { |
+ DistillerJavaScriptExposed) { |
+ // Navigate to a distiller URL. |
+ GURL url(std::string(kDomDistillerScheme) + "://url"); |
+ chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
+ chrome::Navigate(¶ms); |
+ |
+ content::WebContents* contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ |
+ // Wait for the page load to complete (this will be a distiller error page). |
+ content::WaitForLoadStop(contents); |
+ |
+ bool result; |
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
+ contents, kTestDistillerObject, &result)); |
+ EXPECT_TRUE(result); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, |
+ DistillerJavaScriptNotExposed) { |
+ // Navigate to a non-distiller URL. |
+ GURL url("http://url"); |
+ chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
+ chrome::Navigate(¶ms); |
+ |
+ content::WebContents* contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ |
+ // Wait for the page load to complete. |
+ content::WaitForLoadStop(contents); |
+ |
+ bool result; |
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
+ contents, kTestDistillerObject, &result)); |
+ EXPECT_FALSE(result); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, MultiPageArticle) { |
expect_distillation_ = false; |
expect_distiller_page_ = true; |
dom_distiller::DomDistillerServiceFactory::GetInstance() |