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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/shell/test_runner/web_frame_test_client.h" 5 #include "content/shell/test_runner/web_frame_test_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
11 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "content/shell/test_runner/accessibility_controller.h" 14 #include "content/shell/test_runner/accessibility_controller.h"
14 #include "content/shell/test_runner/event_sender.h" 15 #include "content/shell/test_runner/event_sender.h"
15 #include "content/shell/test_runner/mock_color_chooser.h" 16 #include "content/shell/test_runner/mock_color_chooser.h"
16 #include "content/shell/test_runner/mock_screen_orientation_client.h" 17 #include "content/shell/test_runner/mock_screen_orientation_client.h"
17 #include "content/shell/test_runner/mock_web_user_media_client.h" 18 #include "content/shell/test_runner/mock_web_user_media_client.h"
18 #include "content/shell/test_runner/test_common.h" 19 #include "content/shell/test_runner/test_common.h"
19 #include "content/shell/test_runner/test_interfaces.h" 20 #include "content/shell/test_runner/test_interfaces.h"
20 #include "content/shell/test_runner/test_plugin.h" 21 #include "content/shell/test_runner/test_plugin.h"
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 break; 642 break;
642 case blink::WebConsoleMessage::LevelWarning: 643 case blink::WebConsoleMessage::LevelWarning:
643 level = "WARNING"; 644 level = "WARNING";
644 break; 645 break;
645 case blink::WebConsoleMessage::LevelError: 646 case blink::WebConsoleMessage::LevelError:
646 level = "ERROR"; 647 level = "ERROR";
647 break; 648 break;
648 default: 649 default:
649 level = "MESSAGE"; 650 level = "MESSAGE";
650 } 651 }
651 delegate_->PrintMessage(std::string("CONSOLE ") + level + ": "); 652 std::string prefix(std::string("CONSOLE ") + level + ": ");
652 if (source_line) { 653 if (source_line) {
653 delegate_->PrintMessage(base::StringPrintf("line %d: ", source_line)); 654 prefix += base::StringPrintf("line %d: ", source_line);
654 } 655 }
656 bool dump_to_stderr = test_runner()->is_web_platform_tests_mode();
655 if (!message.text.isEmpty()) { 657 if (!message.text.isEmpty()) {
656 std::string new_message; 658 std::string new_message;
657 new_message = message.text.utf8(); 659 new_message = message.text.utf8();
658 size_t file_protocol = new_message.find("file://"); 660 size_t file_protocol = new_message.find("file://");
659 if (file_protocol != std::string::npos) { 661 if (file_protocol != std::string::npos) {
660 new_message = new_message.substr(0, file_protocol) + 662 new_message = new_message.substr(0, file_protocol) +
661 URLSuitableForTestResult(new_message.substr(file_protocol)); 663 URLSuitableForTestResult(new_message.substr(file_protocol));
662 } 664 }
663 delegate_->PrintMessage(new_message); 665 for (auto piece : base::SplitStringPieceUsingSubstr(
666 new_message, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) {
667 if (dump_to_stderr) {
668 delegate_->PrintLogMessage(prefix + piece.as_string() + "\n");
669 } else {
670 delegate_->PrintMessage(prefix + piece.as_string() + "\n");
671 }
672 }
673 } else {
674 if (dump_to_stderr) {
675 delegate_->PrintLogMessage(prefix + "\n");
676 } else {
677 delegate_->PrintMessage(prefix + "\n");
678 }
664 } 679 }
665 delegate_->PrintMessage(std::string("\n"));
666 } 680 }
667 681
668 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( 682 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation(
669 const blink::WebFrameClient::NavigationPolicyInfo& info) { 683 const blink::WebFrameClient::NavigationPolicyInfo& info) {
670 // PlzNavigate 684 // PlzNavigate
671 // Navigation requests initiated by the renderer have checked navigation 685 // Navigation requests initiated by the renderer have checked navigation
672 // policy when the navigation was sent to the browser. Some layout tests 686 // policy when the navigation was sent to the browser. Some layout tests
673 // expect that navigation policy is only checked once. 687 // expect that navigation policy is only checked once.
674 if (delegate_->IsNavigationInitiatedByRenderer(info.urlRequest)) 688 if (delegate_->IsNavigationInitiatedByRenderer(info.urlRequest))
675 return info.defaultPolicy; 689 return info.defaultPolicy;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 blink::WebEffectiveConnectionType 747 blink::WebEffectiveConnectionType
734 WebFrameTestClient::getEffectiveConnectionType() { 748 WebFrameTestClient::getEffectiveConnectionType() {
735 return test_runner()->effective_connection_type(); 749 return test_runner()->effective_connection_type();
736 } 750 }
737 751
738 TestRunner* WebFrameTestClient::test_runner() { 752 TestRunner* WebFrameTestClient::test_runner() {
739 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner(); 753 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner();
740 } 754 }
741 755
742 } // namespace test_runner 756 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698