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

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

Issue 1231083007: Expose distiller functions to JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-content
Patch Set: cl format Created 5 years, 5 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
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(&params);
+
+ 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(&params);
+
+ 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()

Powered by Google App Engine
This is Rietveld 408576698