mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb+WebContent+WebDriver: Port WebDriver to String
This commit is contained in:
parent
bc54c0cdfb
commit
9879ac0893
Notes:
github-actions[bot]
2025-02-21 00:29:12 +00:00
Author: https://github.com/trflynn89
Commit: 9879ac0893
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3631
Reviewed-by: https://github.com/awesomekling ✅
21 changed files with 194 additions and 190 deletions
|
@ -13,43 +13,43 @@ namespace Web::WebDriver {
|
|||
struct ErrorCodeData {
|
||||
ErrorCode error_code;
|
||||
unsigned http_status;
|
||||
ByteString json_error_code;
|
||||
String json_error_code;
|
||||
};
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-error-code
|
||||
static Vector<ErrorCodeData> const s_error_code_data = {
|
||||
{ ErrorCode::ElementClickIntercepted, 400, "element click intercepted" },
|
||||
{ ErrorCode::ElementNotInteractable, 400, "element not interactable" },
|
||||
{ ErrorCode::InsecureCertificate, 400, "insecure certificate" },
|
||||
{ ErrorCode::InvalidArgument, 400, "invalid argument" },
|
||||
{ ErrorCode::InvalidCookieDomain, 400, "invalid cookie domain" },
|
||||
{ ErrorCode::InvalidElementState, 400, "invalid element state" },
|
||||
{ ErrorCode::InvalidSelector, 400, "invalid selector" },
|
||||
{ ErrorCode::InvalidSessionId, 404, "invalid session id" },
|
||||
{ ErrorCode::JavascriptError, 500, "javascript error" },
|
||||
{ ErrorCode::MoveTargetOutOfBounds, 500, "move target out of bounds" },
|
||||
{ ErrorCode::NoSuchAlert, 404, "no such alert" },
|
||||
{ ErrorCode::NoSuchCookie, 404, "no such cookie" },
|
||||
{ ErrorCode::NoSuchElement, 404, "no such element" },
|
||||
{ ErrorCode::NoSuchFrame, 404, "no such frame" },
|
||||
{ ErrorCode::NoSuchWindow, 404, "no such window" },
|
||||
{ ErrorCode::NoSuchShadowRoot, 404, "no such shadow root" },
|
||||
{ ErrorCode::ScriptTimeoutError, 500, "script timeout" },
|
||||
{ ErrorCode::SessionNotCreated, 500, "session not created" },
|
||||
{ ErrorCode::StaleElementReference, 404, "stale element reference" },
|
||||
{ ErrorCode::DetachedShadowRoot, 404, "detached shadow root" },
|
||||
{ ErrorCode::Timeout, 500, "timeout" },
|
||||
{ ErrorCode::UnableToSetCookie, 500, "unable to set cookie" },
|
||||
{ ErrorCode::UnableToCaptureScreen, 500, "unable to capture screen" },
|
||||
{ ErrorCode::UnexpectedAlertOpen, 500, "unexpected alert open" },
|
||||
{ ErrorCode::UnknownCommand, 404, "unknown command" },
|
||||
{ ErrorCode::UnknownError, 500, "unknown error" },
|
||||
{ ErrorCode::UnknownMethod, 405, "unknown method" },
|
||||
{ ErrorCode::UnsupportedOperation, 500, "unsupported operation" },
|
||||
{ ErrorCode::OutOfMemory, 500, "out of memory" },
|
||||
{ ErrorCode::ElementClickIntercepted, 400, "element click intercepted"_string },
|
||||
{ ErrorCode::ElementNotInteractable, 400, "element not interactable"_string },
|
||||
{ ErrorCode::InsecureCertificate, 400, "insecure certificate"_string },
|
||||
{ ErrorCode::InvalidArgument, 400, "invalid argument"_string },
|
||||
{ ErrorCode::InvalidCookieDomain, 400, "invalid cookie domain"_string },
|
||||
{ ErrorCode::InvalidElementState, 400, "invalid element state"_string },
|
||||
{ ErrorCode::InvalidSelector, 400, "invalid selector"_string },
|
||||
{ ErrorCode::InvalidSessionId, 404, "invalid session id"_string },
|
||||
{ ErrorCode::JavascriptError, 500, "javascript error"_string },
|
||||
{ ErrorCode::MoveTargetOutOfBounds, 500, "move target out of bounds"_string },
|
||||
{ ErrorCode::NoSuchAlert, 404, "no such alert"_string },
|
||||
{ ErrorCode::NoSuchCookie, 404, "no such cookie"_string },
|
||||
{ ErrorCode::NoSuchElement, 404, "no such element"_string },
|
||||
{ ErrorCode::NoSuchFrame, 404, "no such frame"_string },
|
||||
{ ErrorCode::NoSuchWindow, 404, "no such window"_string },
|
||||
{ ErrorCode::NoSuchShadowRoot, 404, "no such shadow root"_string },
|
||||
{ ErrorCode::ScriptTimeoutError, 500, "script timeout"_string },
|
||||
{ ErrorCode::SessionNotCreated, 500, "session not created"_string },
|
||||
{ ErrorCode::StaleElementReference, 404, "stale element reference"_string },
|
||||
{ ErrorCode::DetachedShadowRoot, 404, "detached shadow root"_string },
|
||||
{ ErrorCode::Timeout, 500, "timeout"_string },
|
||||
{ ErrorCode::UnableToSetCookie, 500, "unable to set cookie"_string },
|
||||
{ ErrorCode::UnableToCaptureScreen, 500, "unable to capture screen"_string },
|
||||
{ ErrorCode::UnexpectedAlertOpen, 500, "unexpected alert open"_string },
|
||||
{ ErrorCode::UnknownCommand, 404, "unknown command"_string },
|
||||
{ ErrorCode::UnknownError, 500, "unknown error"_string },
|
||||
{ ErrorCode::UnknownMethod, 405, "unknown method"_string },
|
||||
{ ErrorCode::UnsupportedOperation, 500, "unsupported operation"_string },
|
||||
{ ErrorCode::OutOfMemory, 500, "out of memory"_string },
|
||||
};
|
||||
|
||||
Error Error::from_code(ErrorCode code, ByteString message, Optional<JsonValue> data)
|
||||
Error Error::from_code(ErrorCode code, String message, Optional<JsonValue> data)
|
||||
{
|
||||
auto const& error_code_data = s_error_code_data[to_underlying(code)];
|
||||
|
||||
|
@ -61,13 +61,18 @@ Error Error::from_code(ErrorCode code, ByteString message, Optional<JsonValue> d
|
|||
};
|
||||
}
|
||||
|
||||
Error Error::from_code(ErrorCode code, StringView message, Optional<JsonValue> data)
|
||||
{
|
||||
return from_code(code, String::from_utf8_without_validation(message.bytes()), move(data));
|
||||
}
|
||||
|
||||
Error::Error(AK::Error const& error)
|
||||
{
|
||||
VERIFY(error.code() == ENOMEM);
|
||||
*this = from_code(ErrorCode::OutOfMemory, {}, {});
|
||||
*this = from_code(ErrorCode::OutOfMemory, String {}, {});
|
||||
}
|
||||
|
||||
Error::Error(unsigned http_status_, ByteString error_, ByteString message_, Optional<JsonValue> data_)
|
||||
Error::Error(unsigned http_status_, String error_, String message_, Optional<JsonValue> data_)
|
||||
: http_status(http_status_)
|
||||
, error(move(error_))
|
||||
, message(move(message_))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue