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

Unified Diff: content/shell/test_runner/web_frame_test_client.cc

Issue 2678043002: Hide console log messages for imported WPT tests (Closed)
Patch Set: filter console messages in content_shell rather than python Created 3 years, 9 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: content/shell/test_runner/web_frame_test_client.cc
diff --git a/content/shell/test_runner/web_frame_test_client.cc b/content/shell/test_runner/web_frame_test_client.cc
index ac85df245e22584c5628b14d64a80034f98aec02..005dc39a98e81297924bfc031e770b78ca47250e 100644
--- a/content/shell/test_runner/web_frame_test_client.cc
+++ b/content/shell/test_runner/web_frame_test_client.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/strings/string_piece.h"
+#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "content/shell/test_runner/accessibility_controller.h"
@@ -648,10 +649,11 @@ void WebFrameTestClient::didAddMessageToConsole(
default:
level = "MESSAGE";
}
- delegate_->PrintMessage(std::string("CONSOLE ") + level + ": ");
+ std::string prefix(std::string("CONSOLE ") + level + ": ");
if (source_line) {
- delegate_->PrintMessage(base::StringPrintf("line %d: ", source_line));
+ prefix += base::StringPrintf("line %d: ", source_line);
}
+ bool dump_to_stderr = test_runner()->is_web_platform_tests_mode();
if (!message.text.isEmpty()) {
std::string new_message;
new_message = message.text.utf8();
@@ -660,9 +662,21 @@ void WebFrameTestClient::didAddMessageToConsole(
new_message = new_message.substr(0, file_protocol) +
URLSuitableForTestResult(new_message.substr(file_protocol));
}
- delegate_->PrintMessage(new_message);
+ for (auto piece : base::SplitStringPieceUsingSubstr(
+ new_message, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (dump_to_stderr) {
+ delegate_->PrintLogMessage(prefix + piece.as_string() + "\n");
+ } else {
+ delegate_->PrintMessage(prefix + piece.as_string() + "\n");
+ }
+ }
+ } else {
+ if (dump_to_stderr) {
+ delegate_->PrintLogMessage(prefix + "\n");
+ } else {
+ delegate_->PrintMessage(prefix + "\n");
+ }
}
- delegate_->PrintMessage(std::string("\n"));
}
blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation(

Powered by Google App Engine
This is Rietveld 408576698