Closed Bug 1105222 Opened 9 years ago Closed 8 months ago

[meta] Support custom sound files for Web Notifications


(Core :: DOM: Notifications, defect)






(Reporter: mikedeboer, Unassigned)


(Depends on 4 open bugs, )


(Keywords: meta)


(1 file)

DOM Web Notifications in Gecko sports a NotificationBehavior dictionary, which allow to specify a custom sound file to be played when the Notification is triggered.

See,72,75#58 for the IDL definition.
Please note that this is out of date with the current state of the WHATWG spec at We're using a proprietary `mozbehavior` object to specify sound and vibration pattern for B2G/ Gaia.

new Notification("title", {
  mozbehavior: {
    soundFile: "chrome://url/to/soundFile.ogg"

As such, this works for FirefoxOS, but not on the major desktop platforms.

This bug tracks that work.
Flags: qe-verify+
Flags: firefox-backlog+
Depends on: 1105225
Depends on: 1105226
Depends on: 1105229
Depends on: 1105230
Component: Widget → Notifications and Alerts
Product: Core → Toolkit
:karlt actually proposed an awesome alternative in

For ease of implementation, I suggest to support _not_ playing a sound - which all desktop notification agents support - at first, so that Notification API consumers can start with playing a sound of their own via the <audio> element.

How does that 'sound'? (no pun intended ;) )
Attached patch WIP patchSplinter Review
This patch does the following:

1) adds an optional `sound` String argument to the `showAlertNotification` function for nsIAlertService.
2) Supports passing sound names to OSX Notification Manager to allow playing built-in sounds or the 'default' one.
3) Implements the behavior in Notification.cpp to see if the sound passed along with `mozBehavior.soundFile` contains a file that might be playable by the <audio> element.
  a) Tries to play the sound using a HTMLAudioElement instance, which crashes the browser atm. Dunno why, my skill is limited here atm.
  b) If no file is detected, pass the raw string to the alert service OS implementation. It may play a built-in sound.
  c) Pass the ASCII string 'default' to the alert service and let OS specific implementation fall back to its default behavior.
This is standardized, so we should use that API rather than invent a proprietary method:
Summary: Support custom sound files for Web Notifications → [meta] Support custom sound files for Web Notifications
Severity: normal → S3
Component: Notifications and Alerts → DOM: Notifications
Product: Toolkit → Core

It's removed from the spec by in 2018 because of the lack of implementation. I'll close this assuming there's no active use case as this has been silent since FxOS.

Closed: 8 months ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.