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 "AutomationProtocolObjects.h"
33
34#include <wtf/Optional.h>
35#include <wtf/text/CString.h>
36
37namespace Inspector {
38
39namespace Protocol {
40
41namespace AutomationHelpers {
42
43static const char* const enum_constant_values[] = {
44 "Page",
45 "Viewport",
46 "Window",
47 "Tab",
48 "InternalError",
49 "Timeout",
50 "JavaScriptError",
51 "JavaScriptTimeout",
52 "WindowNotFound",
53 "FrameNotFound",
54 "NodeNotFound",
55 "InvalidElementState",
56 "NoJavaScriptDialog",
57 "NotImplemented",
58 "MissingParameter",
59 "InvalidParameter",
60 "InvalidSelector",
61 "ElementNotInteractable",
62 "ElementNotSelectable",
63 "ScreenshotError",
64 "UnexpectedAlertOpen",
65 "TargetOutOfBounds",
66 "None",
67 "Eager",
68 "Normal",
69 "Move",
70 "Down",
71 "Up",
72 "SingleClick",
73 "DoubleClick",
74 "Left",
75 "Middle",
76 "Right",
77 "CapsLock",
78 "Control",
79 "Shift",
80 "Meta",
81 "Alt",
82 "Alternate",
83 "Command",
84 "Cancel",
85 "Help",
86 "Backspace",
87 "Clear",
88 "Enter",
89 "Pause",
90 "Escape",
91 "PageUp",
92 "PageDown",
93 "End",
94 "Home",
95 "LeftArrow",
96 "UpArrow",
97 "RightArrow",
98 "DownArrow",
99 "Insert",
100 "Delete",
101 "Space",
102 "Semicolon",
103 "Equals",
104 "Return",
105 "NumberPad0",
106 "NumberPad1",
107 "NumberPad2",
108 "NumberPad3",
109 "NumberPad4",
110 "NumberPad5",
111 "NumberPad6",
112 "NumberPad7",
113 "NumberPad8",
114 "NumberPad9",
115 "NumberPadMultiply",
116 "NumberPadAdd",
117 "NumberPadSeparator",
118 "NumberPadSubtract",
119 "NumberPadDecimal",
120 "NumberPadDivide",
121 "Function1",
122 "Function2",
123 "Function3",
124 "Function4",
125 "Function5",
126 "Function6",
127 "Function7",
128 "Function8",
129 "Function9",
130 "Function10",
131 "Function11",
132 "Function12",
133 "KeyPress",
134 "KeyRelease",
135 "InsertByKey",
136 "GetUserMedia",
137 "Null",
138 "Mouse",
139 "Keyboard",
140 "Touch",
141 "Pointer",
142 "Element",
143};
144
145String getEnumConstantValue(int code) {
146 return enum_constant_values[code];
147}
148
149// Enums in the 'Automation' Domain
150template<>
151Optional<Inspector::Protocol::Automation::CoordinateSystem> parseEnumValueFromString<Inspector::Protocol::Automation::CoordinateSystem>(const String& protocolString)
152{
153 static const size_t constantValues[] = {
154 (size_t)Inspector::Protocol::Automation::CoordinateSystem::Page,
155 (size_t)Inspector::Protocol::Automation::CoordinateSystem::Viewport,
156 };
157 for (size_t i = 0; i < 2; ++i)
158 if (protocolString == enum_constant_values[constantValues[i]])
159 return (Inspector::Protocol::Automation::CoordinateSystem)constantValues[i];
160
161 return WTF::nullopt;
162}
163
164template<>
165Optional<Inspector::Protocol::Automation::BrowsingContextPresentation> parseEnumValueFromString<Inspector::Protocol::Automation::BrowsingContextPresentation>(const String& protocolString)
166{
167 static const size_t constantValues[] = {
168 (size_t)Inspector::Protocol::Automation::BrowsingContextPresentation::Window,
169 (size_t)Inspector::Protocol::Automation::BrowsingContextPresentation::Tab,
170 };
171 for (size_t i = 0; i < 2; ++i)
172 if (protocolString == enum_constant_values[constantValues[i]])
173 return (Inspector::Protocol::Automation::BrowsingContextPresentation)constantValues[i];
174
175 return WTF::nullopt;
176}
177
178template<>
179Optional<Inspector::Protocol::Automation::ErrorMessage> parseEnumValueFromString<Inspector::Protocol::Automation::ErrorMessage>(const String& protocolString)
180{
181 static const size_t constantValues[] = {
182 (size_t)Inspector::Protocol::Automation::ErrorMessage::InternalError,
183 (size_t)Inspector::Protocol::Automation::ErrorMessage::Timeout,
184 (size_t)Inspector::Protocol::Automation::ErrorMessage::JavaScriptError,
185 (size_t)Inspector::Protocol::Automation::ErrorMessage::JavaScriptTimeout,
186 (size_t)Inspector::Protocol::Automation::ErrorMessage::WindowNotFound,
187 (size_t)Inspector::Protocol::Automation::ErrorMessage::FrameNotFound,
188 (size_t)Inspector::Protocol::Automation::ErrorMessage::NodeNotFound,
189 (size_t)Inspector::Protocol::Automation::ErrorMessage::InvalidElementState,
190 (size_t)Inspector::Protocol::Automation::ErrorMessage::NoJavaScriptDialog,
191 (size_t)Inspector::Protocol::Automation::ErrorMessage::NotImplemented,
192 (size_t)Inspector::Protocol::Automation::ErrorMessage::MissingParameter,
193 (size_t)Inspector::Protocol::Automation::ErrorMessage::InvalidParameter,
194 (size_t)Inspector::Protocol::Automation::ErrorMessage::InvalidSelector,
195 (size_t)Inspector::Protocol::Automation::ErrorMessage::ElementNotInteractable,
196 (size_t)Inspector::Protocol::Automation::ErrorMessage::ElementNotSelectable,
197 (size_t)Inspector::Protocol::Automation::ErrorMessage::ScreenshotError,
198 (size_t)Inspector::Protocol::Automation::ErrorMessage::UnexpectedAlertOpen,
199 (size_t)Inspector::Protocol::Automation::ErrorMessage::TargetOutOfBounds,
200 };
201 for (size_t i = 0; i < 18; ++i)
202 if (protocolString == enum_constant_values[constantValues[i]])
203 return (Inspector::Protocol::Automation::ErrorMessage)constantValues[i];
204
205 return WTF::nullopt;
206}
207
208template<>
209Optional<Inspector::Protocol::Automation::PageLoadStrategy> parseEnumValueFromString<Inspector::Protocol::Automation::PageLoadStrategy>(const String& protocolString)
210{
211 static const size_t constantValues[] = {
212 (size_t)Inspector::Protocol::Automation::PageLoadStrategy::None,
213 (size_t)Inspector::Protocol::Automation::PageLoadStrategy::Eager,
214 (size_t)Inspector::Protocol::Automation::PageLoadStrategy::Normal,
215 };
216 for (size_t i = 0; i < 3; ++i)
217 if (protocolString == enum_constant_values[constantValues[i]])
218 return (Inspector::Protocol::Automation::PageLoadStrategy)constantValues[i];
219
220 return WTF::nullopt;
221}
222
223template<>
224Optional<Inspector::Protocol::Automation::MouseInteraction> parseEnumValueFromString<Inspector::Protocol::Automation::MouseInteraction>(const String& protocolString)
225{
226 static const size_t constantValues[] = {
227 (size_t)Inspector::Protocol::Automation::MouseInteraction::Move,
228 (size_t)Inspector::Protocol::Automation::MouseInteraction::Down,
229 (size_t)Inspector::Protocol::Automation::MouseInteraction::Up,
230 (size_t)Inspector::Protocol::Automation::MouseInteraction::SingleClick,
231 (size_t)Inspector::Protocol::Automation::MouseInteraction::DoubleClick,
232 };
233 for (size_t i = 0; i < 5; ++i)
234 if (protocolString == enum_constant_values[constantValues[i]])
235 return (Inspector::Protocol::Automation::MouseInteraction)constantValues[i];
236
237 return WTF::nullopt;
238}
239
240template<>
241Optional<Inspector::Protocol::Automation::MouseButton> parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(const String& protocolString)
242{
243 static const size_t constantValues[] = {
244 (size_t)Inspector::Protocol::Automation::MouseButton::None,
245 (size_t)Inspector::Protocol::Automation::MouseButton::Left,
246 (size_t)Inspector::Protocol::Automation::MouseButton::Middle,
247 (size_t)Inspector::Protocol::Automation::MouseButton::Right,
248 };
249 for (size_t i = 0; i < 4; ++i)
250 if (protocolString == enum_constant_values[constantValues[i]])
251 return (Inspector::Protocol::Automation::MouseButton)constantValues[i];
252
253 return WTF::nullopt;
254}
255
256template<>
257Optional<Inspector::Protocol::Automation::KeyModifier> parseEnumValueFromString<Inspector::Protocol::Automation::KeyModifier>(const String& protocolString)
258{
259 static const size_t constantValues[] = {
260 (size_t)Inspector::Protocol::Automation::KeyModifier::CapsLock,
261 (size_t)Inspector::Protocol::Automation::KeyModifier::Control,
262 (size_t)Inspector::Protocol::Automation::KeyModifier::Shift,
263 (size_t)Inspector::Protocol::Automation::KeyModifier::Meta,
264 (size_t)Inspector::Protocol::Automation::KeyModifier::Alt,
265 };
266 for (size_t i = 0; i < 5; ++i)
267 if (protocolString == enum_constant_values[constantValues[i]])
268 return (Inspector::Protocol::Automation::KeyModifier)constantValues[i];
269
270 return WTF::nullopt;
271}
272
273template<>
274Optional<Inspector::Protocol::Automation::VirtualKey> parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(const String& protocolString)
275{
276 static const size_t constantValues[] = {
277 (size_t)Inspector::Protocol::Automation::VirtualKey::Shift,
278 (size_t)Inspector::Protocol::Automation::VirtualKey::Control,
279 (size_t)Inspector::Protocol::Automation::VirtualKey::Alternate,
280 (size_t)Inspector::Protocol::Automation::VirtualKey::Meta,
281 (size_t)Inspector::Protocol::Automation::VirtualKey::Command,
282 (size_t)Inspector::Protocol::Automation::VirtualKey::Cancel,
283 (size_t)Inspector::Protocol::Automation::VirtualKey::Help,
284 (size_t)Inspector::Protocol::Automation::VirtualKey::Backspace,
285 (size_t)Inspector::Protocol::Automation::VirtualKey::Tab,
286 (size_t)Inspector::Protocol::Automation::VirtualKey::Clear,
287 (size_t)Inspector::Protocol::Automation::VirtualKey::Enter,
288 (size_t)Inspector::Protocol::Automation::VirtualKey::Pause,
289 (size_t)Inspector::Protocol::Automation::VirtualKey::Escape,
290 (size_t)Inspector::Protocol::Automation::VirtualKey::PageUp,
291 (size_t)Inspector::Protocol::Automation::VirtualKey::PageDown,
292 (size_t)Inspector::Protocol::Automation::VirtualKey::End,
293 (size_t)Inspector::Protocol::Automation::VirtualKey::Home,
294 (size_t)Inspector::Protocol::Automation::VirtualKey::LeftArrow,
295 (size_t)Inspector::Protocol::Automation::VirtualKey::UpArrow,
296 (size_t)Inspector::Protocol::Automation::VirtualKey::RightArrow,
297 (size_t)Inspector::Protocol::Automation::VirtualKey::DownArrow,
298 (size_t)Inspector::Protocol::Automation::VirtualKey::Insert,
299 (size_t)Inspector::Protocol::Automation::VirtualKey::Delete,
300 (size_t)Inspector::Protocol::Automation::VirtualKey::Space,
301 (size_t)Inspector::Protocol::Automation::VirtualKey::Semicolon,
302 (size_t)Inspector::Protocol::Automation::VirtualKey::Equals,
303 (size_t)Inspector::Protocol::Automation::VirtualKey::Return,
304 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad0,
305 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad1,
306 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad2,
307 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad3,
308 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad4,
309 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad5,
310 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad6,
311 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad7,
312 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad8,
313 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPad9,
314 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPadMultiply,
315 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPadAdd,
316 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPadSeparator,
317 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPadSubtract,
318 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPadDecimal,
319 (size_t)Inspector::Protocol::Automation::VirtualKey::NumberPadDivide,
320 (size_t)Inspector::Protocol::Automation::VirtualKey::Function1,
321 (size_t)Inspector::Protocol::Automation::VirtualKey::Function2,
322 (size_t)Inspector::Protocol::Automation::VirtualKey::Function3,
323 (size_t)Inspector::Protocol::Automation::VirtualKey::Function4,
324 (size_t)Inspector::Protocol::Automation::VirtualKey::Function5,
325 (size_t)Inspector::Protocol::Automation::VirtualKey::Function6,
326 (size_t)Inspector::Protocol::Automation::VirtualKey::Function7,
327 (size_t)Inspector::Protocol::Automation::VirtualKey::Function8,
328 (size_t)Inspector::Protocol::Automation::VirtualKey::Function9,
329 (size_t)Inspector::Protocol::Automation::VirtualKey::Function10,
330 (size_t)Inspector::Protocol::Automation::VirtualKey::Function11,
331 (size_t)Inspector::Protocol::Automation::VirtualKey::Function12,
332 };
333 for (size_t i = 0; i < 55; ++i)
334 if (protocolString == enum_constant_values[constantValues[i]])
335 return (Inspector::Protocol::Automation::VirtualKey)constantValues[i];
336
337 return WTF::nullopt;
338}
339
340template<>
341Optional<Inspector::Protocol::Automation::KeyboardInteractionType> parseEnumValueFromString<Inspector::Protocol::Automation::KeyboardInteractionType>(const String& protocolString)
342{
343 static const size_t constantValues[] = {
344 (size_t)Inspector::Protocol::Automation::KeyboardInteractionType::KeyPress,
345 (size_t)Inspector::Protocol::Automation::KeyboardInteractionType::KeyRelease,
346 (size_t)Inspector::Protocol::Automation::KeyboardInteractionType::InsertByKey,
347 };
348 for (size_t i = 0; i < 3; ++i)
349 if (protocolString == enum_constant_values[constantValues[i]])
350 return (Inspector::Protocol::Automation::KeyboardInteractionType)constantValues[i];
351
352 return WTF::nullopt;
353}
354
355template<>
356Optional<Inspector::Protocol::Automation::SessionPermission> parseEnumValueFromString<Inspector::Protocol::Automation::SessionPermission>(const String& protocolString)
357{
358 static const size_t constantValues[] = {
359 (size_t)Inspector::Protocol::Automation::SessionPermission::GetUserMedia,
360 };
361 for (size_t i = 0; i < 1; ++i)
362 if (protocolString == enum_constant_values[constantValues[i]])
363 return (Inspector::Protocol::Automation::SessionPermission)constantValues[i];
364
365 return WTF::nullopt;
366}
367
368template<>
369Optional<Inspector::Protocol::Automation::InputSourceType> parseEnumValueFromString<Inspector::Protocol::Automation::InputSourceType>(const String& protocolString)
370{
371 static const size_t constantValues[] = {
372 (size_t)Inspector::Protocol::Automation::InputSourceType::Null,
373 (size_t)Inspector::Protocol::Automation::InputSourceType::Mouse,
374 (size_t)Inspector::Protocol::Automation::InputSourceType::Keyboard,
375 (size_t)Inspector::Protocol::Automation::InputSourceType::Touch,
376 };
377 for (size_t i = 0; i < 4; ++i)
378 if (protocolString == enum_constant_values[constantValues[i]])
379 return (Inspector::Protocol::Automation::InputSourceType)constantValues[i];
380
381 return WTF::nullopt;
382}
383
384template<>
385Optional<Inspector::Protocol::Automation::MouseMoveOrigin> parseEnumValueFromString<Inspector::Protocol::Automation::MouseMoveOrigin>(const String& protocolString)
386{
387 static const size_t constantValues[] = {
388 (size_t)Inspector::Protocol::Automation::MouseMoveOrigin::Viewport,
389 (size_t)Inspector::Protocol::Automation::MouseMoveOrigin::Pointer,
390 (size_t)Inspector::Protocol::Automation::MouseMoveOrigin::Element,
391 };
392 for (size_t i = 0; i < 3; ++i)
393 if (protocolString == enum_constant_values[constantValues[i]])
394 return (Inspector::Protocol::Automation::MouseMoveOrigin)constantValues[i];
395
396 return WTF::nullopt;
397}
398
399
400} // namespace AutomationHelpers
401
402
403
404} // namespace Protocol
405
406} // namespace Inspector
407