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

Browser+WebContent+WebDriver: Move Add Cookie to WebContent

The new implementation is made a bit simpler by way of TRY. It also
implements setting the SameSite attribute.
This commit is contained in:
Timothy Flynn 2022-11-11 11:00:45 -05:00 committed by Linus Groh
parent fce9fcf154
commit 18abc6c85d
9 changed files with 86 additions and 137 deletions

View file

@ -69,20 +69,6 @@ Messages::WebDriverSessionClient::GetAllCookiesResponse WebDriverConnection::get
return { {} };
}
void WebDriverConnection::add_cookie(Web::Cookie::ParsedCookie const& cookie)
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: add_cookie {}", cookie.name);
if (auto browser_window = m_browser_window.strong_ref()) {
auto& tab = browser_window->active_tab();
if (tab.on_set_cookie) {
// FIXME: The spec doesn't say anything about the source
// but can we assume a cookie created through a HTTP-request to the WebDriver
// to be (source) from an HTTP-API?
tab.on_set_cookie(tab.url(), cookie, Web::Cookie::Source::Http);
}
}
}
void WebDriverConnection::update_cookie(Web::Cookie::Cookie const& cookie)
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: update_cookie {}", cookie.name);

View file

@ -43,7 +43,6 @@ public:
virtual void back() override;
virtual void forward() override;
virtual Messages::WebDriverSessionClient::GetAllCookiesResponse get_all_cookies() override;
virtual void add_cookie(Web::Cookie::ParsedCookie const&) override;
virtual void update_cookie(Web::Cookie::Cookie const&) override;
private:

View file

@ -19,6 +19,5 @@ endpoint WebDriverSessionClient {
back() =|
forward() =|
get_all_cookies() => (Vector<Web::Cookie::Cookie> cookies)
add_cookie(Web::Cookie::ParsedCookie cookie) =|
update_cookie(Web::Cookie::Cookie cookie) =|
}