mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 02:37:35 +00:00
WebDriver: Implement POST /session/{id}/refresh
endpoint
This commit is contained in:
parent
8653903bee
commit
1179d951f6
7 changed files with 48 additions and 0 deletions
|
@ -26,6 +26,7 @@ Vector<Client::Route> Client::s_routes = {
|
|||
{ HTTP::HttpRequest::Method::GET, { "session", ":session_id", "url" }, &Client::handle_get_url },
|
||||
{ HTTP::HttpRequest::Method::GET, { "session", ":session_id", "title" }, &Client::handle_get_title },
|
||||
{ HTTP::HttpRequest::Method::DELETE, { "session", ":session_id", "window" }, &Client::handle_delete_window },
|
||||
{ HTTP::HttpRequest::Method::POST, { "session", ":session_id", "refresh" }, &Client::handle_refresh },
|
||||
};
|
||||
|
||||
Client::Client(NonnullOwnPtr<Core::Stream::BufferedTCPSocket> socket, Core::Object* parent)
|
||||
|
@ -451,4 +452,15 @@ ErrorOr<JsonValue, HttpError> Client::handle_delete_window(Vector<StringView> pa
|
|||
return make_json_value(JsonValue());
|
||||
}
|
||||
|
||||
// POST /session/{session id}/refresh https://w3c.github.io/webdriver/#dfn-refresh
|
||||
ErrorOr<JsonValue, HttpError> Client::handle_refresh(Vector<StringView> parameters, JsonValue const&)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling POST /session/<session_id>/refresh");
|
||||
Session* session = TRY(find_session_with_id(parameters[0]));
|
||||
|
||||
// NOTE: Spec steps handled in Session::refresh().
|
||||
auto result = TRY(session->refresh());
|
||||
return make_json_value(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ private:
|
|||
ErrorOr<JsonValue, HttpError> handle_get_url(Vector<StringView>, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_get_title(Vector<StringView>, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_delete_window(Vector<StringView>, JsonValue const& payload);
|
||||
ErrorOr<JsonValue, HttpError> handle_refresh(Vector<StringView>, JsonValue const& payload);
|
||||
|
||||
ErrorOr<Session*, HttpError> find_session_with_id(StringView session_id);
|
||||
JsonValue make_json_value(JsonValue const&);
|
||||
|
|
|
@ -158,4 +158,29 @@ ErrorOr<JsonValue, HttpError> Session::get_title()
|
|||
return JsonValue(m_browser_connection->get_title());
|
||||
}
|
||||
|
||||
// POST /session/{session id}/refresh https://w3c.github.io/webdriver/#dfn-refresh
|
||||
ErrorOr<JsonValue, HttpError> Session::refresh()
|
||||
{
|
||||
// 1. If the current top-level browsing context is no longer open, return error with error code no such window.
|
||||
auto current_window = get_window_object();
|
||||
if (!current_window.has_value())
|
||||
return HttpError { 404, "no such window", "Window not found" };
|
||||
|
||||
// FIXME: 2. Handle any user prompts and return its value if it is an error.
|
||||
|
||||
// 3. Initiate an overridden reload of the current top-level browsing context’s active document.
|
||||
m_browser_connection->async_refresh();
|
||||
|
||||
// FIXME: 4. If url is special except for file:
|
||||
|
||||
// FIXME: 1. Try to wait for navigation to complete.
|
||||
|
||||
// FIXME: 2. Try to run the post-navigation checks.
|
||||
|
||||
// FIXME: 5. Set the current browsing context with current top-level browsing context.
|
||||
|
||||
// 6. Return success with data null.
|
||||
return JsonValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
ErrorOr<JsonValue, HttpError> post_url(JsonValue const& url);
|
||||
ErrorOr<JsonValue, HttpError> get_url();
|
||||
ErrorOr<JsonValue, HttpError> get_title();
|
||||
ErrorOr<JsonValue, HttpError> refresh();
|
||||
|
||||
private:
|
||||
NonnullRefPtr<Client> m_client;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue