Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: cc35e71c66143f1777eb577bd3b81917356bd514
      
https://github.com/WebKit/WebKit/commit/cc35e71c66143f1777eb577bd3b81917356bd514
  Author: Chris Dumez <[email protected]>
  Date:   2026-06-04 (Thu, 04 Jun 2026)

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

  Log Message:
  -----------
  CookieStore: use the registration host/jar when removing the cookie change 
listener
https://bugs.webkit.org/show_bug.cgi?id=316153

Reviewed by Rupin Mittal.

CookieStore::eventListenersDidChange() and CookieStore::stop() recomputed
the host and cookie jar from the current Document state when removing a
cookie change listener, while WebCookieJar keys its listener map on the
host captured at addChangeListener() time. In practice a Document's URL
host does not change over its lifetime, so this has not been observed to
cause a leak, but the asymmetry is fragile: any future caller or context
where the host or page reference differs between add and remove time
would silently fail to unregister.

eventListenersDidChange() also returned early when the current host was
empty, before checking the listener-count transition, so a transition
back to "no listener" in an empty-host context would skip the remove
path entirely.

CookieStore already had unused m_host and m_cookieJar members that look
like the start of this fix; this change wires them up.

  - eventListenersDidChange() captures the host and cookie jar when a
    listener is added, and uses those stored values when the listener is
    later removed. The empty-host / no-page check now only short-circuits
    the add path, and resets m_hasChangeEventListener so we don't claim a
    registration we never made.
  - stop() removes via the stored m_cookieJar/m_host instead of
    re-deriving them.

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

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



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

Reply via email to