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" |
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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 : mime_type.utf8().data()); | 623 : mime_type.utf8().data()); |
623 delegate_->PrintMessage("\n"); | 624 delegate_->PrintMessage("\n"); |
624 } | 625 } |
625 } | 626 } |
626 | 627 |
627 void WebFrameTestClient::didAddMessageToConsole( | 628 void WebFrameTestClient::didAddMessageToConsole( |
628 const blink::WebConsoleMessage& message, | 629 const blink::WebConsoleMessage& message, |
629 const blink::WebString& source_name, | 630 const blink::WebString& source_name, |
630 unsigned source_line, | 631 unsigned source_line, |
631 const blink::WebString& stack_trace) { | 632 const blink::WebString& stack_trace) { |
632 if (!test_runner()->ShouldDumpConsoleMessages()) | 633 if (!test_runner()->ShouldDumpConsoleMessages()) |
Rick Byers
2017/02/24 22:02:27
Wouldn't it be a lot simpler to just change the im
Dan Elphick
2017/02/27 11:03:06
Isn't this functionally equivalent to just calling
Rick Byers
2017/02/28 16:29:32
Ah, I'm sorry - I was lacking the context on the d
| |
633 return; | 634 return; |
634 std::string level; | 635 std::string level; |
635 switch (message.level) { | 636 switch (message.level) { |
636 case blink::WebConsoleMessage::LevelVerbose: | 637 case blink::WebConsoleMessage::LevelVerbose: |
637 level = "DEBUG"; | 638 level = "DEBUG"; |
638 break; | 639 break; |
639 case blink::WebConsoleMessage::LevelInfo: | 640 case blink::WebConsoleMessage::LevelInfo: |
640 level = "MESSAGE"; | 641 level = "MESSAGE"; |
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 } |
655 if (!message.text.isEmpty()) { | 656 if (!message.text.isEmpty()) { |
656 std::string new_message; | 657 std::string new_message; |
657 new_message = message.text.utf8(); | 658 new_message = message.text.utf8(); |
658 size_t file_protocol = new_message.find("file://"); | 659 size_t file_protocol = new_message.find("file://"); |
659 if (file_protocol != std::string::npos) { | 660 if (file_protocol != std::string::npos) { |
660 new_message = new_message.substr(0, file_protocol) + | 661 new_message = new_message.substr(0, file_protocol) + |
661 URLSuitableForTestResult(new_message.substr(file_protocol)); | 662 URLSuitableForTestResult(new_message.substr(file_protocol)); |
662 } | 663 } |
663 delegate_->PrintMessage(new_message); | 664 for (auto s : base::SplitStringPieceUsingSubstr( |
665 new_message, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
666 delegate_->PrintMessage(prefix); | |
667 delegate_->PrintMessage(s.as_string()); | |
668 delegate_->PrintMessage(std::string("\n")); | |
669 } | |
670 } else { | |
671 delegate_->PrintMessage(prefix + "\n"); | |
664 } | 672 } |
665 delegate_->PrintMessage(std::string("\n")); | |
666 } | 673 } |
667 | 674 |
668 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( | 675 blink::WebNavigationPolicy WebFrameTestClient::decidePolicyForNavigation( |
669 const blink::WebFrameClient::NavigationPolicyInfo& info) { | 676 const blink::WebFrameClient::NavigationPolicyInfo& info) { |
670 // PlzNavigate | 677 // PlzNavigate |
671 // Navigation requests initiated by the renderer have checked navigation | 678 // Navigation requests initiated by the renderer have checked navigation |
672 // policy when the navigation was sent to the browser. Some layout tests | 679 // policy when the navigation was sent to the browser. Some layout tests |
673 // expect that navigation policy is only checked once. | 680 // expect that navigation policy is only checked once. |
674 if (delegate_->IsNavigationInitiatedByRenderer(info.urlRequest)) | 681 if (delegate_->IsNavigationInitiatedByRenderer(info.urlRequest)) |
675 return info.defaultPolicy; | 682 return info.defaultPolicy; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 blink::WebEffectiveConnectionType | 740 blink::WebEffectiveConnectionType |
734 WebFrameTestClient::getEffectiveConnectionType() { | 741 WebFrameTestClient::getEffectiveConnectionType() { |
735 return test_runner()->effective_connection_type(); | 742 return test_runner()->effective_connection_type(); |
736 } | 743 } |
737 | 744 |
738 TestRunner* WebFrameTestClient::test_runner() { | 745 TestRunner* WebFrameTestClient::test_runner() { |
739 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner(); | 746 return web_view_test_proxy_base_->test_interfaces()->GetTestRunner(); |
740 } | 747 } |
741 | 748 |
742 } // namespace test_runner | 749 } // namespace test_runner |
OLD | NEW |