1 | /* |
2 | * Copyright (C) 2013 Google Inc. All rights reserved. |
3 | * Copyright (C) 2013-2016 Apple Inc. All rights reserved. |
4 | * Copyright (C) 2014 University of Washington. All rights reserved. |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
19 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | * THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | // DO NOT EDIT THIS FILE. It is automatically generated from Automation.json |
29 | // by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py |
30 | |
31 | #include "config.h" |
32 | #include "AutomationBackendDispatchers.h" |
33 | |
34 | #include <JavaScriptCore/InspectorFrontendRouter.h> |
35 | #include <wtf/JSONValues.h> |
36 | #include <wtf/NeverDestroyed.h> |
37 | #include <wtf/text/CString.h> |
38 | |
39 | namespace Inspector { |
40 | |
41 | AutomationBackendDispatcherHandler::~AutomationBackendDispatcherHandler() { } |
42 | |
43 | Ref<AutomationBackendDispatcher> AutomationBackendDispatcher::create(BackendDispatcher& backendDispatcher, AutomationBackendDispatcherHandler* agent) |
44 | { |
45 | return adoptRef(*new AutomationBackendDispatcher(backendDispatcher, agent)); |
46 | } |
47 | |
48 | AutomationBackendDispatcher::AutomationBackendDispatcher(BackendDispatcher& backendDispatcher, AutomationBackendDispatcherHandler* agent) |
49 | : SupplementalBackendDispatcher(backendDispatcher) |
50 | , m_agent(agent) |
51 | { |
52 | m_backendDispatcher->registerDispatcherForDomain("Automation"_s , this); |
53 | } |
54 | |
55 | void AutomationBackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) |
56 | { |
57 | Ref<AutomationBackendDispatcher> protect(*this); |
58 | |
59 | RefPtr<JSON::Object> parameters; |
60 | message->getObject("params"_s , parameters); |
61 | |
62 | typedef void (AutomationBackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message); |
63 | typedef HashMap<String, CallHandler> DispatchMap; |
64 | static NeverDestroyed<DispatchMap> dispatchMap; |
65 | if (dispatchMap.get().isEmpty()) { |
66 | static const struct MethodTable { |
67 | const char* name; |
68 | CallHandler handler; |
69 | } commands[] = { |
70 | { "getBrowsingContexts" , &AutomationBackendDispatcher::getBrowsingContexts }, |
71 | { "getBrowsingContext" , &AutomationBackendDispatcher::getBrowsingContext }, |
72 | { "createBrowsingContext" , &AutomationBackendDispatcher::createBrowsingContext }, |
73 | { "closeBrowsingContext" , &AutomationBackendDispatcher::closeBrowsingContext }, |
74 | { "switchToBrowsingContext" , &AutomationBackendDispatcher::switchToBrowsingContext }, |
75 | { "setWindowFrameOfBrowsingContext" , &AutomationBackendDispatcher::setWindowFrameOfBrowsingContext }, |
76 | { "maximizeWindowOfBrowsingContext" , &AutomationBackendDispatcher::maximizeWindowOfBrowsingContext }, |
77 | { "hideWindowOfBrowsingContext" , &AutomationBackendDispatcher::hideWindowOfBrowsingContext }, |
78 | { "navigateBrowsingContext" , &AutomationBackendDispatcher::navigateBrowsingContext }, |
79 | { "goBackInBrowsingContext" , &AutomationBackendDispatcher::goBackInBrowsingContext }, |
80 | { "goForwardInBrowsingContext" , &AutomationBackendDispatcher::goForwardInBrowsingContext }, |
81 | { "reloadBrowsingContext" , &AutomationBackendDispatcher::reloadBrowsingContext }, |
82 | { "waitForNavigationToComplete" , &AutomationBackendDispatcher::waitForNavigationToComplete }, |
83 | { "evaluateJavaScriptFunction" , &AutomationBackendDispatcher::evaluateJavaScriptFunction }, |
84 | { "performMouseInteraction" , &AutomationBackendDispatcher::performMouseInteraction }, |
85 | { "performKeyboardInteractions" , &AutomationBackendDispatcher::performKeyboardInteractions }, |
86 | { "performInteractionSequence" , &AutomationBackendDispatcher::performInteractionSequence }, |
87 | { "cancelInteractionSequence" , &AutomationBackendDispatcher::cancelInteractionSequence }, |
88 | { "takeScreenshot" , &AutomationBackendDispatcher::takeScreenshot }, |
89 | { "resolveChildFrameHandle" , &AutomationBackendDispatcher::resolveChildFrameHandle }, |
90 | { "resolveParentFrameHandle" , &AutomationBackendDispatcher::resolveParentFrameHandle }, |
91 | { "computeElementLayout" , &AutomationBackendDispatcher::computeElementLayout }, |
92 | { "selectOptionElement" , &AutomationBackendDispatcher::selectOptionElement }, |
93 | { "isShowingJavaScriptDialog" , &AutomationBackendDispatcher::isShowingJavaScriptDialog }, |
94 | { "dismissCurrentJavaScriptDialog" , &AutomationBackendDispatcher::dismissCurrentJavaScriptDialog }, |
95 | { "acceptCurrentJavaScriptDialog" , &AutomationBackendDispatcher::acceptCurrentJavaScriptDialog }, |
96 | { "messageOfCurrentJavaScriptDialog" , &AutomationBackendDispatcher::messageOfCurrentJavaScriptDialog }, |
97 | { "setUserInputForCurrentJavaScriptPrompt" , &AutomationBackendDispatcher::setUserInputForCurrentJavaScriptPrompt }, |
98 | { "setFilesToSelectForFileUpload" , &AutomationBackendDispatcher::setFilesToSelectForFileUpload }, |
99 | { "getAllCookies" , &AutomationBackendDispatcher::getAllCookies }, |
100 | { "deleteSingleCookie" , &AutomationBackendDispatcher::deleteSingleCookie }, |
101 | { "addSingleCookie" , &AutomationBackendDispatcher::addSingleCookie }, |
102 | { "deleteAllCookies" , &AutomationBackendDispatcher::deleteAllCookies }, |
103 | { "getSessionPermissions" , &AutomationBackendDispatcher::getSessionPermissions }, |
104 | { "setSessionPermissions" , &AutomationBackendDispatcher::setSessionPermissions }, |
105 | }; |
106 | size_t length = WTF_ARRAY_LENGTH(commands); |
107 | for (size_t i = 0; i < length; ++i) |
108 | dispatchMap.get().add(commands[i].name, commands[i].handler); |
109 | } |
110 | |
111 | auto findResult = dispatchMap.get().find(method); |
112 | if (findResult == dispatchMap.get().end()) { |
113 | m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'Automation." + method + "' was not found" ); |
114 | return; |
115 | } |
116 | |
117 | ((*this).*findResult->value)(requestId, WTFMove(parameters)); |
118 | } |
119 | |
120 | AutomationBackendDispatcherHandler::GetBrowsingContextsCallback::GetBrowsingContextsCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
121 | |
122 | void AutomationBackendDispatcherHandler::GetBrowsingContextsCallback::sendSuccess(RefPtr<JSON::ArrayOf<Inspector::Protocol::Automation::BrowsingContext>>&& contexts) |
123 | { |
124 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
125 | jsonMessage->setArray("contexts"_s , contexts); |
126 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
127 | } |
128 | |
129 | void AutomationBackendDispatcher::getBrowsingContexts(long requestId, RefPtr<JSON::Object>&&) |
130 | { |
131 | Ref<AutomationBackendDispatcherHandler::GetBrowsingContextsCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::GetBrowsingContextsCallback(m_backendDispatcher.copyRef(), requestId)); |
132 | m_agent->getBrowsingContexts(callback.copyRef()); |
133 | |
134 | } |
135 | |
136 | AutomationBackendDispatcherHandler::GetBrowsingContextCallback::GetBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
137 | |
138 | void AutomationBackendDispatcherHandler::GetBrowsingContextCallback::sendSuccess(RefPtr<Inspector::Protocol::Automation::BrowsingContext>&& context) |
139 | { |
140 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
141 | jsonMessage->setObject("context"_s , context); |
142 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
143 | } |
144 | |
145 | void AutomationBackendDispatcher::getBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
146 | { |
147 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
148 | if (m_backendDispatcher->hasProtocolErrors()) { |
149 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.getBrowsingContext' can't be processed"_s ); |
150 | return; |
151 | } |
152 | |
153 | Ref<AutomationBackendDispatcherHandler::GetBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::GetBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
154 | m_agent->getBrowsingContext(in_handle, callback.copyRef()); |
155 | |
156 | } |
157 | |
158 | AutomationBackendDispatcherHandler::CreateBrowsingContextCallback::CreateBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
159 | |
160 | void AutomationBackendDispatcherHandler::CreateBrowsingContextCallback::sendSuccess(const String& handle, Inspector::Protocol::Automation::BrowsingContextPresentation presentation) |
161 | { |
162 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
163 | jsonMessage->setString("handle"_s , handle); |
164 | jsonMessage->setString("presentation"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(presentation)); |
165 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
166 | } |
167 | |
168 | void AutomationBackendDispatcher::createBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
169 | { |
170 | bool opt_in_presentationHint_valueFound = false; |
171 | String opt_in_presentationHint = m_backendDispatcher->getString(parameters.get(), "presentationHint"_s , &opt_in_presentationHint_valueFound); |
172 | if (m_backendDispatcher->hasProtocolErrors()) { |
173 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.createBrowsingContext' can't be processed"_s ); |
174 | return; |
175 | } |
176 | |
177 | Ref<AutomationBackendDispatcherHandler::CreateBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::CreateBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
178 | m_agent->createBrowsingContext(opt_in_presentationHint_valueFound ? &opt_in_presentationHint : nullptr, callback.copyRef()); |
179 | |
180 | } |
181 | |
182 | void AutomationBackendDispatcher::closeBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
183 | { |
184 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
185 | if (m_backendDispatcher->hasProtocolErrors()) { |
186 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.closeBrowsingContext' can't be processed"_s ); |
187 | return; |
188 | } |
189 | |
190 | ErrorString error; |
191 | Ref<JSON::Object> result = JSON::Object::create(); |
192 | m_agent->closeBrowsingContext(error, in_handle); |
193 | |
194 | if (!error.length()) |
195 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
196 | else |
197 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
198 | } |
199 | |
200 | AutomationBackendDispatcherHandler::SwitchToBrowsingContextCallback::SwitchToBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
201 | |
202 | void AutomationBackendDispatcherHandler::SwitchToBrowsingContextCallback::sendSuccess() |
203 | { |
204 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
205 | |
206 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
207 | } |
208 | |
209 | void AutomationBackendDispatcher::switchToBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
210 | { |
211 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
212 | bool opt_in_frameHandle_valueFound = false; |
213 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
214 | if (m_backendDispatcher->hasProtocolErrors()) { |
215 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.switchToBrowsingContext' can't be processed"_s ); |
216 | return; |
217 | } |
218 | |
219 | Ref<AutomationBackendDispatcherHandler::SwitchToBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::SwitchToBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
220 | m_agent->switchToBrowsingContext(in_browsingContextHandle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, callback.copyRef()); |
221 | |
222 | } |
223 | |
224 | AutomationBackendDispatcherHandler::SetWindowFrameOfBrowsingContextCallback::SetWindowFrameOfBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
225 | |
226 | void AutomationBackendDispatcherHandler::SetWindowFrameOfBrowsingContextCallback::sendSuccess() |
227 | { |
228 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
229 | |
230 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
231 | } |
232 | |
233 | void AutomationBackendDispatcher::setWindowFrameOfBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
234 | { |
235 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
236 | bool opt_in_origin_valueFound = false; |
237 | RefPtr<JSON::Object> opt_in_origin = m_backendDispatcher->getObject(parameters.get(), "origin"_s , &opt_in_origin_valueFound); |
238 | bool opt_in_size_valueFound = false; |
239 | RefPtr<JSON::Object> opt_in_size = m_backendDispatcher->getObject(parameters.get(), "size"_s , &opt_in_size_valueFound); |
240 | if (m_backendDispatcher->hasProtocolErrors()) { |
241 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.setWindowFrameOfBrowsingContext' can't be processed"_s ); |
242 | return; |
243 | } |
244 | |
245 | Ref<AutomationBackendDispatcherHandler::SetWindowFrameOfBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::SetWindowFrameOfBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
246 | m_agent->setWindowFrameOfBrowsingContext(in_handle, opt_in_origin_valueFound ? opt_in_origin.get() : nullptr, opt_in_size_valueFound ? opt_in_size.get() : nullptr, callback.copyRef()); |
247 | |
248 | } |
249 | |
250 | AutomationBackendDispatcherHandler::MaximizeWindowOfBrowsingContextCallback::MaximizeWindowOfBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
251 | |
252 | void AutomationBackendDispatcherHandler::MaximizeWindowOfBrowsingContextCallback::sendSuccess() |
253 | { |
254 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
255 | |
256 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
257 | } |
258 | |
259 | void AutomationBackendDispatcher::maximizeWindowOfBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
260 | { |
261 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
262 | if (m_backendDispatcher->hasProtocolErrors()) { |
263 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.maximizeWindowOfBrowsingContext' can't be processed"_s ); |
264 | return; |
265 | } |
266 | |
267 | Ref<AutomationBackendDispatcherHandler::MaximizeWindowOfBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::MaximizeWindowOfBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
268 | m_agent->maximizeWindowOfBrowsingContext(in_handle, callback.copyRef()); |
269 | |
270 | } |
271 | |
272 | AutomationBackendDispatcherHandler::HideWindowOfBrowsingContextCallback::HideWindowOfBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
273 | |
274 | void AutomationBackendDispatcherHandler::HideWindowOfBrowsingContextCallback::sendSuccess() |
275 | { |
276 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
277 | |
278 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
279 | } |
280 | |
281 | void AutomationBackendDispatcher::hideWindowOfBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
282 | { |
283 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
284 | if (m_backendDispatcher->hasProtocolErrors()) { |
285 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.hideWindowOfBrowsingContext' can't be processed"_s ); |
286 | return; |
287 | } |
288 | |
289 | Ref<AutomationBackendDispatcherHandler::HideWindowOfBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::HideWindowOfBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
290 | m_agent->hideWindowOfBrowsingContext(in_handle, callback.copyRef()); |
291 | |
292 | } |
293 | |
294 | AutomationBackendDispatcherHandler::NavigateBrowsingContextCallback::NavigateBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
295 | |
296 | void AutomationBackendDispatcherHandler::NavigateBrowsingContextCallback::sendSuccess() |
297 | { |
298 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
299 | |
300 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
301 | } |
302 | |
303 | void AutomationBackendDispatcher::navigateBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
304 | { |
305 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
306 | String in_url = m_backendDispatcher->getString(parameters.get(), "url"_s , nullptr); |
307 | bool opt_in_pageLoadStrategy_valueFound = false; |
308 | String opt_in_pageLoadStrategy = m_backendDispatcher->getString(parameters.get(), "pageLoadStrategy"_s , &opt_in_pageLoadStrategy_valueFound); |
309 | bool opt_in_pageLoadTimeout_valueFound = false; |
310 | int opt_in_pageLoadTimeout = m_backendDispatcher->getInteger(parameters.get(), "pageLoadTimeout"_s , &opt_in_pageLoadTimeout_valueFound); |
311 | if (m_backendDispatcher->hasProtocolErrors()) { |
312 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.navigateBrowsingContext' can't be processed"_s ); |
313 | return; |
314 | } |
315 | |
316 | Ref<AutomationBackendDispatcherHandler::NavigateBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::NavigateBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
317 | m_agent->navigateBrowsingContext(in_handle, in_url, opt_in_pageLoadStrategy_valueFound ? &opt_in_pageLoadStrategy : nullptr, opt_in_pageLoadTimeout_valueFound ? &opt_in_pageLoadTimeout : nullptr, callback.copyRef()); |
318 | |
319 | } |
320 | |
321 | AutomationBackendDispatcherHandler::GoBackInBrowsingContextCallback::GoBackInBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
322 | |
323 | void AutomationBackendDispatcherHandler::GoBackInBrowsingContextCallback::sendSuccess() |
324 | { |
325 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
326 | |
327 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
328 | } |
329 | |
330 | void AutomationBackendDispatcher::goBackInBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
331 | { |
332 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
333 | bool opt_in_pageLoadStrategy_valueFound = false; |
334 | String opt_in_pageLoadStrategy = m_backendDispatcher->getString(parameters.get(), "pageLoadStrategy"_s , &opt_in_pageLoadStrategy_valueFound); |
335 | bool opt_in_pageLoadTimeout_valueFound = false; |
336 | int opt_in_pageLoadTimeout = m_backendDispatcher->getInteger(parameters.get(), "pageLoadTimeout"_s , &opt_in_pageLoadTimeout_valueFound); |
337 | if (m_backendDispatcher->hasProtocolErrors()) { |
338 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.goBackInBrowsingContext' can't be processed"_s ); |
339 | return; |
340 | } |
341 | |
342 | Ref<AutomationBackendDispatcherHandler::GoBackInBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::GoBackInBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
343 | m_agent->goBackInBrowsingContext(in_handle, opt_in_pageLoadStrategy_valueFound ? &opt_in_pageLoadStrategy : nullptr, opt_in_pageLoadTimeout_valueFound ? &opt_in_pageLoadTimeout : nullptr, callback.copyRef()); |
344 | |
345 | } |
346 | |
347 | AutomationBackendDispatcherHandler::GoForwardInBrowsingContextCallback::GoForwardInBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
348 | |
349 | void AutomationBackendDispatcherHandler::GoForwardInBrowsingContextCallback::sendSuccess() |
350 | { |
351 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
352 | |
353 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
354 | } |
355 | |
356 | void AutomationBackendDispatcher::goForwardInBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
357 | { |
358 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
359 | bool opt_in_pageLoadStrategy_valueFound = false; |
360 | String opt_in_pageLoadStrategy = m_backendDispatcher->getString(parameters.get(), "pageLoadStrategy"_s , &opt_in_pageLoadStrategy_valueFound); |
361 | bool opt_in_pageLoadTimeout_valueFound = false; |
362 | int opt_in_pageLoadTimeout = m_backendDispatcher->getInteger(parameters.get(), "pageLoadTimeout"_s , &opt_in_pageLoadTimeout_valueFound); |
363 | if (m_backendDispatcher->hasProtocolErrors()) { |
364 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.goForwardInBrowsingContext' can't be processed"_s ); |
365 | return; |
366 | } |
367 | |
368 | Ref<AutomationBackendDispatcherHandler::GoForwardInBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::GoForwardInBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
369 | m_agent->goForwardInBrowsingContext(in_handle, opt_in_pageLoadStrategy_valueFound ? &opt_in_pageLoadStrategy : nullptr, opt_in_pageLoadTimeout_valueFound ? &opt_in_pageLoadTimeout : nullptr, callback.copyRef()); |
370 | |
371 | } |
372 | |
373 | AutomationBackendDispatcherHandler::ReloadBrowsingContextCallback::ReloadBrowsingContextCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
374 | |
375 | void AutomationBackendDispatcherHandler::ReloadBrowsingContextCallback::sendSuccess() |
376 | { |
377 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
378 | |
379 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
380 | } |
381 | |
382 | void AutomationBackendDispatcher::reloadBrowsingContext(long requestId, RefPtr<JSON::Object>&& parameters) |
383 | { |
384 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
385 | bool opt_in_pageLoadStrategy_valueFound = false; |
386 | String opt_in_pageLoadStrategy = m_backendDispatcher->getString(parameters.get(), "pageLoadStrategy"_s , &opt_in_pageLoadStrategy_valueFound); |
387 | bool opt_in_pageLoadTimeout_valueFound = false; |
388 | int opt_in_pageLoadTimeout = m_backendDispatcher->getInteger(parameters.get(), "pageLoadTimeout"_s , &opt_in_pageLoadTimeout_valueFound); |
389 | if (m_backendDispatcher->hasProtocolErrors()) { |
390 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.reloadBrowsingContext' can't be processed"_s ); |
391 | return; |
392 | } |
393 | |
394 | Ref<AutomationBackendDispatcherHandler::ReloadBrowsingContextCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::ReloadBrowsingContextCallback(m_backendDispatcher.copyRef(), requestId)); |
395 | m_agent->reloadBrowsingContext(in_handle, opt_in_pageLoadStrategy_valueFound ? &opt_in_pageLoadStrategy : nullptr, opt_in_pageLoadTimeout_valueFound ? &opt_in_pageLoadTimeout : nullptr, callback.copyRef()); |
396 | |
397 | } |
398 | |
399 | AutomationBackendDispatcherHandler::WaitForNavigationToCompleteCallback::WaitForNavigationToCompleteCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
400 | |
401 | void AutomationBackendDispatcherHandler::WaitForNavigationToCompleteCallback::sendSuccess() |
402 | { |
403 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
404 | |
405 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
406 | } |
407 | |
408 | void AutomationBackendDispatcher::waitForNavigationToComplete(long requestId, RefPtr<JSON::Object>&& parameters) |
409 | { |
410 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
411 | bool opt_in_frameHandle_valueFound = false; |
412 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
413 | bool opt_in_pageLoadStrategy_valueFound = false; |
414 | String opt_in_pageLoadStrategy = m_backendDispatcher->getString(parameters.get(), "pageLoadStrategy"_s , &opt_in_pageLoadStrategy_valueFound); |
415 | bool opt_in_pageLoadTimeout_valueFound = false; |
416 | int opt_in_pageLoadTimeout = m_backendDispatcher->getInteger(parameters.get(), "pageLoadTimeout"_s , &opt_in_pageLoadTimeout_valueFound); |
417 | if (m_backendDispatcher->hasProtocolErrors()) { |
418 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.waitForNavigationToComplete' can't be processed"_s ); |
419 | return; |
420 | } |
421 | |
422 | Ref<AutomationBackendDispatcherHandler::WaitForNavigationToCompleteCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::WaitForNavigationToCompleteCallback(m_backendDispatcher.copyRef(), requestId)); |
423 | m_agent->waitForNavigationToComplete(in_browsingContextHandle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, opt_in_pageLoadStrategy_valueFound ? &opt_in_pageLoadStrategy : nullptr, opt_in_pageLoadTimeout_valueFound ? &opt_in_pageLoadTimeout : nullptr, callback.copyRef()); |
424 | |
425 | } |
426 | |
427 | AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback::EvaluateJavaScriptFunctionCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
428 | |
429 | void AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback::sendSuccess(const String& result) |
430 | { |
431 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
432 | jsonMessage->setString("result"_s , result); |
433 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
434 | } |
435 | |
436 | void AutomationBackendDispatcher::evaluateJavaScriptFunction(long requestId, RefPtr<JSON::Object>&& parameters) |
437 | { |
438 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
439 | bool opt_in_frameHandle_valueFound = false; |
440 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
441 | String in_function = m_backendDispatcher->getString(parameters.get(), "function"_s , nullptr); |
442 | RefPtr<JSON::Array> in_arguments = m_backendDispatcher->getArray(parameters.get(), "arguments"_s , nullptr); |
443 | bool opt_in_expectsImplicitCallbackArgument_valueFound = false; |
444 | bool opt_in_expectsImplicitCallbackArgument = m_backendDispatcher->getBoolean(parameters.get(), "expectsImplicitCallbackArgument"_s , &opt_in_expectsImplicitCallbackArgument_valueFound); |
445 | bool opt_in_callbackTimeout_valueFound = false; |
446 | int opt_in_callbackTimeout = m_backendDispatcher->getInteger(parameters.get(), "callbackTimeout"_s , &opt_in_callbackTimeout_valueFound); |
447 | if (m_backendDispatcher->hasProtocolErrors()) { |
448 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.evaluateJavaScriptFunction' can't be processed"_s ); |
449 | return; |
450 | } |
451 | |
452 | Ref<AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback(m_backendDispatcher.copyRef(), requestId)); |
453 | m_agent->evaluateJavaScriptFunction(in_browsingContextHandle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, in_function, *in_arguments, opt_in_expectsImplicitCallbackArgument_valueFound ? &opt_in_expectsImplicitCallbackArgument : nullptr, opt_in_callbackTimeout_valueFound ? &opt_in_callbackTimeout : nullptr, callback.copyRef()); |
454 | |
455 | } |
456 | |
457 | AutomationBackendDispatcherHandler::PerformMouseInteractionCallback::PerformMouseInteractionCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
458 | |
459 | void AutomationBackendDispatcherHandler::PerformMouseInteractionCallback::sendSuccess(RefPtr<Inspector::Protocol::Automation::Point>&& position) |
460 | { |
461 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
462 | jsonMessage->setObject("position"_s , position); |
463 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
464 | } |
465 | |
466 | void AutomationBackendDispatcher::performMouseInteraction(long requestId, RefPtr<JSON::Object>&& parameters) |
467 | { |
468 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
469 | RefPtr<JSON::Object> in_position = m_backendDispatcher->getObject(parameters.get(), "position"_s , nullptr); |
470 | String in_button = m_backendDispatcher->getString(parameters.get(), "button"_s , nullptr); |
471 | String in_interaction = m_backendDispatcher->getString(parameters.get(), "interaction"_s , nullptr); |
472 | RefPtr<JSON::Array> in_modifiers = m_backendDispatcher->getArray(parameters.get(), "modifiers"_s , nullptr); |
473 | if (m_backendDispatcher->hasProtocolErrors()) { |
474 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.performMouseInteraction' can't be processed"_s ); |
475 | return; |
476 | } |
477 | |
478 | Ref<AutomationBackendDispatcherHandler::PerformMouseInteractionCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::PerformMouseInteractionCallback(m_backendDispatcher.copyRef(), requestId)); |
479 | m_agent->performMouseInteraction(in_handle, *in_position, in_button, in_interaction, *in_modifiers, callback.copyRef()); |
480 | |
481 | } |
482 | |
483 | AutomationBackendDispatcherHandler::PerformKeyboardInteractionsCallback::PerformKeyboardInteractionsCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
484 | |
485 | void AutomationBackendDispatcherHandler::PerformKeyboardInteractionsCallback::sendSuccess() |
486 | { |
487 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
488 | |
489 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
490 | } |
491 | |
492 | void AutomationBackendDispatcher::performKeyboardInteractions(long requestId, RefPtr<JSON::Object>&& parameters) |
493 | { |
494 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
495 | RefPtr<JSON::Array> in_interactions = m_backendDispatcher->getArray(parameters.get(), "interactions"_s , nullptr); |
496 | if (m_backendDispatcher->hasProtocolErrors()) { |
497 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.performKeyboardInteractions' can't be processed"_s ); |
498 | return; |
499 | } |
500 | |
501 | Ref<AutomationBackendDispatcherHandler::PerformKeyboardInteractionsCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::PerformKeyboardInteractionsCallback(m_backendDispatcher.copyRef(), requestId)); |
502 | m_agent->performKeyboardInteractions(in_handle, *in_interactions, callback.copyRef()); |
503 | |
504 | } |
505 | |
506 | AutomationBackendDispatcherHandler::PerformInteractionSequenceCallback::PerformInteractionSequenceCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
507 | |
508 | void AutomationBackendDispatcherHandler::PerformInteractionSequenceCallback::sendSuccess() |
509 | { |
510 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
511 | |
512 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
513 | } |
514 | |
515 | void AutomationBackendDispatcher::performInteractionSequence(long requestId, RefPtr<JSON::Object>&& parameters) |
516 | { |
517 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
518 | bool opt_in_frameHandle_valueFound = false; |
519 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
520 | RefPtr<JSON::Array> in_inputSources = m_backendDispatcher->getArray(parameters.get(), "inputSources"_s , nullptr); |
521 | RefPtr<JSON::Array> in_steps = m_backendDispatcher->getArray(parameters.get(), "steps"_s , nullptr); |
522 | if (m_backendDispatcher->hasProtocolErrors()) { |
523 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.performInteractionSequence' can't be processed"_s ); |
524 | return; |
525 | } |
526 | |
527 | Ref<AutomationBackendDispatcherHandler::PerformInteractionSequenceCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::PerformInteractionSequenceCallback(m_backendDispatcher.copyRef(), requestId)); |
528 | m_agent->performInteractionSequence(in_handle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, *in_inputSources, *in_steps, callback.copyRef()); |
529 | |
530 | } |
531 | |
532 | AutomationBackendDispatcherHandler::CancelInteractionSequenceCallback::CancelInteractionSequenceCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
533 | |
534 | void AutomationBackendDispatcherHandler::CancelInteractionSequenceCallback::sendSuccess() |
535 | { |
536 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
537 | |
538 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
539 | } |
540 | |
541 | void AutomationBackendDispatcher::cancelInteractionSequence(long requestId, RefPtr<JSON::Object>&& parameters) |
542 | { |
543 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
544 | bool opt_in_frameHandle_valueFound = false; |
545 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
546 | if (m_backendDispatcher->hasProtocolErrors()) { |
547 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.cancelInteractionSequence' can't be processed"_s ); |
548 | return; |
549 | } |
550 | |
551 | Ref<AutomationBackendDispatcherHandler::CancelInteractionSequenceCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::CancelInteractionSequenceCallback(m_backendDispatcher.copyRef(), requestId)); |
552 | m_agent->cancelInteractionSequence(in_handle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, callback.copyRef()); |
553 | |
554 | } |
555 | |
556 | AutomationBackendDispatcherHandler::TakeScreenshotCallback::TakeScreenshotCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
557 | |
558 | void AutomationBackendDispatcherHandler::TakeScreenshotCallback::sendSuccess(const String& data) |
559 | { |
560 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
561 | jsonMessage->setString("data"_s , data); |
562 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
563 | } |
564 | |
565 | void AutomationBackendDispatcher::takeScreenshot(long requestId, RefPtr<JSON::Object>&& parameters) |
566 | { |
567 | String in_handle = m_backendDispatcher->getString(parameters.get(), "handle"_s , nullptr); |
568 | bool opt_in_frameHandle_valueFound = false; |
569 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
570 | bool opt_in_nodeHandle_valueFound = false; |
571 | String opt_in_nodeHandle = m_backendDispatcher->getString(parameters.get(), "nodeHandle"_s , &opt_in_nodeHandle_valueFound); |
572 | bool opt_in_scrollIntoViewIfNeeded_valueFound = false; |
573 | bool opt_in_scrollIntoViewIfNeeded = m_backendDispatcher->getBoolean(parameters.get(), "scrollIntoViewIfNeeded"_s , &opt_in_scrollIntoViewIfNeeded_valueFound); |
574 | bool opt_in_clipToViewport_valueFound = false; |
575 | bool opt_in_clipToViewport = m_backendDispatcher->getBoolean(parameters.get(), "clipToViewport"_s , &opt_in_clipToViewport_valueFound); |
576 | if (m_backendDispatcher->hasProtocolErrors()) { |
577 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.takeScreenshot' can't be processed"_s ); |
578 | return; |
579 | } |
580 | |
581 | Ref<AutomationBackendDispatcherHandler::TakeScreenshotCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::TakeScreenshotCallback(m_backendDispatcher.copyRef(), requestId)); |
582 | m_agent->takeScreenshot(in_handle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, opt_in_nodeHandle_valueFound ? &opt_in_nodeHandle : nullptr, opt_in_scrollIntoViewIfNeeded_valueFound ? &opt_in_scrollIntoViewIfNeeded : nullptr, opt_in_clipToViewport_valueFound ? &opt_in_clipToViewport : nullptr, callback.copyRef()); |
583 | |
584 | } |
585 | |
586 | AutomationBackendDispatcherHandler::ResolveChildFrameHandleCallback::ResolveChildFrameHandleCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
587 | |
588 | void AutomationBackendDispatcherHandler::ResolveChildFrameHandleCallback::sendSuccess(const String& result) |
589 | { |
590 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
591 | jsonMessage->setString("result"_s , result); |
592 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
593 | } |
594 | |
595 | void AutomationBackendDispatcher::resolveChildFrameHandle(long requestId, RefPtr<JSON::Object>&& parameters) |
596 | { |
597 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
598 | bool opt_in_frameHandle_valueFound = false; |
599 | String opt_in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , &opt_in_frameHandle_valueFound); |
600 | bool opt_in_ordinal_valueFound = false; |
601 | int opt_in_ordinal = m_backendDispatcher->getInteger(parameters.get(), "ordinal"_s , &opt_in_ordinal_valueFound); |
602 | bool opt_in_name_valueFound = false; |
603 | String opt_in_name = m_backendDispatcher->getString(parameters.get(), "name"_s , &opt_in_name_valueFound); |
604 | bool opt_in_nodeHandle_valueFound = false; |
605 | String opt_in_nodeHandle = m_backendDispatcher->getString(parameters.get(), "nodeHandle"_s , &opt_in_nodeHandle_valueFound); |
606 | if (m_backendDispatcher->hasProtocolErrors()) { |
607 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.resolveChildFrameHandle' can't be processed"_s ); |
608 | return; |
609 | } |
610 | |
611 | Ref<AutomationBackendDispatcherHandler::ResolveChildFrameHandleCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::ResolveChildFrameHandleCallback(m_backendDispatcher.copyRef(), requestId)); |
612 | m_agent->resolveChildFrameHandle(in_browsingContextHandle, opt_in_frameHandle_valueFound ? &opt_in_frameHandle : nullptr, opt_in_ordinal_valueFound ? &opt_in_ordinal : nullptr, opt_in_name_valueFound ? &opt_in_name : nullptr, opt_in_nodeHandle_valueFound ? &opt_in_nodeHandle : nullptr, callback.copyRef()); |
613 | |
614 | } |
615 | |
616 | AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback::ResolveParentFrameHandleCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
617 | |
618 | void AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback::sendSuccess(const String& result) |
619 | { |
620 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
621 | jsonMessage->setString("result"_s , result); |
622 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
623 | } |
624 | |
625 | void AutomationBackendDispatcher::resolveParentFrameHandle(long requestId, RefPtr<JSON::Object>&& parameters) |
626 | { |
627 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
628 | String in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , nullptr); |
629 | if (m_backendDispatcher->hasProtocolErrors()) { |
630 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.resolveParentFrameHandle' can't be processed"_s ); |
631 | return; |
632 | } |
633 | |
634 | Ref<AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback(m_backendDispatcher.copyRef(), requestId)); |
635 | m_agent->resolveParentFrameHandle(in_browsingContextHandle, in_frameHandle, callback.copyRef()); |
636 | |
637 | } |
638 | |
639 | AutomationBackendDispatcherHandler::ComputeElementLayoutCallback::ComputeElementLayoutCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
640 | |
641 | void AutomationBackendDispatcherHandler::ComputeElementLayoutCallback::sendSuccess(RefPtr<Inspector::Protocol::Automation::Rect>&& rect, RefPtr<Inspector::Protocol::Automation::Point>&& inViewCenterPoint, bool isObscured) |
642 | { |
643 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
644 | jsonMessage->setObject("rect"_s , rect); |
645 | if (inViewCenterPoint) |
646 | jsonMessage->setObject("inViewCenterPoint"_s , inViewCenterPoint); |
647 | jsonMessage->setBoolean("isObscured"_s , isObscured); |
648 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
649 | } |
650 | |
651 | void AutomationBackendDispatcher::computeElementLayout(long requestId, RefPtr<JSON::Object>&& parameters) |
652 | { |
653 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
654 | String in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , nullptr); |
655 | String in_nodeHandle = m_backendDispatcher->getString(parameters.get(), "nodeHandle"_s , nullptr); |
656 | bool opt_in_scrollIntoViewIfNeeded_valueFound = false; |
657 | bool opt_in_scrollIntoViewIfNeeded = m_backendDispatcher->getBoolean(parameters.get(), "scrollIntoViewIfNeeded"_s , &opt_in_scrollIntoViewIfNeeded_valueFound); |
658 | String in_coordinateSystem = m_backendDispatcher->getString(parameters.get(), "coordinateSystem"_s , nullptr); |
659 | if (m_backendDispatcher->hasProtocolErrors()) { |
660 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.computeElementLayout' can't be processed"_s ); |
661 | return; |
662 | } |
663 | |
664 | Ref<AutomationBackendDispatcherHandler::ComputeElementLayoutCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::ComputeElementLayoutCallback(m_backendDispatcher.copyRef(), requestId)); |
665 | m_agent->computeElementLayout(in_browsingContextHandle, in_frameHandle, in_nodeHandle, opt_in_scrollIntoViewIfNeeded_valueFound ? &opt_in_scrollIntoViewIfNeeded : nullptr, in_coordinateSystem, callback.copyRef()); |
666 | |
667 | } |
668 | |
669 | AutomationBackendDispatcherHandler::SelectOptionElementCallback::SelectOptionElementCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
670 | |
671 | void AutomationBackendDispatcherHandler::SelectOptionElementCallback::sendSuccess() |
672 | { |
673 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
674 | |
675 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
676 | } |
677 | |
678 | void AutomationBackendDispatcher::selectOptionElement(long requestId, RefPtr<JSON::Object>&& parameters) |
679 | { |
680 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
681 | String in_frameHandle = m_backendDispatcher->getString(parameters.get(), "frameHandle"_s , nullptr); |
682 | String in_nodeHandle = m_backendDispatcher->getString(parameters.get(), "nodeHandle"_s , nullptr); |
683 | if (m_backendDispatcher->hasProtocolErrors()) { |
684 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.selectOptionElement' can't be processed"_s ); |
685 | return; |
686 | } |
687 | |
688 | Ref<AutomationBackendDispatcherHandler::SelectOptionElementCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::SelectOptionElementCallback(m_backendDispatcher.copyRef(), requestId)); |
689 | m_agent->selectOptionElement(in_browsingContextHandle, in_frameHandle, in_nodeHandle, callback.copyRef()); |
690 | |
691 | } |
692 | |
693 | void AutomationBackendDispatcher::isShowingJavaScriptDialog(long requestId, RefPtr<JSON::Object>&& parameters) |
694 | { |
695 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
696 | if (m_backendDispatcher->hasProtocolErrors()) { |
697 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.isShowingJavaScriptDialog' can't be processed"_s ); |
698 | return; |
699 | } |
700 | |
701 | ErrorString error; |
702 | Ref<JSON::Object> result = JSON::Object::create(); |
703 | bool out_result; |
704 | m_agent->isShowingJavaScriptDialog(error, in_browsingContextHandle, &out_result); |
705 | |
706 | if (!error.length()) |
707 | result->setBoolean("result"_s , out_result); |
708 | |
709 | if (!error.length()) |
710 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
711 | else |
712 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
713 | } |
714 | |
715 | void AutomationBackendDispatcher::dismissCurrentJavaScriptDialog(long requestId, RefPtr<JSON::Object>&& parameters) |
716 | { |
717 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
718 | if (m_backendDispatcher->hasProtocolErrors()) { |
719 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.dismissCurrentJavaScriptDialog' can't be processed"_s ); |
720 | return; |
721 | } |
722 | |
723 | ErrorString error; |
724 | Ref<JSON::Object> result = JSON::Object::create(); |
725 | m_agent->dismissCurrentJavaScriptDialog(error, in_browsingContextHandle); |
726 | |
727 | if (!error.length()) |
728 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
729 | else |
730 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
731 | } |
732 | |
733 | void AutomationBackendDispatcher::acceptCurrentJavaScriptDialog(long requestId, RefPtr<JSON::Object>&& parameters) |
734 | { |
735 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
736 | if (m_backendDispatcher->hasProtocolErrors()) { |
737 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.acceptCurrentJavaScriptDialog' can't be processed"_s ); |
738 | return; |
739 | } |
740 | |
741 | ErrorString error; |
742 | Ref<JSON::Object> result = JSON::Object::create(); |
743 | m_agent->acceptCurrentJavaScriptDialog(error, in_browsingContextHandle); |
744 | |
745 | if (!error.length()) |
746 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
747 | else |
748 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
749 | } |
750 | |
751 | void AutomationBackendDispatcher::messageOfCurrentJavaScriptDialog(long requestId, RefPtr<JSON::Object>&& parameters) |
752 | { |
753 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
754 | if (m_backendDispatcher->hasProtocolErrors()) { |
755 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.messageOfCurrentJavaScriptDialog' can't be processed"_s ); |
756 | return; |
757 | } |
758 | |
759 | ErrorString error; |
760 | Ref<JSON::Object> result = JSON::Object::create(); |
761 | String out_message; |
762 | m_agent->messageOfCurrentJavaScriptDialog(error, in_browsingContextHandle, &out_message); |
763 | |
764 | if (!error.length()) |
765 | result->setString("message"_s , out_message); |
766 | |
767 | if (!error.length()) |
768 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
769 | else |
770 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
771 | } |
772 | |
773 | void AutomationBackendDispatcher::setUserInputForCurrentJavaScriptPrompt(long requestId, RefPtr<JSON::Object>&& parameters) |
774 | { |
775 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
776 | String in_userInput = m_backendDispatcher->getString(parameters.get(), "userInput"_s , nullptr); |
777 | if (m_backendDispatcher->hasProtocolErrors()) { |
778 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.setUserInputForCurrentJavaScriptPrompt' can't be processed"_s ); |
779 | return; |
780 | } |
781 | |
782 | ErrorString error; |
783 | Ref<JSON::Object> result = JSON::Object::create(); |
784 | m_agent->setUserInputForCurrentJavaScriptPrompt(error, in_browsingContextHandle, in_userInput); |
785 | |
786 | if (!error.length()) |
787 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
788 | else |
789 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
790 | } |
791 | |
792 | void AutomationBackendDispatcher::setFilesToSelectForFileUpload(long requestId, RefPtr<JSON::Object>&& parameters) |
793 | { |
794 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
795 | RefPtr<JSON::Array> in_filenames = m_backendDispatcher->getArray(parameters.get(), "filenames"_s , nullptr); |
796 | bool opt_in_fileContents_valueFound = false; |
797 | RefPtr<JSON::Array> opt_in_fileContents = m_backendDispatcher->getArray(parameters.get(), "fileContents"_s , &opt_in_fileContents_valueFound); |
798 | if (m_backendDispatcher->hasProtocolErrors()) { |
799 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.setFilesToSelectForFileUpload' can't be processed"_s ); |
800 | return; |
801 | } |
802 | |
803 | ErrorString error; |
804 | Ref<JSON::Object> result = JSON::Object::create(); |
805 | m_agent->setFilesToSelectForFileUpload(error, in_browsingContextHandle, *in_filenames, opt_in_fileContents_valueFound ? opt_in_fileContents.get() : nullptr); |
806 | |
807 | if (!error.length()) |
808 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
809 | else |
810 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
811 | } |
812 | |
813 | AutomationBackendDispatcherHandler::GetAllCookiesCallback::GetAllCookiesCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
814 | |
815 | void AutomationBackendDispatcherHandler::GetAllCookiesCallback::sendSuccess(RefPtr<JSON::ArrayOf<Inspector::Protocol::Automation::Cookie>>&& cookies) |
816 | { |
817 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
818 | jsonMessage->setArray("cookies"_s , cookies); |
819 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
820 | } |
821 | |
822 | void AutomationBackendDispatcher::getAllCookies(long requestId, RefPtr<JSON::Object>&& parameters) |
823 | { |
824 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
825 | if (m_backendDispatcher->hasProtocolErrors()) { |
826 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.getAllCookies' can't be processed"_s ); |
827 | return; |
828 | } |
829 | |
830 | Ref<AutomationBackendDispatcherHandler::GetAllCookiesCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::GetAllCookiesCallback(m_backendDispatcher.copyRef(), requestId)); |
831 | m_agent->getAllCookies(in_browsingContextHandle, callback.copyRef()); |
832 | |
833 | } |
834 | |
835 | AutomationBackendDispatcherHandler::DeleteSingleCookieCallback::DeleteSingleCookieCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
836 | |
837 | void AutomationBackendDispatcherHandler::DeleteSingleCookieCallback::sendSuccess() |
838 | { |
839 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
840 | |
841 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
842 | } |
843 | |
844 | void AutomationBackendDispatcher::deleteSingleCookie(long requestId, RefPtr<JSON::Object>&& parameters) |
845 | { |
846 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
847 | String in_cookieName = m_backendDispatcher->getString(parameters.get(), "cookieName"_s , nullptr); |
848 | if (m_backendDispatcher->hasProtocolErrors()) { |
849 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.deleteSingleCookie' can't be processed"_s ); |
850 | return; |
851 | } |
852 | |
853 | Ref<AutomationBackendDispatcherHandler::DeleteSingleCookieCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::DeleteSingleCookieCallback(m_backendDispatcher.copyRef(), requestId)); |
854 | m_agent->deleteSingleCookie(in_browsingContextHandle, in_cookieName, callback.copyRef()); |
855 | |
856 | } |
857 | |
858 | AutomationBackendDispatcherHandler::AddSingleCookieCallback::AddSingleCookieCallback(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { } |
859 | |
860 | void AutomationBackendDispatcherHandler::AddSingleCookieCallback::sendSuccess() |
861 | { |
862 | Ref<JSON::Object> jsonMessage = JSON::Object::create(); |
863 | |
864 | CallbackBase::sendSuccess(WTFMove(jsonMessage)); |
865 | } |
866 | |
867 | void AutomationBackendDispatcher::addSingleCookie(long requestId, RefPtr<JSON::Object>&& parameters) |
868 | { |
869 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
870 | RefPtr<JSON::Object> in_cookie = m_backendDispatcher->getObject(parameters.get(), "cookie"_s , nullptr); |
871 | if (m_backendDispatcher->hasProtocolErrors()) { |
872 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.addSingleCookie' can't be processed"_s ); |
873 | return; |
874 | } |
875 | |
876 | Ref<AutomationBackendDispatcherHandler::AddSingleCookieCallback> callback = adoptRef(*new AutomationBackendDispatcherHandler::AddSingleCookieCallback(m_backendDispatcher.copyRef(), requestId)); |
877 | m_agent->addSingleCookie(in_browsingContextHandle, *in_cookie, callback.copyRef()); |
878 | |
879 | } |
880 | |
881 | void AutomationBackendDispatcher::deleteAllCookies(long requestId, RefPtr<JSON::Object>&& parameters) |
882 | { |
883 | String in_browsingContextHandle = m_backendDispatcher->getString(parameters.get(), "browsingContextHandle"_s , nullptr); |
884 | if (m_backendDispatcher->hasProtocolErrors()) { |
885 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.deleteAllCookies' can't be processed"_s ); |
886 | return; |
887 | } |
888 | |
889 | ErrorString error; |
890 | Ref<JSON::Object> result = JSON::Object::create(); |
891 | m_agent->deleteAllCookies(error, in_browsingContextHandle); |
892 | |
893 | if (!error.length()) |
894 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
895 | else |
896 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
897 | } |
898 | |
899 | void AutomationBackendDispatcher::getSessionPermissions(long requestId, RefPtr<JSON::Object>&&) |
900 | { |
901 | ErrorString error; |
902 | Ref<JSON::Object> result = JSON::Object::create(); |
903 | RefPtr<JSON::ArrayOf<Inspector::Protocol::Automation::SessionPermissionData>> out_permissions; |
904 | m_agent->getSessionPermissions(error, out_permissions); |
905 | |
906 | if (!error.length()) |
907 | result->setArray("permissions"_s , out_permissions); |
908 | |
909 | if (!error.length()) |
910 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
911 | else |
912 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
913 | } |
914 | |
915 | void AutomationBackendDispatcher::setSessionPermissions(long requestId, RefPtr<JSON::Object>&& parameters) |
916 | { |
917 | RefPtr<JSON::Array> in_permissions = m_backendDispatcher->getArray(parameters.get(), "permissions"_s , nullptr); |
918 | if (m_backendDispatcher->hasProtocolErrors()) { |
919 | m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method 'Automation.setSessionPermissions' can't be processed"_s ); |
920 | return; |
921 | } |
922 | |
923 | ErrorString error; |
924 | Ref<JSON::Object> result = JSON::Object::create(); |
925 | m_agent->setSessionPermissions(error, *in_permissions); |
926 | |
927 | if (!error.length()) |
928 | m_backendDispatcher->sendResponse(requestId, WTFMove(result), false); |
929 | else |
930 | m_backendDispatcher->reportProtocolError(BackendDispatcher::ServerError, WTFMove(error)); |
931 | } |
932 | |
933 | } // namespace Inspector |
934 | |