Index: chrome/browser/dom_distiller/tab_utils_browsertest.cc |
diff --git a/chrome/browser/dom_distiller/tab_utils_browsertest.cc b/chrome/browser/dom_distiller/tab_utils_browsertest.cc |
index ddc07da66ca99ec4770bdb52a3a17a83e7c2075e..bb4313afb3a2181f937c2e1cc70cbd35b96e8b45 100644 |
--- a/chrome/browser/dom_distiller/tab_utils_browsertest.cc |
+++ b/chrome/browser/dom_distiller/tab_utils_browsertest.cc |
@@ -32,11 +32,42 @@ |
namespace dom_distiller { |
namespace { |
+ |
const char* kSimpleArticlePath = "/dom_distiller/simple_article.html"; |
+ |
+static bool hit_javascript_error = false; |
+ |
+bool JavascriptErrorDetectingLogHandler(int severity, |
+ const char* file, |
+ int line, |
+ size_t message_start, |
+ const std::string& str) { |
+ if (file == NULL || std::string("CONSOLE") != file) |
+ return false; |
+ |
+ // Catch CSP violation as well. |
+ bool contains_error = str.find(" violates ") != std::string::npos; |
+ if (severity == logging::LOG_ERROR || |
+ (severity == logging::LOG_INFO && contains_error)) { |
+ hit_javascript_error = true; |
+ } |
+ |
+ return false; |
+} |
+ |
} // namespace |
class DomDistillerTabUtilsBrowserTest : public InProcessBrowserTest { |
public: |
+ DomDistillerTabUtilsBrowserTest() { |
+ logging::SetLogMessageHandler(&JavascriptErrorDetectingLogHandler); |
+ hit_javascript_error = false; |
+ } |
+ |
+ ~DomDistillerTabUtilsBrowserTest() override { |
+ logging::SetLogMessageHandler(nullptr); |
+ } |
+ |
void SetUpOnMainThread() override { |
if (!DistillerJavaScriptWorldIdIsSet()) { |
SetDistillerJavaScriptWorldId(content::ISOLATED_WORLD_ID_CONTENT_END); |
@@ -47,6 +78,10 @@ class DomDistillerTabUtilsBrowserTest : public InProcessBrowserTest { |
void SetUpCommandLine(base::CommandLine* command_line) override { |
command_line->AppendSwitch(switches::kEnableDomDistiller); |
} |
+ |
+ void TearDown() override { |
+ EXPECT_FALSE(hit_javascript_error); |
+ } |
}; |
// WebContentsMainFrameHelper is used to detect if a distilled page has |