W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2013

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

From: Nikhil Marathe <nsm.nikhil@gmail.com>
Date: Wed, 23 Oct 2013 18:19:10 -0700
Message-ID: <CANg7hhoa86ZSfmee4g+DjkY3BtgaB6UPh7rnSKPH88GgQgjWFg@mail.gmail.com>
To: whatwg@whatwg.org
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
Received on Thursday, 24 October 2013 01:19:57 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:12 UTC