| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/layout_test/blink_test_runner.h" | 5 #include "content/shell/renderer/layout_test/blink_test_runner.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <clocale> | 9 #include <clocale> |
| 10 #include <cmath> | 10 #include <cmath> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/base64.h" | 13 #include "base/base64.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/debug/debugger.h" | 16 #include "base/debug/debugger.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/location.h" | 18 #include "base/location.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/md5.h" | 20 #include "base/md5.h" |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 25 #include "base/strings/sys_string_conversions.h" | 25 #include "base/strings/sys_string_conversions.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/thread_task_runner_handle.h" | 27 #include "base/thread_task_runner_handle.h" |
| 28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 29 #include "base/values.h" |
| 29 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 30 #include "components/plugins/renderer/plugin_placeholder.h" | 31 #include "components/plugins/renderer/plugin_placeholder.h" |
| 31 #include "components/test_runner/app_banner_client.h" | 32 #include "components/test_runner/app_banner_client.h" |
| 32 #include "components/test_runner/gamepad_controller.h" | 33 #include "components/test_runner/gamepad_controller.h" |
| 33 #include "components/test_runner/layout_dump.h" | 34 #include "components/test_runner/layout_dump.h" |
| 34 #include "components/test_runner/layout_dump_flags.h" | 35 #include "components/test_runner/layout_dump_flags.h" |
| 35 #include "components/test_runner/mock_screen_orientation_client.h" | 36 #include "components/test_runner/mock_screen_orientation_client.h" |
| 36 #include "components/test_runner/test_interfaces.h" | 37 #include "components/test_runner/test_interfaces.h" |
| 38 #include "components/test_runner/tracked_dictionary.h" |
| 37 #include "components/test_runner/web_task.h" | 39 #include "components/test_runner/web_task.h" |
| 38 #include "components/test_runner/web_test_interfaces.h" | 40 #include "components/test_runner/web_test_interfaces.h" |
| 39 #include "components/test_runner/web_test_proxy.h" | 41 #include "components/test_runner/web_test_proxy.h" |
| 40 #include "components/test_runner/web_test_runner.h" | 42 #include "components/test_runner/web_test_runner.h" |
| 41 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 42 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
| 43 #include "content/public/common/web_preferences.h" | 45 #include "content/public/common/web_preferences.h" |
| 44 #include "content/public/renderer/media_stream_api.h" | 46 #include "content/public/renderer/media_stream_api.h" |
| 45 #include "content/public/renderer/render_frame.h" | 47 #include "content/public/renderer/render_frame.h" |
| 46 #include "content/public/renderer/render_view.h" | 48 #include "content/public/renderer/render_view.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 #include "third_party/WebKit/public/platform/WebURLError.h" | 73 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 72 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 74 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 73 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 75 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 74 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" | 76 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerProm
ptReply.h" |
| 75 #include "third_party/WebKit/public/web/WebArrayBufferView.h" | 77 #include "third_party/WebKit/public/web/WebArrayBufferView.h" |
| 76 #include "third_party/WebKit/public/web/WebContextMenuData.h" | 78 #include "third_party/WebKit/public/web/WebContextMenuData.h" |
| 77 #include "third_party/WebKit/public/web/WebDataSource.h" | 79 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 78 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" | 80 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" |
| 79 #include "third_party/WebKit/public/web/WebDocument.h" | 81 #include "third_party/WebKit/public/web/WebDocument.h" |
| 80 #include "third_party/WebKit/public/web/WebElement.h" | 82 #include "third_party/WebKit/public/web/WebElement.h" |
| 83 #include "third_party/WebKit/public/web/WebFrame.h" |
| 81 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 84 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
| 82 #include "third_party/WebKit/public/web/WebKit.h" | 85 #include "third_party/WebKit/public/web/WebKit.h" |
| 83 #include "third_party/WebKit/public/web/WebLeakDetector.h" | 86 #include "third_party/WebKit/public/web/WebLeakDetector.h" |
| 84 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 87 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 85 #include "third_party/WebKit/public/web/WebScriptSource.h" | 88 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 86 #include "third_party/WebKit/public/web/WebTestingSupport.h" | 89 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
| 87 #include "third_party/WebKit/public/web/WebView.h" | 90 #include "third_party/WebKit/public/web/WebView.h" |
| 88 #include "ui/gfx/geometry/rect.h" | 91 #include "ui/gfx/geometry/rect.h" |
| 89 | 92 |
| 90 using blink::Platform; | 93 using blink::Platform; |
| 91 using blink::WebArrayBufferView; | 94 using blink::WebArrayBufferView; |
| 92 using blink::WebContextMenuData; | 95 using blink::WebContextMenuData; |
| 93 using blink::WebDevToolsAgent; | 96 using blink::WebDevToolsAgent; |
| 94 using blink::WebDeviceMotionData; | 97 using blink::WebDeviceMotionData; |
| 95 using blink::WebDeviceOrientationData; | 98 using blink::WebDeviceOrientationData; |
| 96 using blink::WebElement; | 99 using blink::WebElement; |
| 97 using blink::WebLocalFrame; | 100 using blink::WebLocalFrame; |
| 98 using blink::WebHistoryItem; | 101 using blink::WebHistoryItem; |
| 102 using blink::WebFrame; |
| 99 using blink::WebLocalFrame; | 103 using blink::WebLocalFrame; |
| 100 using blink::WebPoint; | 104 using blink::WebPoint; |
| 101 using blink::WebRect; | 105 using blink::WebRect; |
| 102 using blink::WebScriptSource; | 106 using blink::WebScriptSource; |
| 103 using blink::WebSize; | 107 using blink::WebSize; |
| 104 using blink::WebString; | 108 using blink::WebString; |
| 105 using blink::WebURL; | 109 using blink::WebURL; |
| 106 using blink::WebURLError; | 110 using blink::WebURLError; |
| 107 using blink::WebURLRequest; | 111 using blink::WebURLRequest; |
| 108 using blink::WebScreenOrientationType; | 112 using blink::WebScreenOrientationType; |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 result = result.substr(0, strlen("file:///")) + | 607 result = result.substr(0, strlen("file:///")) + |
| 604 result.substr(strlen("file:////")); | 608 result.substr(strlen("file:////")); |
| 605 } | 609 } |
| 606 return RewriteLayoutTestsURL(result).string().utf8(); | 610 return RewriteLayoutTestsURL(result).string().utf8(); |
| 607 } | 611 } |
| 608 | 612 |
| 609 void BlinkTestRunner::SetLocale(const std::string& locale) { | 613 void BlinkTestRunner::SetLocale(const std::string& locale) { |
| 610 setlocale(LC_ALL, locale.c_str()); | 614 setlocale(LC_ALL, locale.c_str()); |
| 611 } | 615 } |
| 612 | 616 |
| 617 void BlinkTestRunner::OnLayoutDumpFlagsChanged( |
| 618 const base::DictionaryValue& changed_values) { |
| 619 // Ignore changes that happen before we got the initial, accumulated |
| 620 // layout flag changes in ShellViewMsg_ReplicateTestConfiguration. |
| 621 if (!is_main_window_) |
| 622 return; |
| 623 |
| 624 // Message needs to be send via a local frame to eventually reach |
| 625 // WebContentsObserver via OnMessage(..., RenderFrameHost*) overload - this |
| 626 // lets BlinkTestController figure out the originator of the message. |
| 627 RenderFrame* local_frame = nullptr; |
| 628 for (WebFrame* frame = render_view()->GetWebView()->mainFrame(); frame; |
| 629 frame = frame->traverseNext(false)) { |
| 630 if (frame->isWebLocalFrame()) { |
| 631 local_frame = RenderFrame::FromWebFrame(frame); |
| 632 break; |
| 633 } |
| 634 } |
| 635 DCHECK(local_frame); |
| 636 Send(new ShellViewHostMsg_LayoutDumpFlagsChanged(local_frame->GetRoutingID(), |
| 637 changed_values)); |
| 638 } |
| 639 |
| 613 void BlinkTestRunner::TestFinished() { | 640 void BlinkTestRunner::TestFinished() { |
| 614 if (!is_main_window_ || !render_view()->GetMainRenderFrame()) { | 641 if (!is_main_window_ || !render_view()->GetMainRenderFrame()) { |
| 615 Send(new ShellViewHostMsg_TestFinishedInSecondaryRenderer(routing_id())); | 642 Send(new ShellViewHostMsg_TestFinishedInSecondaryRenderer(routing_id())); |
| 616 return; | 643 return; |
| 617 } | 644 } |
| 618 test_runner::WebTestInterfaces* interfaces = | 645 test_runner::WebTestInterfaces* interfaces = |
| 619 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); | 646 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
| 620 interfaces->SetTestIsRunning(false); | 647 interfaces->SetTestIsRunning(false); |
| 621 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { | 648 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { |
| 622 SyncNavigationStateVisitor visitor; | 649 SyncNavigationStateVisitor visitor; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 923 |
| 897 const test_runner::LayoutDumpFlags& layout_dump_flags = | 924 const test_runner::LayoutDumpFlags& layout_dump_flags = |
| 898 interfaces->TestRunner()->GetLayoutDumpFlags(); | 925 interfaces->TestRunner()->GetLayoutDumpFlags(); |
| 899 if (!layout_dump_flags.dump_child_frames()) { | 926 if (!layout_dump_flags.dump_child_frames()) { |
| 900 std::string layout_dump = DumpLayout( | 927 std::string layout_dump = DumpLayout( |
| 901 render_view()->GetMainRenderFrame()->GetWebFrame(), layout_dump_flags); | 928 render_view()->GetMainRenderFrame()->GetWebFrame(), layout_dump_flags); |
| 902 OnLayoutDumpCompleted(layout_dump); | 929 OnLayoutDumpCompleted(layout_dump); |
| 903 return; | 930 return; |
| 904 } | 931 } |
| 905 | 932 |
| 906 Send( | 933 Send(new ShellViewHostMsg_InitiateLayoutDump(routing_id())); |
| 907 new ShellViewHostMsg_InitiateLayoutDump(routing_id(), layout_dump_flags)); | |
| 908 // OnLayoutDumpCompleted will be eventually called by an IPC from the browser. | 934 // OnLayoutDumpCompleted will be eventually called by an IPC from the browser. |
| 909 } | 935 } |
| 910 | 936 |
| 911 void BlinkTestRunner::OnLayoutDumpCompleted(std::string completed_layout_dump) { | 937 void BlinkTestRunner::OnLayoutDumpCompleted(std::string completed_layout_dump) { |
| 912 test_runner::WebTestInterfaces* interfaces = | 938 test_runner::WebTestInterfaces* interfaces = |
| 913 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); | 939 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
| 914 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { | 940 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { |
| 915 completed_layout_dump.append(proxy()->DumpBackForwardLists()); | 941 completed_layout_dump.append(proxy()->DumpBackForwardLists()); |
| 916 } | 942 } |
| 917 | 943 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 get_bluetooth_events_callbacks_.pop_front(); | 1066 get_bluetooth_events_callbacks_.pop_front(); |
| 1041 callback.Run(events); | 1067 callback.Run(events); |
| 1042 } | 1068 } |
| 1043 | 1069 |
| 1044 void BlinkTestRunner::ReportLeakDetectionResult( | 1070 void BlinkTestRunner::ReportLeakDetectionResult( |
| 1045 const LeakDetectionResult& report) { | 1071 const LeakDetectionResult& report) { |
| 1046 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 1072 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
| 1047 } | 1073 } |
| 1048 | 1074 |
| 1049 } // namespace content | 1075 } // namespace content |
| OLD | NEW |