mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Stub out WebDriver deserialize as a proxy capability AO
This prevents us from returning an 'unrecognized capability' error when a WebDriver client sends us a proxy capability. We still don't actually support setting or returning a non-empty proxy capability, though. We just don't choke on the input capability request from the server. This patch also doesn't actually validate the input proxy requests.
This commit is contained in:
parent
50bba8d9fc
commit
deb11a669a
1 changed files with 32 additions and 2 deletions
|
@ -45,6 +45,33 @@ static Response deserialize_as_an_unhandled_prompt_behavior(JsonValue value)
|
|||
return value;
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-deserialize-as-a-proxy
|
||||
static ErrorOr<JsonObject, Error> deserialize_as_a_proxy(JsonValue parameter)
|
||||
{
|
||||
// 1. If parameter is not a JSON Object return an error with error code invalid argument.
|
||||
if (!parameter.is_object())
|
||||
return Error::from_code(ErrorCode::InvalidArgument, "Capability proxy must be an object"sv);
|
||||
|
||||
// 2. Let proxy be a new, empty proxy configuration object.
|
||||
JsonObject proxy;
|
||||
|
||||
// 3. For each enumerable own property in parameter run the following substeps:
|
||||
TRY(parameter.as_object().try_for_each_member([&](auto const& key, JsonValue const& value) -> ErrorOr<void, Error> {
|
||||
// 1. Let key be the name of the property.
|
||||
// 2. Let value be the result of getting a property named name from capability.
|
||||
|
||||
// FIXME: 3. If there is no matching key for key in the proxy configuration table return an error with error code invalid argument.
|
||||
// FIXME: 4. If value is not one of the valid values for that key, return an error with error code invalid argument.
|
||||
|
||||
// 5. Set a property key to value on proxy.
|
||||
proxy.set(key, value);
|
||||
|
||||
return {};
|
||||
}));
|
||||
|
||||
return proxy;
|
||||
}
|
||||
|
||||
static Response deserialize_as_ladybird_options(JsonValue value)
|
||||
{
|
||||
if (!value.is_object())
|
||||
|
@ -113,8 +140,11 @@ static ErrorOr<JsonObject, Error> validate_capabilities(JsonValue const& capabil
|
|||
deserialized = TRY(deserialize_as_a_page_load_strategy(value));
|
||||
}
|
||||
|
||||
// FIXME: -> name equals "proxy"
|
||||
// FIXME: Let deserialized be the result of trying to deserialize as a proxy with argument value.
|
||||
// -> name equals "proxy"
|
||||
else if (name == "proxy"sv) {
|
||||
// Let deserialized be the result of trying to deserialize as a proxy with argument value.
|
||||
deserialized = TRY(deserialize_as_a_proxy(value));
|
||||
}
|
||||
|
||||
// -> name equals "strictFileInteractability"
|
||||
else if (name == "strictFileInteractability"sv) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue