2017-07-18 07:20:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Igalia S.L.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "HTTPServer.h"
|
|
|
|
#include "Session.h"
|
|
|
|
#include <wtf/Forward.h>
|
|
|
|
#include <wtf/HashMap.h>
|
2017-11-28 19:58:16 +00:00
|
|
|
#include <wtf/JSONValues.h>
|
2017-07-18 07:20:33 +00:00
|
|
|
#include <wtf/text/StringHash.h>
|
|
|
|
|
|
|
|
namespace WebDriver {
|
|
|
|
|
2017-08-11 12:28:21 +00:00
|
|
|
struct Capabilities;
|
2017-07-18 07:20:33 +00:00
|
|
|
class CommandResult;
|
|
|
|
class Session;
|
|
|
|
|
|
|
|
class WebDriverService final : public HTTPRequestHandler {
|
|
|
|
public:
|
|
|
|
WebDriverService();
|
|
|
|
~WebDriverService() = default;
|
|
|
|
|
|
|
|
int run(int argc, char** argv);
|
|
|
|
|
2020-09-30 21:22:57 +00:00
|
|
|
static void platformInit();
|
2017-08-05 09:27:15 +00:00
|
|
|
static bool platformCompareBrowserVersions(const String&, const String&);
|
|
|
|
|
2017-07-18 07:20:33 +00:00
|
|
|
private:
|
|
|
|
enum class HTTPMethod { Get, Post, Delete };
|
2017-11-28 19:58:16 +00:00
|
|
|
typedef void (WebDriverService::*CommandHandler)(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-07-18 07:20:33 +00:00
|
|
|
struct Command {
|
|
|
|
HTTPMethod method;
|
|
|
|
const char* uriTemplate;
|
|
|
|
CommandHandler handler;
|
|
|
|
};
|
|
|
|
static const Command s_commands[];
|
|
|
|
|
2021-05-30 16:11:40 +00:00
|
|
|
static std::optional<HTTPMethod> toCommandHTTPMethod(const String& method);
|
2017-11-21 16:56:46 +00:00
|
|
|
static bool findCommand(HTTPMethod, const String& path, CommandHandler*, HashMap<String, String>& parameters);
|
2017-07-18 07:20:33 +00:00
|
|
|
|
2017-11-28 19:58:16 +00:00
|
|
|
void newSession(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void deleteSession(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-12-01 09:49:10 +00:00
|
|
|
void status(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2018-01-11 10:00:31 +00:00
|
|
|
void getTimeouts(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-11-28 19:58:16 +00:00
|
|
|
void setTimeouts(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void go(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getCurrentURL(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void back(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void forward(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void refresh(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getTitle(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getWindowHandle(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void closeWindow(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void switchToWindow(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getWindowHandles(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2019-11-12 08:12:40 +00:00
|
|
|
void newWindow(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-11-28 19:58:16 +00:00
|
|
|
void switchToFrame(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void switchToParentFrame(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getWindowRect(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void setWindowRect(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2018-05-24 08:54:37 +00:00
|
|
|
void maximizeWindow(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void minimizeWindow(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void fullscreenWindow(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-11-28 19:58:16 +00:00
|
|
|
void findElement(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void findElements(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void findElementFromElement(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void findElementsFromElement(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getActiveElement(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void isElementSelected(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-12-04 11:29:29 +00:00
|
|
|
void getElementAttribute(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getElementProperty(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2018-01-22 14:33:32 +00:00
|
|
|
void getElementCSSValue(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-11-28 19:58:16 +00:00
|
|
|
void getElementText(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getElementTagName(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getElementRect(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void isElementEnabled(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void isElementDisplayed(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void elementClick(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void elementClear(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void elementSendKeys(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2019-11-08 15:09:00 +00:00
|
|
|
void getPageSource(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-11-28 19:58:16 +00:00
|
|
|
void executeScript(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void executeAsyncScript(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getAllCookies(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getNamedCookie(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void addCookie(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void deleteCookie(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void deleteAllCookies(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2018-05-10 06:52:31 +00:00
|
|
|
void performActions(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void releaseActions(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-11-28 19:58:16 +00:00
|
|
|
void dismissAlert(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void acceptAlert(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void getAlertText(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void sendAlertText(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void takeScreenshot(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void takeElementScreenshot(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
|
2017-07-18 07:20:33 +00:00
|
|
|
|
2017-08-05 09:27:15 +00:00
|
|
|
static Capabilities platformCapabilities();
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
Vector<Capabilities> processCapabilities(const JSON::Object&, Function<void (CommandResult&&)>&) const;
|
2017-11-28 19:58:16 +00:00
|
|
|
RefPtr<JSON::Object> validatedCapabilities(const JSON::Object&) const;
|
|
|
|
RefPtr<JSON::Object> mergeCapabilities(const JSON::Object&, const JSON::Object&) const;
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
RefPtr<JSON::Object> matchCapabilities(const JSON::Object&) const;
|
Web Inspector: modernize generated backend protocol code
https://bugs.webkit.org/show_bug.cgi?id=216302
<rdar://problem/68547649>
Reviewed by Brian Burg.
Source/JavaScriptCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/scripts/codegen/generator.py:
(Generator.generate_includes_from_entries):
* inspector/scripts/codegen/cpp_generator_templates.py:
* inspector/scripts/codegen/cpp_generator.py:
(CppGenerator.helpers_namespace):
(CppGenerator.cpp_getter_method_for_type):
(CppGenerator.cpp_setter_method_for_type):
(CppGenerator.cpp_protocol_type_for_type):
(CppGenerator.cpp_type_for_type_member_argument): Added.
(CppGenerator.cpp_type_for_command_parameter): Added.
(CppGenerator.cpp_type_for_command_return_declaration): Added.
(CppGenerator.cpp_type_for_command_return_argument): Added.
(CppGenerator.cpp_type_for_event_parameter): Added.
(CppGenerator.cpp_type_for_enum): Added.
(CppGenerator.should_move_argument): Added.
(CppGenerator.should_release_argument): Added.
(CppGenerator.should_dereference_argument): Added.
(CppGenerator.cpp_protocol_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_unchecked_formal_in_parameter): Deleted.
(CppGenerator.cpp_type_for_checked_formal_event_parameter): Deleted.
(CppGenerator.cpp_type_for_type_member): Deleted.
(CppGenerator.cpp_type_for_type_with_name): Deleted.
(CppGenerator.cpp_type_for_formal_out_parameter): Deleted.
(CppGenerator.cpp_type_for_formal_async_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_in_parameter): Deleted.
(CppGenerator.cpp_type_for_stack_out_parameter): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member): Deleted.
(CppGenerator.cpp_assertion_method_for_type_member.assertion_method_for_type): Deleted.
(CppGenerator.should_use_wrapper_for_return_type): Deleted.
(CppGenerator.should_use_references_for_type): Deleted.
(CppGenerator.should_pass_by_copy_for_return_type): Deleted.
* inspector/scripts/codegen/generate_cpp_alternate_backend_dispatcher_header.py:
(CppAlternateBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppAlternateBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py:
(CppBackendDispatcherHeaderGenerator.generate_output):
(CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppBackendDispatcherHeaderGenerator._generate_handler_declarations_for_domain):
(CppBackendDispatcherHeaderGenerator._generate_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_async_handler_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_command):
(CppBackendDispatcherHeaderGenerator._generate_anonymous_enum_for_parameter): Deleted.
* inspector/scripts/codegen/generate_cpp_backend_dispatcher_implementation.py:
(CppBackendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppBackendDispatcherImplementationGenerator._generate_small_dispatcher_switch_implementation_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_async_dispatcher_class_for_domain):
(CppBackendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_command):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py:
(CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherHeaderGenerator._generate_dispatcher_declaration_for_event):
* inspector/scripts/codegen/generate_cpp_frontend_dispatcher_implementation.py:
(CppFrontendDispatcherImplementationGenerator._generate_secondary_header_includes):
(CppFrontendDispatcherImplementationGenerator._generate_dispatcher_implementation_for_event):
* inspector/scripts/codegen/generate_cpp_protocol_types_header.py:
(CppProtocolTypesHeaderGenerator._generate_secondary_header_includes):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_secondary_header_includes):
(CppProtocolTypesImplementationGenerator._generate_enum_conversion_methods_for_domain):
(CppProtocolTypesImplementationGenerator._generate_open_field_names):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_header.py:
(ObjCBackendDispatcherHeaderGenerator._generate_objc_handler_declaration_for_command):
* inspector/scripts/codegen/generate_objc_backend_dispatcher_implementation.py:
(ObjCBackendDispatcherImplementationGenerator._generate_handler_implementation_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_success_block_for_command.and):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command.in_param_expression):
(ObjCBackendDispatcherImplementationGenerator._generate_conversions_for_command):
(ObjCBackendDispatcherImplementationGenerator._generate_invocation_for_command):
* inspector/scripts/codegen/generate_objc_frontend_dispatcher_implementation.py:
(ObjCFrontendDispatcherImplementationGenerator._generate_event):
(ObjCFrontendDispatcherImplementationGenerator._generate_event_out_parameters):
* inspector/scripts/codegen/objc_generator_templates.py:
* inspector/scripts/codegen/objc_generator.py:
(ObjCGenerator.protocol_type_for_type):
(ObjCGenerator.objc_type_for_param_internal):
(ObjCGenerator.objc_protocol_import_expression_for_parameter):
* inspector/protocol/Page.json:
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
* inspector/agents/InspectorAuditAgent.h:
* inspector/agents/InspectorAuditAgent.cpp:
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/InspectorConsoleAgent.cpp:
* inspector/agents/InspectorDebuggerAgent.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
* inspector/agents/InspectorHeapAgent.h:
* inspector/agents/InspectorHeapAgent.cpp:
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
* inspector/agents/InspectorScriptProfilerAgent.h:
* inspector/agents/InspectorScriptProfilerAgent.cpp:
* inspector/agents/InspectorTargetAgent.h:
* inspector/agents/InspectorTargetAgent.cpp:
* inspector/agents/JSGlobalObjectAuditAgent.h:
* inspector/agents/JSGlobalObjectAuditAgent.cpp:
* inspector/agents/JSGlobalObjectDebuggerAgent.h:
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp:
* inspector/agents/JSGlobalObjectRuntimeAgent.h:
* inspector/agents/JSGlobalObjectRuntimeAgent.cpp:
* inspector/JSGlobalObjectConsoleClient.cpp:
* inspector/JSGlobalObjectInspectorController.cpp:
Elided backend dispatcher handler changes describe above.
* bindings/ScriptValue.cpp:
(Inspector::jsToInspectorValue):
* inspector/AsyncStackTrace.h:
* inspector/AsyncStackTrace.cpp:
(Inspector::AsyncStackTrace::buildInspectorObject const):
* inspector/ConsoleMessage.cpp:
(Inspector::ConsoleMessage::addToFrontend):
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::makeEvalCall):
(Inspector::InjectedScriptBase::checkCallResult):
(Inspector::InjectedScriptBase::checkAsyncCallResult):
* inspector/InjectedScript.h:
* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::execute):
(Inspector::InjectedScript::evaluate):
(Inspector::InjectedScript::callFunctionOn):
(Inspector::InjectedScript::evaluateOnCallFrame):
(Inspector::InjectedScript::getFunctionDetails):
(Inspector::InjectedScript::functionDetails):
(Inspector::InjectedScript::getPreview):
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getDisplayableProperties):
(Inspector::InjectedScript::getInternalProperties):
(Inspector::InjectedScript::getCollectionEntries):
(Inspector::InjectedScript::saveResult):
(Inspector::InjectedScript::wrapCallFrames const):
(Inspector::InjectedScript::wrapObject const):
(Inspector::InjectedScript::wrapJSONString const):
(Inspector::InjectedScript::wrapTable const):
(Inspector::InjectedScript::previewValue const):
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::injectedScriptForObjectId):
* inspector/InspectorBackendDispatcher.h:
* inspector/InspectorBackendDispatcher.cpp:
(Inspector::BackendDispatcher::CallbackBase::sendSuccess):
(Inspector::BackendDispatcher::dispatch):
(Inspector::BackendDispatcher::sendResponse):
(Inspector::BackendDispatcher::getPropertyValue):
(Inspector::BackendDispatcher::getBoolean):
(Inspector::BackendDispatcher::getInteger):
(Inspector::BackendDispatcher::getDouble):
(Inspector::BackendDispatcher::getString):
(Inspector::BackendDispatcher::getValue):
(Inspector::BackendDispatcher::getObject):
(Inspector::BackendDispatcher::getArray):
(Inspector::castToInteger): Deleted.
(Inspector::castToNumber): Deleted.
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::runtimeCast):
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/remote/socket/RemoteInspectorConnectionClient.cpp:
(Inspector::RemoteInspectorConnectionClient::extractEvent):
* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::pushListingsNow):
* runtime/TypeSet.cpp:
(JSC::StructureShape::inspectorRepresentation):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
* inspector/scripts/tests/enum-values.json:
* inspector/scripts/tests/expected/command-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/commands-with-async-attribute.json-result:
* inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result:
* inspector/scripts/tests/expected/definitions-with-mac-platform.json-result:
* inspector/scripts/tests/expected/domain-debuggableTypes.json-result:
* inspector/scripts/tests/expected/domain-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/domain-targetTypes.json-result:
* inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result:
* inspector/scripts/tests/expected/enum-values.json-result:
* inspector/scripts/tests/expected/event-targetType-matching-domain-debuggableType.json-result:
* inspector/scripts/tests/expected/events-with-optional-parameters.json-result:
* inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result:
* inspector/scripts/tests/expected/same-type-id-different-domain.json-result:
* inspector/scripts/tests/expected/shadowed-optional-type-setters.json-result:
* inspector/scripts/tests/expected/should-strip-comments.json-result:
* inspector/scripts/tests/expected/type-declaration-aliased-primitive-type.json-result:
* inspector/scripts/tests/expected/type-declaration-array-type.json-result:
* inspector/scripts/tests/expected/type-declaration-enum-type.json-result:
* inspector/scripts/tests/expected/type-declaration-object-type.json-result:
* inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result:
* inspector/scripts/tests/expected/type-with-open-parameters.json-result:
* inspector/scripts/tests/expected/version.json-result:
Source/WebCore:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* inspector/InspectorAuditResourcesObject.cpp:
* inspector/InspectorCanvas.h:
* inspector/InspectorCanvas.cpp:
* inspector/InspectorController.cpp:
* inspector/InspectorStyleSheet.h:
* inspector/InspectorStyleSheet.cpp:
* inspector/agents/InspectorAnimationAgent.h:
* inspector/agents/InspectorAnimationAgent.cpp:
* inspector/agents/InspectorApplicationCacheAgent.h:
* inspector/agents/InspectorApplicationCacheAgent.cpp:
* inspector/agents/InspectorCPUProfilerAgent.h:
* inspector/agents/InspectorCPUProfilerAgent.cpp:
* inspector/agents/InspectorCSSAgent.h:
* inspector/agents/InspectorCSSAgent.cpp:
* inspector/agents/InspectorCanvasAgent.h:
* inspector/agents/InspectorCanvasAgent.cpp:
* inspector/agents/InspectorDOMAgent.h:
* inspector/agents/InspectorDOMAgent.cpp:
* inspector/agents/InspectorDOMDebuggerAgent.h:
* inspector/agents/InspectorDOMDebuggerAgent.cpp:
* inspector/agents/InspectorDOMStorageAgent.h:
* inspector/agents/InspectorDOMStorageAgent.cpp:
* inspector/agents/InspectorDatabaseAgent.h:
* inspector/agents/InspectorDatabaseAgent.cpp:
* inspector/agents/InspectorIndexedDBAgent.h:
* inspector/agents/InspectorIndexedDBAgent.cpp:
* inspector/agents/InspectorLayerTreeAgent.h:
* inspector/agents/InspectorLayerTreeAgent.cpp:
* inspector/agents/InspectorMemoryAgent.h:
* inspector/agents/InspectorMemoryAgent.cpp:
* inspector/agents/InspectorNetworkAgent.h:
* inspector/agents/InspectorNetworkAgent.cpp:
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
* inspector/agents/InspectorTimelineAgent.h:
* inspector/agents/InspectorTimelineAgent.cpp:
* inspector/agents/InspectorWorkerAgent.h:
* inspector/agents/InspectorWorkerAgent.cpp:
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/WebDebuggerAgent.h:
* inspector/agents/WebDebuggerAgent.cpp:
* inspector/agents/WebHeapAgent.h:
* inspector/agents/WebHeapAgent.cpp:
* inspector/agents/page/PageAuditAgent.h:
* inspector/agents/page/PageAuditAgent.cpp:
* inspector/agents/page/PageConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
* inspector/agents/page/PageDOMDebuggerAgent.h:
* inspector/agents/page/PageDOMDebuggerAgent.cpp:
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
* inspector/agents/page/PageHeapAgent.h:
* inspector/agents/page/PageHeapAgent.cpp:
* inspector/agents/page/PageNetworkAgent.h:
* inspector/agents/page/PageNetworkAgent.cpp:
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
* inspector/agents/worker/ServiceWorkerAgent.h:
* inspector/agents/worker/ServiceWorkerAgent.cpp:
* inspector/agents/worker/WorkerAuditAgent.h:
* inspector/agents/worker/WorkerConsoleAgent.h:
* inspector/agents/worker/WorkerAuditAgent.cpp:
* inspector/agents/worker/WorkerDOMDebuggerAgent.h:
* inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:
* inspector/agents/worker/WorkerDebuggerAgent.h:
* inspector/agents/worker/WorkerDebuggerAgent.cpp:
* inspector/agents/worker/WorkerNetworkAgent.h:
* inspector/agents/worker/WorkerNetworkAgent.cpp:
* inspector/agents/worker/WorkerRuntimeAgent.h:
* inspector/agents/worker/WorkerRuntimeAgent.cpp:
Elided backend dispatcher handler changes describe above.
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::inspect):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
* inspector/InspectorFrontendHost.cpp:
(WebCore::valuePayloadFromJSONValue):
(WebCore::InspectorFrontendHost::logDiagnosticEvent):
* inspector/TimelineRecordFactory.h:
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::appendLayoutRoot):
* Modules/applicationmanifest/ApplicationManifestParser.cpp:
(WebCore::ApplicationManifestParser::parseManifest):
(WebCore::ApplicationManifestParser::parseStartURL):
(WebCore::ApplicationManifestParser::parseDisplay):
(WebCore::ApplicationManifestParser::parseScope):
(WebCore::ApplicationManifestParser::parseGenericString):
* Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::extractKeyIDsKeyids):
* platform/encryptedmedia/CDMUtilities.cpp:
(WebCore::CDMUtilities::parseJSONObject):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseLicenseFormat):
(WebCore::parseLicenseReleaseAcknowledgementFormat):
* platform/graphics/avfoundation/CDMFairPlayStreaming.cpp:
(WebCore::extractSinfData):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::parseJSONValue):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateLicense):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebDriver:
* CommandResult.cpp:
(WebDriver::CommandResult::CommandResult):
* Session.cpp:
(WebDriver::firstWindowHandleInResult):
(WebDriver::Session::getTimeouts):
(WebDriver::Session::createTopLevelBrowsingContext):
(WebDriver::Session::handleUserPrompts):
(WebDriver::Session::reportUnexpectedAlertOpen):
(WebDriver::Session::go):
(WebDriver::Session::getCurrentURL):
(WebDriver::Session::back):
(WebDriver::Session::forward):
(WebDriver::Session::refresh):
(WebDriver::Session::getTitle):
(WebDriver::Session::getWindowHandle):
(WebDriver::Session::closeTopLevelBrowsingContext):
(WebDriver::Session::switchToWindow):
(WebDriver::Session::getWindowHandles):
(WebDriver::Session::newWindow):
(WebDriver::Session::switchToFrame):
(WebDriver::Session::switchToParentFrame):
(WebDriver::Session::getToplevelBrowsingContextRect):
(WebDriver::Session::setWindowRect):
(WebDriver::Session::maximizeWindow):
(WebDriver::Session::minimizeWindow):
(WebDriver::Session::fullscreenWindow):
(WebDriver::Session::createElement):
(WebDriver::Session::extractElementID):
(WebDriver::Session::computeElementLayout):
(WebDriver::Session::findElements):
(WebDriver::Session::getActiveElement):
(WebDriver::Session::isElementSelected):
(WebDriver::Session::getElementText):
(WebDriver::Session::getElementTagName):
(WebDriver::Session::getElementRect):
(WebDriver::Session::isElementEnabled):
(WebDriver::Session::isElementDisplayed):
(WebDriver::Session::getElementAttribute):
(WebDriver::Session::getElementProperty):
(WebDriver::Session::getElementCSSValue):
(WebDriver::Session::waitForNavigationToComplete):
(WebDriver::Session::elementIsFileUpload):
(WebDriver::Session::parseElementIsFileUploadResult):
(WebDriver::Session::selectOptionElement):
(WebDriver::Session::elementClick):
(WebDriver::Session::elementIsEditable):
(WebDriver::Session::elementClear):
(WebDriver::Session::setInputFileUploadFiles):
(WebDriver::Session::elementSendKeys):
(WebDriver::Session::getPageSource):
(WebDriver::Session::handleScriptResult):
(WebDriver::Session::executeScript):
(WebDriver::Session::performMouseInteraction):
(WebDriver::Session::performKeyboardInteractions):
(WebDriver::builtAutomationCookie):
(WebDriver::serializeCookie):
(WebDriver::Session::getAllCookies):
(WebDriver::Session::getNamedCookie):
(WebDriver::Session::addCookie):
(WebDriver::Session::deleteCookie):
(WebDriver::Session::deleteAllCookies):
(WebDriver::Session::performActions):
(WebDriver::Session::releaseActions):
(WebDriver::Session::dismissAlert):
(WebDriver::Session::acceptAlert):
(WebDriver::Session::getAlertText):
(WebDriver::Session::sendAlertText):
(WebDriver::Session::takeScreenshot):
* SessionHost.cpp:
(WebDriver::SessionHost::dispatchMessage):
* WebDriverService.h:
* WebDriverService.cpp:
(WebDriver::WebDriverService::handleRequest):
(WebDriver::WebDriverService::sendResponse const):
(WebDriver::valueAsNumberInRange):
(WebDriver::deserializeTimeouts):
(WebDriver::deserializeProxy):
(WebDriver::WebDriverService::parseCapabilities const):
(WebDriver::WebDriverService::findSessionOrCompleteWithError):
(WebDriver::WebDriverService::validatedCapabilities const):
(WebDriver::WebDriverService::mergeCapabilities const):
(WebDriver::WebDriverService::matchCapabilities const):
(WebDriver::WebDriverService::processCapabilities const):
(WebDriver::WebDriverService::createSession):
(WebDriver::WebDriverService::deleteSession):
(WebDriver::WebDriverService::go):
(WebDriver::WebDriverService::setWindowRect):
(WebDriver::WebDriverService::closeWindow):
(WebDriver::WebDriverService::switchToWindow):
(WebDriver::WebDriverService::newWindow):
(WebDriver::WebDriverService::switchToFrame):
(WebDriver::findElementOrCompleteWithError):
(WebDriver::findStrategyAndSelectorOrCompleteWithError):
(WebDriver::WebDriverService::getElementAttribute):
(WebDriver::WebDriverService::getElementProperty):
(WebDriver::WebDriverService::getElementCSSValue):
(WebDriver::WebDriverService::elementSendKeys):
(WebDriver::findScriptAndArgumentsOrCompleteWithError):
(WebDriver::WebDriverService::getNamedCookie):
(WebDriver::deserializeCookie):
(WebDriver::WebDriverService::addCookie):
(WebDriver::WebDriverService::deleteCookie):
(WebDriver::processPauseAction):
(WebDriver::processNullAction):
(WebDriver::processKeyAction):
(WebDriver::processPointerAction):
(WebDriver::processPointerParameters):
(WebDriver::processInputActionSequence):
(WebDriver::WebDriverService::performActions):
(WebDriver::WebDriverService::sendAlertText):
* WebDriver/gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/win/WebDriverServiceWin.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
* WebDriver/wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability):
(WebDriver::WebDriverService::platformValidateCapability):
(WebDriver::WebDriverService::platformParseCapabilities):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WebInspectorUI:
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype.set forcedAppearance):
Now that enums are processed before being passed to backend dispacher handlers, the
`appearance` parameter of `Page.setForcedAppearance` must be marked `optional` as
there's no way for it to accept an empty string, as that's not possible for an enum.
As such, rework the frontend logic for invoking `Page.setForcedAppearance` to instead
not provide an `appearance` parameter at all when wanting to "unset" it.
* UserInterface/Views/SettingsTabContentView.js:
(WI.SettingsTabContentView.prototype._createConsoleSettingsView):
Now that all logging channels matching a `Console.ChannelSource` are returned instead of
just the hardcoded list, check for a matching `WI.UIString` before showing a `<select>`.
Source/WebKit:
Previously, the inspector protocol was expressed in code in a somewhat confusing way:
- the error string was the first argument
- required parameters were `T` or `const T&`
- optional parameters were `const T*`
- enum parameters were the underlying type requiring the backend dispatcher handler to
process it instead of it being preprocessed
- required returns were `T&`
- optional returns were `T*`
This doesn't really make for easy/obvious reading of code since the order of arguments is
not weird (e.g. error string first), and that there are references/pointers to primitive
types.
This patch cleans up the generated inspector protocol code to be:
- required parameters are `T` or `Ref<T>&&`
- optional parameters are `Optional<T>&&` or `RefPtr<T>&&`
- enum parameters are preprocessed and passed to the backend dispatcher handler if valid
- synchronous commands return `Expected<X, ErrorString>` using the same types/rules above
where `X` is either a single return or a `std::tuple` of multiple returns
The one exception to the above is `String`, which is already a tri-state of `nullString()`,
`emptyString()`, and something set, so there's no need to use `Optional<String>`.
Also use `Protocol` objects/`typedefs` wherever possible to further relate the protocol
JSON and the actual backend dispatcher handler implementation.
* UIProcess/Automation/Automation.json:
`CoordinateSystem` has `Page` and `Viewport` enum values, but `WebAutomationSession` checks
for `"Page"` and `"LayoutViewport"`. Add a `LayoutViewport` enum value now that enums are
processed before being passed to backend dispacher handlers to preserve functionality.
* UIProcess/Inspector/Agents/InspectorBrowserAgent.h:
* UIProcess/Inspector/Agents/InspectorBrowserAgent.cpp:
* UIProcess/Automation/WebAutomationSessionMacros.h:
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.cpp:
* UIProcess/Automation/mac/WebAutomationSessionMac.mm:
Elided backend dispatcher handler changes describe above.
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::setTargetList):
`JSON` classes now use `Ref&&` wherever possible and `Optional` instead of an out parameter
for `get*`/`as*` so that values can be more easily manipulated and can be confidently known
to exist.
Source/WTF:
* wtf/JSONValues.h:
(WTF::JSONImpl::ObjectBase::setValue):
(WTF::JSONImpl::ObjectBase::setObject):
(WTF::JSONImpl::ObjectBase::setArray):
(WTF::JSONImpl::ArrayBase::pushValue):
(WTF::JSONImpl::ArrayBase::pushObject):
(WTF::JSONImpl::ArrayBase::pushArray):
(WTF::JSONImpl::ArrayOf::ArrayOf): Deleted.
(WTF::JSONImpl::ArrayOf::castedArray): Deleted.
(WTF::JSONImpl::ArrayOf::addItem): Deleted.
(WTF::JSONImpl::ArrayOf::create): Deleted.
* wtf/JSONValues.cpp:
(WTF::JSONImpl::Value::asValue):
(WTF::JSONImpl::Value::asObject):
(WTF::JSONImpl::Value::asArray):
(WTF::JSONImpl::Value::parseJSON):
(WTF::JSONImpl::Value::asBoolean const):
(WTF::JSONImpl::Value::asDouble const):
(WTF::JSONImpl::Value::asInteger const):
(WTF::JSONImpl::Value::asString const):
(WTF::JSONImpl::ObjectBase::asObject):
(WTF::JSONImpl::ObjectBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::getBoolean const):
(WTF::JSONImpl::ObjectBase::getDouble const):
(WTF::JSONImpl::ObjectBase::getInteger const):
(WTF::JSONImpl::ObjectBase::getString const):
(WTF::JSONImpl::ObjectBase::getObject const):
(WTF::JSONImpl::ObjectBase::getArray const):
(WTF::JSONImpl::ObjectBase::getValue const):
(WTF::JSONImpl::ObjectBase::ObjectBase):
(WTF::JSONImpl::ArrayBase::asArray):
(WTF::JSONImpl::ArrayBase::writeJSON const):
(WTF::JSONImpl::ArrayBase::ArrayBase):
(WTF::JSONImpl::ArrayBase::get const):
(WTF::JSONImpl::ArrayBase::memoryCost const):
(WTF::JSONImpl::ObjectBase::openAccessors): Deleted.
Use `Ref&&` wherever possible and `Optional` instead of an out parameter for `get*`/`as*`
so that values can be more easily manipulated and can be confidently assumed to exist.
Remove unused overloads and allow subclasses to call `as*` instead of `openAccessors` as
they're effectively the same thing.
Tools:
* TestWebKitAPI/Tests/WTF/JSONValue.cpp:
LayoutTests:
* inspector/canvas/requestShaderSource-expected.txt:
* inspector/canvas/updateShader-expected.txt:
* inspector/console/webcore-logging-expected.txt:
* inspector/dom/highlightQuad-expected.txt:
* inspector/worker/dom-debugger-dom-breakpoints-expected.txt:
Canonical link: https://commits.webkit.org/229208@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-10 19:23:17 +00:00
|
|
|
bool platformValidateCapability(const String&, const Ref<JSON::Value>&) const;
|
|
|
|
bool platformMatchCapability(const String&, const Ref<JSON::Value>&) const;
|
2019-11-11 15:16:16 +00:00
|
|
|
bool platformSupportProxyType(const String&) const;
|
2017-11-28 19:58:16 +00:00
|
|
|
void parseCapabilities(const JSON::Object& desiredCapabilities, Capabilities&) const;
|
|
|
|
void platformParseCapabilities(const JSON::Object& desiredCapabilities, Capabilities&) const;
|
WebDriver: test imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName fails
https://bugs.webkit.org/show_bug.cgi?id=181985
Reviewed by Carlos Alberto Lopez Perez.
Source/WebDriver:
The problem is that we are considering a failure when the browser name doesn't match the capabilities, instead
of trying with the next merged capabilities. This is happening because when processing capabilities, we only
match the ones that we know without having to launch the browser. Browser name and version are provided by the
browser during the session initialization. This patch reworks the session creation to make it possible to try
with the next merged capabilities when matching fails after the browser is launched.
* Session.cpp:
(WebDriver::Session::Session): Initialize timeouts from capabilities, because now we have the final capabilities here.
(WebDriver::Session::id const): Return the session ID from the SessionHost, since it's now created there.
(WebDriver::Session::createTopLevelBrowsingContext): Do not start the session, it has already been started a
this point.
(WebDriver::Session::createElement): Use id() instead of m_id.
* Session.h:
* SessionHost.h:
(WebDriver::SessionHost::sessionID const): Return the session ID.
* WebDriverService.cpp:
(WebDriver::WebDriverService::matchCapabilities const): Remove the error handling, and return a boolean instead,
since not mathing is not an error.
(WebDriver::WebDriverService::processCapabilities const): Return a list of matched capabilities, instead of the
JSON object corresponding to the first match.
(WebDriver::WebDriverService::newSession): Use helper connectToBrowser().
(WebDriver::WebDriverService::connectToBrowser): Create a session host for the next merged capabilities and
connect to the browser.
(WebDriver::WebDriverService::createSession): Start a new automation session. If capabilities didn't match,
start the process again calling connectToBrowser(), otherwise create the new session and top level.
* WebDriverService.h:
* glib/SessionHostGlib.cpp:
(WebDriver::matchBrowserOptions): Helper to check browser options.
(WebDriver::SessionHost::matchCapabilities): Use matchBrowserOptions() and return true or false instead of an
optional error message.
(WebDriver::SessionHost::startAutomationSession): Create the session ID here and notify the caller in case
capabilities didn't match.
(WebDriver::SessionHost::setTargetList): Notify that capabilities did match.
* gtk/WebDriverServiceGtk.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Make it return bool.
* wpe/WebDriverServiceWPE.cpp:
(WebDriver::WebDriverService::platformMatchCapability const): Ditto.
WebDriverTests:
Remove expectations for imported/w3c/webdriver/tests/sessions/new_session/merge.py::test_merge_browserName.
* TestExpectations.json:
Canonical link: https://commits.webkit.org/197938@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227603 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-25 13:52:40 +00:00
|
|
|
void connectToBrowser(Vector<Capabilities>&&, Function<void (CommandResult&&)>&&);
|
|
|
|
void createSession(Vector<Capabilities>&&, std::unique_ptr<SessionHost>&&, Function<void (CommandResult&&)>&&);
|
2017-12-01 09:47:15 +00:00
|
|
|
bool findSessionOrCompleteWithError(JSON::Object&, Function<void (CommandResult&&)>&);
|
2017-07-18 07:20:33 +00:00
|
|
|
|
|
|
|
void handleRequest(HTTPRequestHandler::Request&&, Function<void (HTTPRequestHandler::Response&&)>&& replyHandler) override;
|
|
|
|
void sendResponse(Function<void (HTTPRequestHandler::Response&&)>&& replyHandler, CommandResult&&) const;
|
|
|
|
|
|
|
|
HTTPServer m_server;
|
2017-12-01 09:47:15 +00:00
|
|
|
RefPtr<Session> m_session;
|
2020-09-30 21:22:57 +00:00
|
|
|
|
|
|
|
#if USE(INSPECTOR_SOCKET_SERVER)
|
|
|
|
String m_targetAddress;
|
|
|
|
uint16_t m_targetPort { 0 };
|
|
|
|
#endif
|
2017-07-18 07:20:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WebDriver
|