mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
Browser+WebContent+WebDriver: Move Get All Cookies to WebContent
There are a couple changes here from the existing Get All Cookies implementation. 1. Previously, WebDriver actually returned *all* cookies in the cookie jar. The spec dictates that we only return cookies that match the document's URL. Specifically, it calls out that we must run just the first step of RFC 6265 section 5.4 to perform domain matching. This change adds a special mode to our implementation of that section to skip the remaining steps. 2. We now fill in the SameSite cookie attribute when serializing the cookie to JSON (this was a trival FIXME that didn't get picked up when SameSite was implemented).
This commit is contained in:
parent
d2c1957d8f
commit
c77260c480
11 changed files with 89 additions and 29 deletions
|
@ -313,30 +313,6 @@ static JsonObject serialize_cookie(Web::Cookie::Cookie const& cookie)
|
|||
return serialized_cookie;
|
||||
}
|
||||
|
||||
// 14.1 Get All Cookies, https://w3c.github.io/webdriver/#dfn-get-all-cookies
|
||||
Web::WebDriver::Response Session::get_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. Let cookies be a new JSON List.
|
||||
JsonArray cookies = {};
|
||||
|
||||
// 4. For each cookie in all associated cookies of the current browsing context’s active document:
|
||||
for (auto const& cookie : m_browser_connection->get_all_cookies()) {
|
||||
// 1. Let serialized cookie be the result of serializing cookie.
|
||||
auto serialized_cookie = serialize_cookie(cookie);
|
||||
|
||||
// 2. Append serialized cookie to cookies
|
||||
cookies.append(serialized_cookie);
|
||||
}
|
||||
|
||||
// 5. Return success with data cookies.
|
||||
return JsonValue(cookies);
|
||||
}
|
||||
|
||||
// 14.2 Get Named Cookie, https://w3c.github.io/webdriver/#dfn-get-named-cookie
|
||||
Web::WebDriver::Response Session::get_named_cookie(String const& name)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue