Bug 248309 - notification.close() not working
Summary: notification.close() not working
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-11-24 08:11 PST by Andy
Modified: 2022-11-29 01:36 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy 2022-11-24 08:11:01 PST
Calling notification.close() (from both inside and outside a service worker) doesn't remove the notification(s)

Use case:
Removing notifications that no longer apply to user, for instance if they have visited a page the notification would take them to.


To replicate
- Have a notification in Notification Centre created by current site
- get all notifications, then call notification.close()


From a window:
navigator.serviceWorker.ready.then(function(registration) {
	registration.getNotifications().then((notifications) => {
		for (let notification of notifications) {
			notification.close()
		}
	})
})

From within a service worker:
self.registration.getNotifications().then((notifications) => {
	for (let notification of notifications) {
		notification.close()
	}
})

Expected results
The notification in notification is removed

Actual result
The notification remains
Comment 1 Radar WebKit Bug Importer 2022-11-26 14:45:24 PST
<rdar://problem/102683841>
Comment 2 youenn fablet 2022-11-28 05:23:43 PST
Pull request: https://github.com/WebKit/WebKit/pull/6856
Comment 3 EWS 2022-11-29 01:36:33 PST
Committed 257108@main (d02120f1bc06): <https://commits.webkit.org/257108@main>

Reviewed commits have been landed. Closing PR #6856 and removing active labels.