[whatwg] The behaviour of Notification.requestPermission() in Workers

Nikhil Marathe nsm.nikhil at gmail.com
Wed Oct 23 18:19:10 PDT 2013


Hello,

There has been considerable interest in exposing the Notification API on
workers, and especially service workers. The behaviour of
Notification.requestPermission() requires some consensus. The problem of
requestPermission() on workers is that the user agent may not always be in
a position to present UI to the user. The worker may be started on a page
that is not the active tab, the worker may be a service worker running in
the background, or it may be a shared worker with no single window with
which to associate UI (related [1]).

The easiest solution for implementors and authors is to make the
requestPermission() call in a HTML page before spawning a worker or
registering a service worker. Inside the Worker scope we then have two
options:
1) requestPermission() is not defined.
2) requestPermission() does not ask the user, but uses the permission
associated with that origin, or denied.

I believe option 2 is better in terms of having a complete API.

Feedback is appreciated about what the right approach should be.

Regards,
Nikhil

[1]:
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2013-March/039311.html


More information about the whatwg mailing list