mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:47:34 +00:00
Browser+WebContent+WebDriver: Move Delete All Cookies to WebContent
This commit is contained in:
parent
b7f21bb92e
commit
ff6055e0a3
9 changed files with 18 additions and 69 deletions
|
@ -789,8 +789,7 @@ Web::WebDriver::Response Client::handle_delete_all_cookies(Vector<StringView> co
|
|||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session/<session_id>/cookie");
|
||||
auto* session = TRY(find_session_with_id(parameters[0]));
|
||||
auto result = TRY(session->delete_all_cookies());
|
||||
return make_json_value(result);
|
||||
return session->web_content_connection().delete_all_cookies();
|
||||
}
|
||||
|
||||
// 17.1 Take Screenshot, https://w3c.github.io/webdriver/#take-screenshot
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
#include <LibGfx/Point.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibWeb/Cookie/Cookie.h>
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
#include <LibWeb/WebDriver/ExecuteScript.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace WebDriver {
|
||||
|
@ -297,37 +294,4 @@ Web::WebDriver::Response Session::get_window_handles() const
|
|||
return JsonValue { handles };
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-delete-cookies
|
||||
void Session::delete_cookies(Optional<StringView> const& name)
|
||||
{
|
||||
// For each cookie among all associated cookies of the current browsing context’s active document,
|
||||
// run the substeps of the first matching condition:
|
||||
for (auto& cookie : m_browser_connection->get_all_cookies()) {
|
||||
// -> name is undefined
|
||||
// -> name is equal to cookie name
|
||||
if (!name.has_value() || name.value() == cookie.name) {
|
||||
// Set the cookie expiry time to a Unix timestamp in the past.
|
||||
cookie.expiry_time = Core::DateTime::from_timestamp(0);
|
||||
m_browser_connection->async_update_cookie(cookie);
|
||||
}
|
||||
// -> Otherwise
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
// 14.5 Delete All Cookies, https://w3c.github.io/webdriver/#dfn-delete-all-cookies
|
||||
Web::WebDriver::Response Session::delete_all_cookies()
|
||||
{
|
||||
// 1. If the current browsing context is no longer open, return error with error code no such window.
|
||||
TRY(check_for_open_top_level_browsing_context_or_return_error());
|
||||
|
||||
// FIXME: 2. Handle any user prompts, and return its value if it is an error.
|
||||
|
||||
// 3. Delete cookies, giving no filtering argument.
|
||||
delete_cookies();
|
||||
|
||||
// 4. Return success with data null.
|
||||
return JsonValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,12 +58,9 @@ public:
|
|||
Web::WebDriver::Response get_window_handle();
|
||||
ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window();
|
||||
Web::WebDriver::Response get_window_handles() const;
|
||||
Web::WebDriver::Response delete_all_cookies();
|
||||
Web::WebDriver::Response take_element_screenshot(StringView element_id);
|
||||
|
||||
private:
|
||||
void delete_cookies(Optional<StringView> const& name = {});
|
||||
|
||||
enum class ServerType {
|
||||
Browser,
|
||||
WebContent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue