Open Bug 1418281 Opened 7 years ago Updated 1 year ago

Notification.onclose called while notification is shown with libnotify on Linux; onclick never fires

Categories

(Toolkit :: Alerts Service, defect, P3)

56 Branch
Unspecified
Linux
defect

Tracking

()

People

(Reporter: robwu, Unassigned)

References

(Blocks 1 open bug)

Details

On ArchLinux, Firefox backed by libnotify, Firefox thinks that the notification has been dismissed (and fires "onclose"), even though the notification is being shown. Consequently, it is not possible to take any action when the notification is being clicked. This issue does not happen with XUL notifications (I tested this in Firefox 56 by installing https://addons.mozilla.org/en-US/firefox/addon/no-native-notifications/ ). STR: 1. Start Firefox with a new profile (tested with 56, 57, 58, 59.0a1) 2. On any website (e.g. the mozilla.org first run page), open the devtools and run the following snippet: var n; Notification.requestPermission().then(function() { n = new Notification('hello'); n.onshow = () => console.log('show'); n.onclose = () => console.log('close'); n.onclick = () => console.log('click'); }); 3. Confirm the permission request. 4. Click on the notification to dismiss it. Expected: - See "show", "click", "close" events in the console. Actual: - After step 3, "show" and "close" are shown (even though the notification is still being shown!) - The "click" event is never triggered.
Component: DOM → Notifications and Alerts
Product: Core → Toolkit
Interesting! On Ubuntu Unity, we'll fall back to the XUL backend, because we detect that libnotify notifications don't support click actions, and bail. It sounds like Arch at least claims to support them, and we need to be more clever about falling back to XUL. Or it might be a bug in our click handling code. Rob, do other apps that show libnotify notifications on Arch let you click on them?
Flags: needinfo?(rob)
The click stuff does work sometimes. When no notifications have been displayed before, clicking on the notification causes "click" to trigger, but no "close" - and after that the reported bug starts happening. However, when I close the notification via the close button on the notification, then "close" is triggered (and "click" is not triggered, as expected) and the notification behaves as expected. Here is the log of messages when I run the below snippet multiple times: (run snippet, #1) show 1 (click) click 1 (notification was dismissed, missing "close" event) (run snippet, #2) show 2 close 1 <---- Look, the "close" event for the first notification! close 2 <---- "close" event, but the notification is still being shown. (click) (notification was dismissed, missing "click" event) (run snippet, #3) show 3 close 3 <---- Again, a "close" event even though the notification was shown. (click on CLOSE button instead of notification) (notification was dismissed) (run snippet, #4) show 4 (if click on notification - then continue at #1) (if click on close button - then continue at #3) // This is the snippet for the test var n, ctr = ctr || 0; Notification.requestPermission().then(function() { var id = ++ctr; n = new Notification('hello'); n.onshow = () => console.log('show ' + id); n.onclose = () => console.log('close ' + id); n.onclick = () => console.log('click ' + id); });
Flags: needinfo?(rob)
Priority: -- → P3
Severity: normal → S3
Component: Notifications and Alerts → DOM: Notifications
Product: Toolkit → Core
Component: DOM: Notifications → Alerts Service
Product: Core → Toolkit
You need to log in before you can comment on or make changes to this bug.