OLD | NEW |
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" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 break; | 641 break; |
642 case blink::WebConsoleMessage::LevelWarning: | 642 case blink::WebConsoleMessage::LevelWarning: |
643 level = "WARNING"; | 643 level = "WARNING"; |
644 break; | 644 break; |
645 case blink::WebConsoleMessage::LevelError: | 645 case blink::WebConsoleMessage::LevelError: |
646 level = "ERROR"; | 646 level = "ERROR"; |
647 break; | 647 break; |
648 default: | 648 default: |
649 level = "MESSAGE"; | 649 level = "MESSAGE"; |
650 } | 650 } |
651 delegate_->PrintMessage(std::string("CONSOLE ") + level + ": "); | 651 std::string console_message(std::string("CONSOLE ") + level + ": "); |
652 if (source_line) { | 652 if (source_line) { |
653 delegate_->PrintMessage(base::StringPrintf("line %d: ", source_line)); | 653 console_message += base::StringPrintf("line %d: ", source_line); |
654 } | 654 } |
| 655 // Console messages shouldn't be included in the expected output for |
| 656 // web-platform-tests because they may create non-determinism not |
| 657 // intended by the test author. They are still included in the stderr |
| 658 // output for debug purposes. |
| 659 bool dump_to_stderr = test_runner()->is_web_platform_tests_mode(); |
655 if (!message.text.isEmpty()) { | 660 if (!message.text.isEmpty()) { |
656 std::string new_message; | 661 std::string new_message; |
657 new_message = message.text.utf8(); | 662 new_message = message.text.utf8(); |
658 size_t file_protocol = new_message.find("file://"); | 663 size_t file_protocol = new_message.find("file://"); |
659 if (file_protocol != std::string::npos) { | 664 if (file_protocol != std::string::npos) { |
660 new_message = new_message.substr(0, file_protocol) + | 665 new_message = new_message.substr(0, file_protocol) + |
661 URLSuitableForTestResult(new_message.substr(file_protocol)); | 666 URLSuitableForTestResult(new_message.substr(file_protocol)); |
662 } | 667 } |
663 delegate_->PrintMessage(new_message); | 668 console_message += new_message; |
664 } | 669 } |
665 delegate_->PrintMessage(std::string("\n")); | 670 console_message += "\n"; |
| 671 |
| 672 if (dump_to_stderr) { |
| 673 delegate_->PrintMessageToStderr(console_message); |
| 674 } else { |
| 675 delegate_->PrintMessage(console_message); |
| 676 } |
666 } | 677 } |
667 | 678 |
668 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( | 679 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( |
669 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 680 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
670 // PlzNavigate | 681 // PlzNavigate |
671 // Navigation requests initiated by the renderer have checked navigation | 682 // Navigation requests initiated by the renderer have checked navigation |
672 // policy when the navigation was sent to the browser. Some layout tests | 683 // policy when the navigation was sent to the browser. Some layout tests |
673 // expect that navigation policy is only checked once. | 684 // expect that navigation policy is only checked once. |
674 if (delegate_->IsNavigationInitiatedByRenderer(info.urlRequest)) | 685 if (delegate_->IsNavigationInitiatedByRenderer(info.urlRequest)) |
675 return info.defaultPolicy; | 686 return info.defaultPolicy; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 blink::WebEffectiveConnectionType | 744 blink::WebEffectiveConnectionType |
734 WebFrameTestClient::getEffectiveConnectionType() { | 745 WebFrameTestClient::getEffectiveConnectionType() { |
735 return test_runner()->effective_connection_type(); | 746 return test_runner()->effective_connection_type(); |
736 } | 747 } |
737 | 748 |
738 TestRunner* WebFrameTestClient::test_runner() { | 749 TestRunner* WebFrameTestClient::test_runner() { |
739 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner(); | 750 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner(); |
740 } | 751 } |
741 | 752 |
742 } // namespace test_runner | 753 } // namespace test_runner |
OLD | NEW |