mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
AK+Everywhere: Store JSON object keys as String
This commit is contained in:
parent
70eb0ba1cd
commit
e591636419
Notes:
github-actions[bot]
2025-02-21 00:29:28 +00:00
Author: https://github.com/trflynn89
Commit: e591636419
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3631
Reviewed-by: https://github.com/awesomekling ✅
23 changed files with 119 additions and 111 deletions
|
@ -145,7 +145,7 @@ static ErrorOr<JsonObject, Error> validate_capabilities(JsonValue const& capabil
|
|||
else if (name.contains(':')) {
|
||||
// If name is known to the implementation, let deserialized be the result of trying to deserialize value in
|
||||
// an implementation-specific way. Otherwise, let deserialized be set to value.
|
||||
if (name.starts_with("ladybird:"sv))
|
||||
if (name.starts_with_bytes("ladybird:"sv))
|
||||
deserialized = TRY(deserialize_as_ladybird_capability(name, value));
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ static ErrorOr<MatchedRoute, Error> match_route(HTTP::HttpRequest const& request
|
|||
static JsonValue make_success_response(JsonValue value)
|
||||
{
|
||||
JsonObject result;
|
||||
result.set("value", move(value));
|
||||
result.set("value"sv, move(value));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -329,14 +329,14 @@ ErrorOr<void, Client::WrappedError> Client::send_error_response(HTTP::HttpReques
|
|||
auto reason = HTTP::HttpResponse::reason_phrase_for_code(error.http_status);
|
||||
|
||||
JsonObject error_response;
|
||||
error_response.set("error", error.error);
|
||||
error_response.set("message", error.message);
|
||||
error_response.set("stacktrace", ""sv);
|
||||
error_response.set("error"sv, error.error);
|
||||
error_response.set("message"sv, error.message);
|
||||
error_response.set("stacktrace"sv, ""sv);
|
||||
if (error.data.has_value())
|
||||
error_response.set("data", *error.data);
|
||||
error_response.set("data"sv, *error.data);
|
||||
|
||||
JsonObject result;
|
||||
result.set("value", move(error_response));
|
||||
result.set("value"sv, move(error_response));
|
||||
|
||||
auto content = result.serialized<StringBuilder>();
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ ErrorOr<JsonObject, Error> deserialize_as_a_proxy(JsonValue const& parameter)
|
|||
JsonObject proxy;
|
||||
|
||||
// 3. For each enumerable own property in parameter run the following substeps:
|
||||
TRY(parameter.as_object().try_for_each_member([&](ByteString const& key, JsonValue const& value) -> ErrorOr<void, Error> {
|
||||
TRY(parameter.as_object().try_for_each_member([&](String 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.
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ Response deserialize_as_an_unhandled_prompt_behavior(JsonValue value)
|
|||
JsonObject user_prompt_handler;
|
||||
|
||||
// 6. For each prompt type → handler in value:
|
||||
TRY(value.as_object().try_for_each_member([&](ByteString const& prompt_type, JsonValue const& handler_value) -> ErrorOr<void, WebDriver::Error> {
|
||||
TRY(value.as_object().try_for_each_member([&](String const& prompt_type, JsonValue const& handler_value) -> ErrorOr<void, WebDriver::Error> {
|
||||
// 1. If is string value is false and valid prompt types does not contain prompt type return error with error code invalid argument.
|
||||
if (!is_string_value && !valid_prompt_types.contains_slow(prompt_type))
|
||||
return WebDriver::Error::from_code(ErrorCode::InvalidArgument, ByteString::formatted("'{}' is not a valid prompt type", prompt_type));
|
||||
|
@ -192,7 +192,7 @@ bool check_user_prompt_handler_matches(JsonObject const& requested_prompt_handle
|
|||
return true;
|
||||
|
||||
// 2. For each request prompt type → request handler in requested prompt handler:
|
||||
auto result = requested_prompt_handler.try_for_each_member([&](ByteString const& request_prompt_type, JsonValue const& request_handler) -> ErrorOr<void> {
|
||||
auto result = requested_prompt_handler.try_for_each_member([&](String const& request_prompt_type, JsonValue const& request_handler) -> ErrorOr<void> {
|
||||
// 1. If the user prompt handler contains request prompt type:
|
||||
if (auto handler = s_user_prompt_handler->get(prompt_type_from_string(request_prompt_type)); handler.has_value()) {
|
||||
// 1. If the requested prompt handler's handler is not equal to the user prompt handler's handler, return false.
|
||||
|
@ -215,7 +215,7 @@ void update_the_user_prompt_handler(JsonObject const& requested_prompt_handler)
|
|||
s_user_prompt_handler = UserPromptHandler::ValueType {};
|
||||
|
||||
// 2. For each request prompt type → request handler in requested prompt handler:
|
||||
requested_prompt_handler.for_each_member([&](ByteString const& request_prompt_type, JsonValue const& request_handler) {
|
||||
requested_prompt_handler.for_each_member([&](String const& request_prompt_type, JsonValue const& request_handler) {
|
||||
// 1. Set user prompt handler[request prompt type] to request handler.
|
||||
s_user_prompt_handler->set(
|
||||
prompt_type_from_string(request_prompt_type),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue