whatwg / notifications

Notifications API Standard
https://notifications.spec.whatwg.org/
Other
135 stars 49 forks source link

If a notification with the requireInteraction flag not set is left and is automatically removed, should the notificationclose event fire #64

Open PaulKinlan opened 8 years ago

PaulKinlan commented 8 years ago

If a persistent notification with the require Interaction flag not set is left and is automatically removed from the display, should the notificationclose event fire? I think it should.

Right now in Chrome it does not, and looking at the spec and https://github.com/whatwg/notifications/issues/52 it is not clear if it should or not (the language I think is a little vague).

The spec says wrt to require interaction flag:

When set, indicates that on devices with a sufficiently large screen, the notification should remain readily available until the user activates or dismisses the notification.

The spec also says close steps should only apply to persistent notifications when the user or system dismisses the notification, and a persistent notification is a notification with an attached service worker.

Checking Chrome's implementation, when in a service worker there is a notification on the screen self.registration.getNotifications().then(function(e) {console.log(e);}) will list the notification objects, when the timeout for the display occurs self.registration.getNotifications().then(function(e) {console.log(e);}) will then have an empty list. This implies the item has been removed from the notification list and should have the event fired. But chrome I think is spec compliant in this case.

In my head at least, there needs to be clarity around the definition of the requireInteractionFlag should say 'the notification should remain in the list of notifications until the user activates or dismisses the notification', without this it is not saying clearly that the close steps should be run or not when the system times out notification.

PaulKinlan commented 8 years ago

Spoke to @beverloo out of band and at least in the implementation it is intended. If this is also the intention of the spec it would be good to clear up the language a little in the requireInteractionFlag section to indicate that it will not raise a SW event, right now (unless I am mistaken) it is inferred.

annevk commented 8 years ago

Your initial post is a little confusing. If the flag is not set I would not expect events necessarily. If it is set, it seems weird for the browser to dismiss the notification after some time. Could you clarify what scenario you mean?

PaulKinlan commented 8 years ago

The former, so to clarify the thinking after talking to @beverloo :

My questioning is more around the language in the spec. If the above three points are accurate it would be nice to clarify them. Or if they are not accurate, also clarify it. Right now when I read through the spec I inferred that it might fire the event when the system auto-dismisses, but speaking to peter said they shouldn't.

annevk commented 8 years ago

requireInteraction can only be true or false per the specification. There is no third state (not passing it is false).