mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
LibWeb+WebContent+WebDriver: Port WebDriver to String
This commit is contained in:
@@ -30,14 +30,14 @@
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
||||
#define TRY_OR_JS_ERROR(expression) \
|
||||
({ \
|
||||
auto&& _temporary_result = (expression); \
|
||||
if (_temporary_result.is_error()) [[unlikely]] \
|
||||
return WebDriver::Error::from_code(ErrorCode::JavascriptError, "Script returned an error"); \
|
||||
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
|
||||
"Do not return a reference from a fallible expression"); \
|
||||
_temporary_result.release_value(); \
|
||||
#define TRY_OR_JS_ERROR(expression) \
|
||||
({ \
|
||||
auto&& _temporary_result = (expression); \
|
||||
if (_temporary_result.is_error()) [[unlikely]] \
|
||||
return WebDriver::Error::from_code(ErrorCode::JavascriptError, "Script returned an error"sv); \
|
||||
static_assert(!::AK::Detail::IsLvalueReference<decltype(_temporary_result.release_value())>, \
|
||||
"Do not return a reference from a fallible expression"); \
|
||||
_temporary_result.release_value(); \
|
||||
})
|
||||
|
||||
using SeenMap = HashTable<GC::RawPtr<JS::Object const>>;
|
||||
@@ -120,7 +120,7 @@ static ErrorOr<ResultType, WebDriver::Error> clone_an_object(HTML::BrowsingConte
|
||||
// script to be run and that script throws an error, return error with error code javascript error.
|
||||
auto source_property_value = value.get(name);
|
||||
if (source_property_value.is_error()) {
|
||||
error = WebDriver::Error::from_code(ErrorCode::JavascriptError, "Script returned an error");
|
||||
error = WebDriver::Error::from_code(ErrorCode::JavascriptError, "Script returned an error"sv);
|
||||
return JS::normal_completion({});
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ static Response internal_json_clone(HTML::BrowsingContext const& browsing_contex
|
||||
if (value.is_number())
|
||||
return JsonValue { value.as_double() };
|
||||
if (value.is_string())
|
||||
return JsonValue { value.as_string().byte_string() };
|
||||
return JsonValue { value.as_string().utf8_string() };
|
||||
|
||||
// AD-HOC: 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.
|
||||
@@ -257,7 +257,7 @@ static Response internal_json_clone(HTML::BrowsingContext const& browsing_contex
|
||||
if (!to_json_result.is_string())
|
||||
return WebDriver::Error::from_code(ErrorCode::JavascriptError, "toJSON did not return a String"sv);
|
||||
|
||||
return JsonValue { to_json_result.as_string().byte_string() };
|
||||
return JsonValue { to_json_result.as_string().utf8_string() };
|
||||
}
|
||||
|
||||
// -> Otherwise
|
||||
|
||||
Reference in New Issue
Block a user