chrome.notifications extension API: Clicking a notification makes it impossible to clear on macOS
Categories
(WebExtensions :: Frontend, defect)
Tracking
(firefox70 verified)
Tracking | Status | |
---|---|---|
firefox70 | --- | verified |
People
(Reporter: erin20913, Assigned: robwu)
References
Details
Attachments
(4 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Steps to reproduce:
I'm writing a WebExtension which uses the chrome.notifications
API and testing it on macOS Mojave 10.14.4, on Firefox Developer Edition 68.0b10. Essentially, the following code does not work:
chrome.notifications.onClicked.addListener(notificationId => {
chrome.notifications.getAll(allNotifications => {
console.log(notificationId, allNotifications); // notificationId is not a key of allNotifications
chrome.notifications.clear(notificationId, success => {
console.log(success); // always false
});
});
});
I've created a sample WebExtension which can be cloned and loaded as a temporary extension to illustrate the issue: https://github.com/Geo1088/chrome-notifications-test-case
The same code works as intended on Windows 10.
Actual results:
- Calling
chrome.notifications.getAll
from within achrome.notifications.onClicked
listener results in the clicked tab's ID being absent from the returned object. - Calling
chrome.notifications.clear
from within achrome.notifications.onClicked
listener results in no visible action and a value offalse
being passed to the callback.
Expected results:
- Calling
chrome.notifications.getAll
from within achrome.notifications.onClicked
listener should result in the clicked tab's ID being present in the returned object. - Calling
chrome.notifications.clear
from within achrome.notifications.onClicked
listener should result in the notification being cleared and the valuetrue
being passed to the callback.
Comment 1•5 years ago
|
||
Hi,
Please, check if the issue is reproducible on latest Nightly version, here is the link where you can download it https://www.mozilla.org/en-US/firefox/nightly/all/
Could you also attached a screen recording for this please?
Reproduced on a clean install of Nightly 69.0a1 build 20190619214046 on macOS 10.14.4. Attaching a screen recording of the issue momentarily.
Screen recording of the bug being reproduced in Firefox Nightly 69.0a1 build 20190619214046 on macOS 10.14.4.
The test extension is loaded through the debugger and a notification is created. After opening the inspector, the notification is not clicked, and the appropriate console output is displayed. The notification is not observed in the notification center after the ten-second timeout.
The extension is then removed and re-added through about:debugging, and this time the notification is clicked. The bugged console output is observed, and the notification remains in notification center even after the ten-second timeout.
Comment 4•5 years ago
|
||
The priority flag is not set for this bug.
:ddurst, could you have a look please?
For more information, please visit auto_nag documentation.
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 5•5 years ago
|
||
Not a regression. This behavior already existed since the initial implementation in bug 1256635.
On Linux, Windows and Android, clicking the native notification will automatically close the notification.
On all platforms (including macOS), if the pref alerts.useSystemBackend
is set to false
, then the same behavior occurs.
The current exception is macOS: I tested in Firefox 67.0.4, Firefox Nightly, Safari 12.1.1, Google Chrome 75.0.3770.90, and the web platform's Notification
API is similar to the extension's chrome.notifications
API (in Chrome): When the notification is shown, clicking it does not dismiss the notification. The click
event can thus be fired repeatedly.
Compared to other browsers, and the web platform's Notification
API on desktop, the notification from the browser.notifications
API does not have a close
button.
Assignee | ||
Comment 6•5 years ago
|
||
On Windows, Linux, Android, the backend for native notifications closes
the notification notification upon click.
On macOS, the notification sticks around, unless the user closes the
notification. This behavior is also observed in the Notification API
on the web platform, across different browsers.
Assignee | ||
Comment 7•5 years ago
|
||
Comment 8•5 years ago
|
||
IIUC our implementation was not 100% compatible with Chrome or with web notifications. This patch addresses that (and almost as a side effect fixes the reported issue). As well it seems that extensions must explicitly close the notification now.
Given the time that it has worked this way, do we know that this wont break any existing extensions on AMO?
Assignee | ||
Comment 9•5 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #8)
As well it seems that extensions must explicitly close the notification now.
The second patch only adds a close button on macOS that was previously not visible. The invisibility of the button prevented users from closing the notification.
Given the time that it has worked this way, do we know that this wont break any existing extensions on AMO?
The first patch changes the behavior of notifications.getAll
, and does not change the behavior of events (i.e. onClicked
/onClosed
), and the unit tests that I added (that explicitly check the order of events), already pass before my fix if I remove the checkNotificationCount
checks. So I don't expect significant breakage.
Assignee | ||
Comment 10•5 years ago
|
||
Assignee | ||
Comment 12•5 years ago
|
||
str |
STR:
- Install an add-on that uses notifications: https://addons.mozilla.org/en-US/firefox/addon/display-_anchors/
- Click on the extension button (while still on AMO).
- Observe a desktop notification from the extension.
- Put the mouse pointer on the notification.
Expected:
- A "Close" button should appear. Clicks at the left (not on the button) are ignored, clicking on the "Close" button should close the notification.
Actual (before patch):
- "Close" button does not appear. Clicks on the notification are ignored.
Comment 13•5 years ago
|
||
Comment 14•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/53effd672f63
https://hg.mozilla.org/mozilla-central/rev/359eff208383
https://hg.mozilla.org/mozilla-central/rev/f0cdc7a25e47
Comment 15•5 years ago
|
||
I have verified this issue on MacOS 10.14.1 Using FF70.0a1 (20190712095934) using the steps from comment 12. The following behavior was observed:
- after clicking the extension button the notification is displayed, when hovering the notification the close button is displayed.
- Clicking the close button closes the notification.
The only thing that is not as in the expected results mentioned in the comment 12 is that clicking anywhere on the notification (not on the close button) closes the notification.
@Rob
Should we log a new bug for this issue?
Assignee | ||
Comment 16•5 years ago
|
||
(In reply to Madalin Cotetiu from comment #15)
I have verified this issue on MacOS 10.14.1
The only thing that is not as in the expected results mentioned in the comment 12 is that clicking anywhere on the notification (not on the close button) closes the notification.
@Rob
Should we log a new bug for this issue?
No. On macOS 10.14.5 I observed that the notification doesn't disappear on click, and hence I found the need to add a close button.
If the notification is somehow clickable on your machine, then that's fine (it means that this bug is not as severe as I initially thought).
Comment 17•5 years ago
|
||
Based on the above comment I'm marking the bug as verified fixed. Thanks for the response Rob!
Updated•5 years ago
|
Description
•