1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

WebDriver: Move GET /session/{session id}/window impl into Session

This commit is contained in:
Linus Groh 2022-10-19 19:39:54 +02:00
parent 0064d2e8c8
commit 24ee5a2202
3 changed files with 16 additions and 7 deletions

View file

@ -235,6 +235,18 @@ ErrorOr<JsonValue, HttpError> Session::get_title()
return JsonValue(m_browser_connection->get_title());
}
// 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle
ErrorOr<JsonValue, HttpError> Session::get_window_handle()
{
// 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" };
// 2. Return success with data being the window handle associated with the current top-level browsing context.
return m_current_window_handle;
}
// 11.2 Close Window, https://w3c.github.io/webdriver/#dfn-close-window
ErrorOr<void, Variant<HttpError, Error>> Session::close_window()
{