mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:27:45 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -103,7 +103,7 @@ static ErrorOr<JsonObject, Error> validate_capabilities(JsonValue const& capabil
|
|||
else if (name.is_one_of("browserName"sv, "browserVersion"sv, "platformName"sv)) {
|
||||
// If value is not a string return an error with error code invalid argument. Otherwise, let deserialized be set to value.
|
||||
if (!value.is_string())
|
||||
return Error::from_code(ErrorCode::InvalidArgument, DeprecatedString::formatted("Capability {} must be a string", name));
|
||||
return Error::from_code(ErrorCode::InvalidArgument, ByteString::formatted("Capability {} must be a string", name));
|
||||
deserialized = value;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ static ErrorOr<JsonObject, Error> validate_capabilities(JsonValue const& capabil
|
|||
// -> The remote end is an endpoint node
|
||||
else {
|
||||
// Return an error with error code invalid argument.
|
||||
return Error::from_code(ErrorCode::InvalidArgument, DeprecatedString::formatted("Unrecognized capability: {}", name));
|
||||
return Error::from_code(ErrorCode::InvalidArgument, ByteString::formatted("Unrecognized capability: {}", name));
|
||||
}
|
||||
|
||||
// d. If deserialized is not null, set a property on result with name name and value deserialized.
|
||||
|
@ -192,7 +192,7 @@ static ErrorOr<JsonObject, Error> merge_capabilities(JsonObject const& primary,
|
|||
|
||||
// d. If primary value is not undefined, return an error with error code invalid argument.
|
||||
if (primary_value.has_value())
|
||||
return Error::from_code(ErrorCode::InvalidArgument, DeprecatedString::formatted("Unable to merge capability {}", name));
|
||||
return Error::from_code(ErrorCode::InvalidArgument, ByteString::formatted("Unable to merge capability {}", name));
|
||||
|
||||
// e. Set a property on result with name name and value value.
|
||||
result.set(name, value);
|
||||
|
@ -267,20 +267,20 @@ static JsonValue match_capabilities(JsonObject const& capabilities)
|
|||
// -> "browserName"
|
||||
if (name == "browserName"sv) {
|
||||
// If value is not a string equal to the "browserName" entry in matched capabilities, return success with data null.
|
||||
if (value.as_string() != matched_capabilities.get_deprecated_string(name).value())
|
||||
if (value.as_string() != matched_capabilities.get_byte_string(name).value())
|
||||
return AK::Error::from_string_view("browserName"sv);
|
||||
}
|
||||
// -> "browserVersion"
|
||||
else if (name == "browserVersion"sv) {
|
||||
// Compare value to the "browserVersion" entry in matched capabilities using an implementation-defined comparison algorithm. The comparison is to accept a value that places constraints on the version using the "<", "<=", ">", and ">=" operators.
|
||||
// If the two values do not match, return success with data null.
|
||||
if (!matches_browser_version(value.as_string(), matched_capabilities.get_deprecated_string(name).value()))
|
||||
if (!matches_browser_version(value.as_string(), matched_capabilities.get_byte_string(name).value()))
|
||||
return AK::Error::from_string_view("browserVersion"sv);
|
||||
}
|
||||
// -> "platformName"
|
||||
else if (name == "platformName"sv) {
|
||||
// If value is not a string equal to the "platformName" entry in matched capabilities, return success with data null.
|
||||
if (!matches_platform_name(value.as_string(), matched_capabilities.get_deprecated_string(name).value()))
|
||||
if (!matches_platform_name(value.as_string(), matched_capabilities.get_byte_string(name).value()))
|
||||
return AK::Error::from_string_view("platformName"sv);
|
||||
}
|
||||
// -> "acceptInsecureCerts"
|
||||
|
|
|
@ -270,7 +270,7 @@ ErrorOr<void, Client::WrappedError> Client::handle_request(JsonValue body)
|
|||
if constexpr (WEBDRIVER_DEBUG) {
|
||||
dbgln("Got HTTP request: {} {}", m_request->method_name(), m_request->resource());
|
||||
if (!body.is_null())
|
||||
dbgln("Body: {}", body.to_deprecated_string());
|
||||
dbgln("Body: {}", body.to_byte_string());
|
||||
}
|
||||
|
||||
auto [handler, parameters] = TRY(match_route(*m_request));
|
||||
|
@ -345,7 +345,7 @@ ErrorOr<void, Client::WrappedError> Client::send_error_response(Error const& err
|
|||
|
||||
void Client::log_response(unsigned code)
|
||||
{
|
||||
outln("{} :: {:03d} :: {} {}", Core::DateTime::now().to_deprecated_string(), code, m_request->method_name(), m_request->resource());
|
||||
outln("{} :: {:03d} :: {} {}", Core::DateTime::now().to_byte_string(), code, m_request->method_name(), m_request->resource());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ JsonObject window_proxy_reference_object(HTML::WindowProxy const& window)
|
|||
|
||||
// identifier
|
||||
// Associated window handle of the window’s browsing context.
|
||||
object.set(identifier, window.associated_browsing_context()->window_handle().to_deprecated_string());
|
||||
object.set(identifier, window.associated_browsing_context()->window_handle().to_byte_string());
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::WebDriver {
|
|||
struct ErrorCodeData {
|
||||
ErrorCode error_code;
|
||||
unsigned http_status;
|
||||
DeprecatedString json_error_code;
|
||||
ByteString json_error_code;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-error-code
|
||||
|
@ -49,7 +49,7 @@ static Vector<ErrorCodeData> const s_error_code_data = {
|
|||
{ ErrorCode::OutOfMemory, 500, "out of memory" },
|
||||
};
|
||||
|
||||
Error Error::from_code(ErrorCode code, DeprecatedString message, Optional<JsonValue> data)
|
||||
Error Error::from_code(ErrorCode code, ByteString message, Optional<JsonValue> data)
|
||||
{
|
||||
auto const& error_code_data = s_error_code_data[to_underlying(code)];
|
||||
|
||||
|
@ -67,7 +67,7 @@ Error::Error(AK::Error const& error)
|
|||
*this = from_code(ErrorCode::OutOfMemory, {}, {});
|
||||
}
|
||||
|
||||
Error::Error(unsigned http_status_, DeprecatedString error_, DeprecatedString message_, Optional<JsonValue> data_)
|
||||
Error::Error(unsigned http_status_, ByteString error_, ByteString message_, Optional<JsonValue> data_)
|
||||
: http_status(http_status_)
|
||||
, error(move(error_))
|
||||
, message(move(message_))
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/JsonValue.h>
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
@ -50,13 +50,13 @@ enum class ErrorCode {
|
|||
// https://w3c.github.io/webdriver/#errors
|
||||
struct Error {
|
||||
unsigned http_status;
|
||||
DeprecatedString error;
|
||||
DeprecatedString message;
|
||||
ByteString error;
|
||||
ByteString message;
|
||||
Optional<JsonValue> data;
|
||||
|
||||
static Error from_code(ErrorCode, DeprecatedString message, Optional<JsonValue> data = {});
|
||||
static Error from_code(ErrorCode, ByteString message, Optional<JsonValue> data = {});
|
||||
|
||||
Error(unsigned http_status, DeprecatedString error, DeprecatedString message, Optional<JsonValue> data);
|
||||
Error(unsigned http_status, ByteString error, ByteString message, Optional<JsonValue> data);
|
||||
Error(AK::Error const&);
|
||||
};
|
||||
|
||||
|
@ -66,6 +66,6 @@ template<>
|
|||
struct AK::Formatter<Web::WebDriver::Error> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Web::WebDriver::Error const& error)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, DeprecatedString::formatted("Error {}, {}: {}", error.http_status, error.error, error.message));
|
||||
return Formatter<StringView>::format(builder, ByteString::formatted("Error {}, {}: {}", error.http_status, error.error, error.message));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -99,7 +99,7 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> internal_json_clone_algorithm
|
|||
if (value.is_number())
|
||||
return JsonValue { value.as_double() };
|
||||
if (value.is_string())
|
||||
return JsonValue { value.as_string().deprecated_string() };
|
||||
return JsonValue { value.as_string().byte_string() };
|
||||
|
||||
// NOTE: BigInt and Symbol not mentioned anywhere in the WebDriver spec, as it references ES5.
|
||||
// It assumes that all primitives are handled above, and the value is an object for the remaining steps.
|
||||
|
@ -130,7 +130,7 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> internal_json_clone_algorithm
|
|||
auto to_json_result = TRY_OR_JS_ERROR(to_json.as_function().internal_call(value, JS::MarkedVector<JS::Value> { vm.heap() }));
|
||||
if (!to_json_result.is_string())
|
||||
return ExecuteScriptResultType::JavaScriptError;
|
||||
return to_json_result.as_string().deprecated_string();
|
||||
return to_json_result.as_string().byte_string();
|
||||
}
|
||||
|
||||
// -> Otherwise
|
||||
|
@ -220,7 +220,7 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> clone_an_object(JS::Realm& re
|
|||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-execute-a-function-body
|
||||
static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> parameters)
|
||||
static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page, ByteString const& body, JS::MarkedVector<JS::Value> parameters)
|
||||
{
|
||||
// FIXME: If at any point during the algorithm a user prompt appears, immediately return Completion { [[Type]]: normal, [[Value]]: null, [[Target]]: empty }, but continue to run the other steps of this algorithm in parallel.
|
||||
|
||||
|
@ -237,7 +237,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
|
|||
auto& realm = window.realm();
|
||||
|
||||
bool contains_direct_call_to_eval = false;
|
||||
auto source_text = DeprecatedString::formatted("function() {{ {} }}", body);
|
||||
auto source_text = ByteString::formatted("function() {{ {} }}", body);
|
||||
auto parser = JS::Parser { JS::Lexer { source_text } };
|
||||
auto function_expression = parser.parse_function_node<JS::FunctionExpression>();
|
||||
|
||||
|
@ -282,7 +282,7 @@ static JS::ThrowCompletionOr<JS::Value> execute_a_function_body(Web::Page& page,
|
|||
return completion;
|
||||
}
|
||||
|
||||
ExecuteScriptResultSerialized execute_script(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
|
||||
ExecuteScriptResultSerialized execute_script(Web::Page& page, ByteString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
|
||||
{
|
||||
// FIXME: Use timeout.
|
||||
(void)timeout;
|
||||
|
@ -323,7 +323,7 @@ ExecuteScriptResultSerialized execute_script(Web::Page& page, DeprecatedString c
|
|||
return { result.type, json_value_or_error.release_value() };
|
||||
}
|
||||
|
||||
ExecuteScriptResultSerialized execute_async_script(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
|
||||
ExecuteScriptResultSerialized execute_async_script(Web::Page& page, ByteString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
|
||||
{
|
||||
auto* document = page.top_level_browsing_context().active_document();
|
||||
auto* window = page.top_level_browsing_context().active_window();
|
||||
|
|
|
@ -32,7 +32,7 @@ struct ExecuteScriptResultSerialized {
|
|||
JsonValue value;
|
||||
};
|
||||
|
||||
ExecuteScriptResultSerialized execute_script(Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
|
||||
ExecuteScriptResultSerialized execute_async_script(Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
|
||||
ExecuteScriptResultSerialized execute_script(Page& page, ByteString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
|
||||
ExecuteScriptResultSerialized execute_async_script(Page& page, ByteString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout);
|
||||
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ ErrorOr<Web::WebDriver::Response> IPC::decode(Decoder& decoder)
|
|||
|
||||
case ResponseType::Error: {
|
||||
auto http_status = TRY(decoder.decode<unsigned>());
|
||||
auto error = TRY(decoder.decode<DeprecatedString>());
|
||||
auto message = TRY(decoder.decode<DeprecatedString>());
|
||||
auto error = TRY(decoder.decode<ByteString>());
|
||||
auto message = TRY(decoder.decode<ByteString>());
|
||||
auto data = TRY(decoder.decode<Optional<JsonValue>>());
|
||||
|
||||
return Web::WebDriver::Error { http_status, move(error), move(message), move(data) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue