1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-08-06 20:17:36 +00:00

WebDriver+Browser: Implement POST /session/{id}/window/rect

This commit is contained in:
Timothy Flynn 2022-11-02 09:33:24 -04:00 committed by Linus Groh
parent dac91c5790
commit 174248678e
7 changed files with 119 additions and 0 deletions

View file

@ -79,6 +79,29 @@ Messages::WebDriverSessionClient::GetWindowRectResponse WebDriverConnection::get
return { {} };
}
void WebDriverConnection::restore_window()
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: restore_window");
if (auto browser_window = m_browser_window.strong_ref()) {
browser_window->show();
browser_window->move_to_front();
}
}
void WebDriverConnection::set_window_size(Gfx::IntSize const& size)
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: set_window_size {}", size);
if (auto browser_window = m_browser_window.strong_ref())
browser_window->resize(size);
}
void WebDriverConnection::set_window_position(Gfx::IntPoint const& position)
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: set_window_position {}", position);
if (auto browser_window = m_browser_window.strong_ref())
browser_window->move_to(position);
}
Messages::WebDriverSessionClient::GetAllCookiesResponse WebDriverConnection::get_all_cookies()
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: get_cookies");

View file

@ -44,6 +44,9 @@ public:
virtual void back() override;
virtual void forward() override;
virtual Messages::WebDriverSessionClient::GetWindowRectResponse get_window_rect() override;
virtual void restore_window() override;
virtual void set_window_size(Gfx::IntSize const&) override;
virtual void set_window_position(Gfx::IntPoint const&) override;
virtual Messages::WebDriverSessionClient::GetAllCookiesResponse get_all_cookies() override;
virtual Messages::WebDriverSessionClient::GetNamedCookieResponse get_named_cookie(String const& name) override;
virtual void add_cookie(Web::Cookie::ParsedCookie const&) override;

View file

@ -1,6 +1,8 @@
#include <AK/URL.h>
#include <AK/Vector.h>
#include <LibGfx/Point.h>
#include <LibGfx/Rect.h>
#include <LibGfx/Size.h>
#include <LibWeb/Cookie/Cookie.h>
#include <LibWeb/Cookie/ParsedCookie.h>
@ -14,6 +16,9 @@ endpoint WebDriverSessionClient {
back() =|
forward() =|
get_window_rect() => (Gfx::IntRect rect)
restore_window() =|
set_window_size(Gfx::IntSize size) =|
set_window_position(Gfx::IntPoint position) =|
get_all_cookies() => (Vector<Web::Cookie::Cookie> cookies)
get_named_cookie(String name) => (Optional<Web::Cookie::Cookie> cookie)
add_cookie(Web::Cookie::ParsedCookie cookie) =|