LibWebView: Notify cookie-change listeners after changing them
Cookie listeners may query the jar while handling a notification. For example, DevTools does this when the Storage panel computes whether a cookie was added, changed, or deleted. Insert the cookie before sending the notification, so that listeners see the new state, not the old one.
This commit is contained in:
parent
31ffb2f214
commit
b2724268fe
1 changed files with 7 additions and 4 deletions
|
|
@ -565,17 +565,20 @@ void CookieJar::TransientStorage::set_cookie(CookieStorageKey key, HTTP::Cookie:
|
|||
if (cookie.expiry_time < now && !m_cookies.contains(key))
|
||||
return;
|
||||
|
||||
// We skip notifying about updating expired cookies, as they will be notified as being expired immediately after instead
|
||||
auto cookie_value_changed = true;
|
||||
if (cookie.expiry_time >= now) {
|
||||
auto cookie_value_changed = true;
|
||||
if (auto old_cookie = m_cookies.get(key); old_cookie.has_value())
|
||||
cookie_value_changed = old_cookie->value != cookie.value;
|
||||
|
||||
send_cookie_changed_notifications({ { CookieEntry { {}, cookie } } }, cookie_value_changed);
|
||||
}
|
||||
|
||||
auto cookie_for_notification = cookie;
|
||||
m_cookies.set(key, cookie);
|
||||
m_dirty_cookies.set(move(key), move(cookie));
|
||||
|
||||
// We skip notifying about updating expired cookies, as they will be notified as being
|
||||
// expired immediately after instead.
|
||||
if (cookie_for_notification.expiry_time >= now)
|
||||
send_cookie_changed_notifications({ { CookieEntry { {}, move(cookie_for_notification) } } }, cookie_value_changed);
|
||||
}
|
||||
|
||||
Optional<HTTP::Cookie::Cookie const&> CookieJar::TransientStorage::get_cookie(CookieStorageKey const& key)
|
||||
|
|
|
|||
Loading…
Reference in a new issue