OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/layout_test/layout_test_devtools_bindings.h" | 5 #include "content/shell/browser/layout_test/layout_test_devtools_bindings.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 GURL result = | 51 GURL result = |
52 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html")); | 52 net::FilePathToFileURL(dev_tools_path.AppendASCII("inspector.html")); |
53 std::string url_string = | 53 std::string url_string = |
54 base::StringPrintf("%s?experiments=true", result.spec().c_str()); | 54 base::StringPrintf("%s?experiments=true", result.spec().c_str()); |
55 if (is_debug_dev_tools) | 55 if (is_debug_dev_tools) |
56 url_string += "&debugFrontend=true"; | 56 url_string += "&debugFrontend=true"; |
57 return GURL(url_string); | 57 return GURL(url_string); |
58 } | 58 } |
59 | 59 |
60 // static. | 60 // static. |
61 GURL LayoutTestDevToolsBindings::MapJSTestURL(const GURL& test_url) { | 61 GURL LayoutTestDevToolsBindings::MapIntegrationTestURL(const GURL& test_url) { |
62 return MapJSTestURL(test_url, "integration_test_runner.html"); | |
63 } | |
64 | |
65 // static. | |
66 GURL LayoutTestDevToolsBindings::MapUnitTestURL(const GURL& test_url) { | |
67 return MapJSTestURL(test_url, "unit_test_runner.html"); | |
68 } | |
69 | |
70 // static. | |
71 GURL LayoutTestDevToolsBindings::MapJSTestURL( | |
72 const GURL& test_url, | |
73 const std::string& entry_filename) { | |
62 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); | 74 std::string url_string = GetDevToolsPathAsURL(std::string()).spec(); |
63 std::string inspector_file_name = "inspector.html"; | 75 std::string inspector_file_name = "inspector.html"; |
64 size_t start_position = url_string.find(inspector_file_name); | 76 size_t start_position = url_string.find(inspector_file_name); |
65 url_string.replace(start_position, inspector_file_name.length(), | 77 url_string.replace(start_position, inspector_file_name.length(), |
66 "unit_test_runner.html"); | 78 entry_filename); |
67 url_string += "&test=" + test_url.spec(); | 79 url_string += "&test=" + test_url.spec(); |
68 return GURL(url_string); | 80 return GURL(url_string); |
69 } | 81 } |
70 | 82 |
71 // static | 83 // static |
72 LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools( | 84 LayoutTestDevToolsBindings* LayoutTestDevToolsBindings::LoadDevTools( |
73 WebContents* devtools_contents_, | 85 WebContents* devtools_contents_, |
74 WebContents* inspected_contents_, | 86 WebContents* inspected_contents_, |
75 const std::string& settings, | 87 const std::string& settings, |
76 const std::string& frontend_url) { | 88 const std::string& frontend_url) { |
77 LayoutTestDevToolsBindings* bindings = | 89 LayoutTestDevToolsBindings* bindings = |
78 new LayoutTestDevToolsBindings(devtools_contents_, inspected_contents_); | 90 new LayoutTestDevToolsBindings(devtools_contents_, inspected_contents_); |
79 bindings->SetPreferences(settings); | 91 bindings->SetPreferences(settings); |
92 bindings->CreateFrontendHost(devtools_contents_->GetMainFrame()); | |
dgozman
2017/04/25 21:08:28
I now think we can just remove this call. Could yo
chenwilliam
2017/06/15 01:01:05
Done.
| |
80 GURL devtools_url = | 93 GURL devtools_url = |
81 LayoutTestDevToolsBindings::GetDevToolsPathAsURL(frontend_url); | 94 LayoutTestDevToolsBindings::GetDevToolsPathAsURL(frontend_url); |
82 NavigationController::LoadURLParams params(devtools_url); | 95 NavigationController::LoadURLParams params(devtools_url); |
83 params.transition_type = ui::PageTransitionFromInt( | 96 params.transition_type = ui::PageTransitionFromInt( |
84 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 97 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
85 bindings->web_contents()->GetController().LoadURLWithParams(params); | 98 bindings->web_contents()->GetController().LoadURLWithParams(params); |
86 bindings->web_contents()->Focus(); | 99 bindings->web_contents()->Focus(); |
87 bindings->CreateFrontendHost(); | |
88 return bindings; | 100 return bindings; |
89 } | 101 } |
90 | 102 |
91 void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id, | 103 void LayoutTestDevToolsBindings::EvaluateInFrontend(int call_id, |
92 const std::string& script) { | 104 const std::string& script) { |
93 if (!ready_for_test_) { | 105 if (!ready_for_test_) { |
94 pending_evaluations_.push_back(std::make_pair(call_id, script)); | 106 pending_evaluations_.push_back(std::make_pair(call_id, script)); |
95 return; | 107 return; |
96 } | 108 } |
97 | 109 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 base::TerminationStatus status) { | 145 base::TerminationStatus status) { |
134 BlinkTestController::Get()->DevToolsProcessCrashed(); | 146 BlinkTestController::Get()->DevToolsProcessCrashed(); |
135 } | 147 } |
136 | 148 |
137 void LayoutTestDevToolsBindings::RenderFrameCreated( | 149 void LayoutTestDevToolsBindings::RenderFrameCreated( |
138 RenderFrameHost* render_frame_host) { | 150 RenderFrameHost* render_frame_host) { |
139 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); | 151 BlinkTestController::Get()->HandleNewRenderFrameHost(render_frame_host); |
140 } | 152 } |
141 | 153 |
142 } // namespace content | 154 } // namespace content |
OLD | NEW |