Re: [deviceorientation] requestPermission() and event handling clarification (#74)

> @reillyeon and I were discussing the Chromium implementation of #68 and we figured it'd be good to get some clarification on how it integrates with `Device{Orientation,Motion}Event` -- either in terms of what the spec's supposed to mean or, if it's intentionally leaving some decisions up to implementations, what WebKit/Safari do so we can try to align some of the behavior across implementations.
> 
> * Does WebKit/Safari remember if permission's been granted to a given page or are users always asked for permission when `requestPermission()` is called?

WebKit only remembers for the lifetime of the web page. Safari might remember for longer, it is unclear at this point.

> * If an event listener for a deviceorientation/motion event is added before permission is granted, does anything happen (e.g. a null deviceorientation/motion event is fired)?

No, deviceorientation / devicemotion events are fired until permission is granted. We currently log a console message when registering an event listener before permission is granted to let developers know.

> * Are users at all supposed to be able to add an event listener for those events before requesting permission?

As it is implemented in WebKit, yes. There is not really a precedent (AFAIK) for preventing somebody from adding an event listener. I think it is much nicer to developers as well to allow registering the event listener, but delay firing of events until permission is granted.

> * Once permission is granted, do previously registered event listeners start working or does the user need to add another event listener in order to start receiving events?

Yes, existing event listeners start receiving events.


-- 
GitHub Notification of comment by cdumez
Please view or discuss this issue at https://github.com/w3c/deviceorientation/issues/74#issuecomment-480981479 using your GitHub account

Received on Monday, 8 April 2019 19:52:12 UTC