New issue
Advanced search Search tips

Issue 635326 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Replacing a notification keps the old one in notifications list indefinitely

Reported by teodorma...@gmail.com, Aug 7 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Steps to reproduce the problem:
As per specs (https://notifications.spec.whatwg.org/#replacing-a-notification), when an old notification is replaced by a new one (when both notifications have same, non-empty tag), the old notification should be removed from the list of notifications and the new one placed in its spot. However this is not happening.

To reproduce it (in the service worker context):

    self.registration.showNotification('A', { tag: 'abc' })
      .then(() => self.registration.getNotifications({ tag: 'abc' }))
      .then(notificationsList => {
        console.log(notificationsList); // [ NotificationA ]
        return self.registration.showNotification('B', { tag: 'abc' });
      })
      .then(() => self.registration.getNotifications({ tag: 'abc' }))
      .then(notificationsList => {
        console.log(notificationsList); // [ NotificationB, NotificationA ]
        return self.registration.showNotification('C', { tag: 'abc' });
      })
      .then(() => self.registration.getNotifications({ tag: 'abc' }))
      .then(notificationsList => {
        console.log(notificationsList); // [ NotificationC, NotificationB, NotificationA ]
      })

What is the expected behavior?
The result of self.registration.getNotifications({ tag: 'abc' }) should only contain the latest Notification, which was to replace the old one.

What went wrong?
To "prevent" this behavior in code, before calling the self.registration.showNotification(), you need to explicitly walk through the notificationsList for that tag and call .close() on every Notification object.

The Notification is only ever removed from the notifications list when the person explicitly closes the notification by swiping it away or clicking [x] button on the notification (in that case, the .close() is called implicitly), or when the code itself calls .close() on a Notification.

Did this work before? No 

Chrome version: 51.0.2704.103  Channel: stable
OS Version: 10.0
Flash Version: Shockwave Flash 22.0 r0
 
Labels: TE-NeedsfurtherTriage
Components: UI>Notifications
Labels: -TE-NeedsfurtherTriage TE-NeedsTriageHelp

Comment 4 by peter@chromium.org, Aug 8 2016

Labels: -OS-Windows OS-All
Owner: peter@chromium.org
Status: Assigned (was: Unconfirmed)
Yup, I can confirm this. I uploaded a test-case here:

https://tests.peter.sh/random/notification-replacement.html

Expected test output (green lines):
  Displayed notifications: #1
  Displayed notifications: #2
  Displayed notifications: #3

Not three of them like this issue describes, certainly not the additive effect that happens when reloading the page.

Comment 5 by peter@chromium.org, Aug 8 2016

Status: Started (was: Assigned)
CL uploaded here:
  https://codereview.chromium.org/2223943002/
Project Member

Comment 6 by bugdroid1@chromium.org, Aug 9 2016

Comment 7 by peter@chromium.org, Aug 9 2016

Status: Fixed (was: Started)

Sign in to add a comment