Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e64287e8977f5c4445ef74621f35416737f28aa6
      
https://github.com/WebKit/WebKit/commit/e64287e8977f5c4445ef74621f35416737f28aa6
  Author: Chris Dumez <[email protected]>
  Date:   2026-07-27 (Mon, 27 Jul 2026)

  Changed paths:
    M Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp
    M Tools/TestWebKitAPI/Helpers/TestNotificationProvider.cpp
    M Tools/TestWebKitAPI/Helpers/TestNotificationProvider.h
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/PushAPI.mm

  Log Message:
  -----------
  providerDidCloseNotifications() stops closing notifications after the first 
persistent one
https://bugs.webkit.org/show_bug.cgi?id=320162

Reviewed by Brady Eidson.

WebNotificationManagerProxy::providerDidCloseNotifications() iterates over the
array of notification identifiers passed by the notification provider and closes
each one. For a persistent (service worker) notification, it dispatched the 
close
event to the service worker and then did `return;` instead of `continue;`, which
had two consequences:

- Any notification identifiers appearing after the first persistent notification
  in the batch were never processed: they were not closed and no
  DidCloseNotifications message was sent for them.
- The persistent notification had already been removed from m_notifications via
  take(), but the early return skipped removing its entry from
  m_globalNotificationMap, leaving a stale identifier mapping behind.

Every other skip case in the same loop already uses `continue;`; this one should
too. Replace the `return;` with `continue;`.

The existing TestNotificationProvider could only close a single notification per
provider callback (it tracked one pending notification and built a one-element
array), so the batch path was never exercised. Extend it to remember every shown
notification and add simulateMultipleNotificationsClose(), which closes them all
in a single WKNotificationManagerProviderDidCloseNotifications() call. The
now-redundant single m_pendingNotification member is removed and the existing
simulateNotificationClick()/simulateNotificationClose() helpers are 
reimplemented
on top of m_pendingNotifications.

Add a regression test that shows two persistent notifications, closes them in 
one
provider callback, and verifies both fire a notificationclose event.

Test: PushAPI.fireMultipleNotificationCloseEvents

* Source/WebKit/UIProcess/Notifications/WebNotificationManagerProxy.cpp:
(WebKit::WebNotificationManagerProxy::providerDidCloseNotifications):
* Tools/TestWebKitAPI/Helpers/TestNotificationProvider.cpp:
(TestWebKitAPI::TestNotificationProvider::~TestNotificationProvider):
(TestWebKitAPI::TestNotificationProvider::showWebNotification):
(TestWebKitAPI::TestNotificationProvider::simulateNotificationClick):
(TestWebKitAPI::TestNotificationProvider::simulateNotificationClose):
(TestWebKitAPI::TestNotificationProvider::simulateMultipleNotificationsClose):
* Tools/TestWebKitAPI/Helpers/TestNotificationProvider.h:
(TestWebKitAPI::TestNotificationProvider::pendingNotificationCount const):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/PushAPI.mm:
(-[CountNotificationCloseMessageHandler 
userContentController:didReceiveScriptMessage:]):
((PushAPI, fireMultipleNotificationCloseEvents)):

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



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

Reply via email to