Add an event for all notifications that are being shown

UNCONFIRMED
Unassigned

Status

()

Toolkit
WebExtensions: Untriaged
--
enhancement
UNCONFIRMED
11 months ago
3 months ago

People

(Reporter: freaktechnik, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [design-decision-needed] triaged[notifications])

(Reporter)

Description

11 months ago
I propose an event in extensions that is fired, whenever a notification is shown. It should have rough category filters for its origin like "website", "webextension" and "native" or similar. The listener to the event would then receive a basic description of the notification, including title, icon, description and category.
This would already cover extensions that build on notifications to do things like notification mirroring or other actions upon notifications, like playing a specific sound etc.

If there then was the ability to listen to the event "blocking" and cancel a notification this would add notification filtering or notification deamon replacement (like gNotifier) to the possibilities of WebExtensions.

The reason I explicitly listed "webextension" as a distinct category and not "extensions", is because built-in notifications and notifications from XPCOM extensions look the same to the alerts service.
It might also be useful to pass on the origin URL of a notification.

So far this was (to my knowledge) only possible by replacing the nsIAlertService, which always was a sub-optimal solution. However I do think such an API would be easy to implement and shouldn't be too powerful.
(Reporter)

Updated

11 months ago
Whiteboard: [design-decision-needed]

Updated

11 months ago
Whiteboard: [design-decision-needed] → [design-decision-needed] triaged

Comment 1

10 months ago
There is some concern that this would allow WebExtensions to escape outside their sandbox and possibly have privacy or security concerns. Especially since there are lots of notifications across Firefox that we or may not know about.

Would it make sense to limit this to say just "websites" and have a similar set of URLs that we do for content scripts to limit the notifications to just some websites or all websites?
(Reporter)

Comment 2

10 months ago
If you limit it just to websites there is no need for an API - you can just use a content-script and try wrapping the API there.

The point of this API is to a degree to give deeper access to the notification daemon, if the content of certain notifications is potentially a security concern the content could just be omitted and just the source "native" or similar be given.

I am aware that canceling notifications is a bit of a stretch and very prone to "breaking Firefox", and I do not think it is necessary, but it would (as I wrote) massively expand the use-cases. Limiting what this method to just notifications to websites would probably be still interesting.

Updated

3 months ago
Whiteboard: [design-decision-needed] triaged → [design-decision-needed] triaged[notifications]
You need to log in before you can comment on or make changes to this bug.