Open Bug 965632 Opened 10 years ago Updated 2 years ago

[Web Notifications] Notification.get(), Events on retrieved notifications need to fire in all globals

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

People

(Reporter: mikehenrty, Unassigned)

References

Details

(Whiteboard: [systemsfe])

Attachments

(1 file)

Right now if one tab creates a notification and then another tab of the same origin fetches that notification, we will have two notifications each with different globals representing the same object. The problem arises when, for instance, one tab closes said notification, and the other tab has an onclose handler defined for it. The onclose handler will not get fired in the second tab. We need to implement a way to propagate this message across globals.

Code example illustrating:
Tab 1:
var notification = new Notification('hello world');


Tab 2:
var promise = Notification.get();
promise.then(function(notifications) {
  notifications[0].onclose = function {
    console.log('Will never get called');
  };
});

Tab 1:
notification.close();

Note: this problem also applies directly to Workers who would fetch notifications using Notification.get().
Assignee: nobody → robertbindar
I'm working on it. Currently I fixed it for b2g and firefox desktop on (Windows, Linux[+e10s]).
Any chance to limit platform specific bits to minimum.
I'd expect there to be a cross-platform thing (service?) which iterates all the Notications and notifies about show/click/close
I tried to limit them as much as I could, but we have different alerts services for almost each platform which deal pretty different with notifying the observers (another problem is that the observers are notified mostly from platform specific code).

I was thinking about introducing a new service which could be cross-platform code and let it be the observer. This way we wouldn't care about platform specific implementations of the alerts service; the new service would act as a proxy between content and alerts service and each new notification/clone would be stored there. When the observer would be notified i.e. the new service, it'd notify all the notifications/clones registered with the same id.

How does it sound?
Flags: needinfo?(bugs)
A proxy sounds good to me.
Flags: needinfo?(bugs)
See http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Aug/0187.html for a completely different approach to this problem.
annevk: I don't think it's possible to fetch the same object. What about the case when you want to fetch a notification after a browser restart? In b2g for instance we need to restore the notifications after reboot, cross origin, it wouldn't be possible to have the same notification object as the original one.
Flags: needinfo?(annevk)
Ignore comment 8; I could make Notification.get() to return the same notification objects with a similar approach as in comment 5. When the browser is restarted, we obviously lose the original instance and in this case Notification.get() will create new instances of the stored notifications (which will preserve the current behavior of both b2g and firefox desktop).

Why do we need Notification.get() to create different objects for service workers ( http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Aug/0187.html ) ?
I'm not following your questions. My idea was not to make it fetch the same object, but simply not offer copies for traditional Notification objects, only those backed by a service worker.
Flags: needinfo?(annevk)
Component: DOM → DOM: Core & HTML

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: robertbindar → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: