[webkit-changes] [WebKit/WebKit] 90ca34: [Cookie Store API] Ensure event listener uses cook...

Rupin Mittal noreply at github.com
Tue Jan 14 17:36:39 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 90ca349aa08cc917dcf128f61cd9cc061197a315
      https://github.com/WebKit/WebKit/commit/90ca349aa08cc917dcf128f61cd9cc061197a315
  Author: Rupin Mittal <rupin at apple.com>
  Date:   2025-01-14 (Tue, 14 Jan 2025)

  Changed paths:
    M Source/WebCore/Modules/cookie-store/CookieStore.cpp

  Log Message:
  -----------
  [Cookie Store API] Ensure event listener uses cookie creation time to decide whether it was deleted or changed
https://bugs.webkit.org/show_bug.cgi?id=285628
rdar://142518999

Reviewed by Sihui Liu.

When the event listener is fired, we must decide whether the cookie
was changed or deleted so we can fire the correct type of event.

Current logic (incorrect):
if (cookie.expires < currentTime) --> it was deleted
else --> it was changed

This is wrong because currentTime is the time of the event firing, not cookie creation.
We see this causing a problem in the test site. If the expiry time is really small,
say 0.1 seconds from now, the event will fire after the expiry, so we'll say the cookie
was deleted instead of changed. This is flaky as well. We should instead be comparing
with the creation time of the cookie.

New logic (correct):
if (cookie.expires <= cookie.created) --> it was deleted
else --> it was changed

We need to expire in the (cookie.expires = cookie.created) case because of
the case where a cookie is set using document.cookie with max-age=0. In that
case, the cookie is expires as soon as it's set, which is considered deletion
(see the wpt test cookie-store/change_eventhandler_for_document_cookie.https.window.html)

This is verified by testing using the test case in the radar.

* Source/WebCore/Modules/cookie-store/CookieStore.cpp:
(WebCore::CookieStore::cookiesAdded):

Canonical link: https://commits.webkit.org/288908@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list