Skip to content

Commit

Permalink
device_orientation: Add requestPermission() to Device{Orientation,Mot…
Browse files Browse the repository at this point in the history
…ion}Event

Implement w3c/deviceorientation#68, which has added
a static requestPermission() method to both DeviceOrientationEvent as well
as DeviceMotionEvent.

Permission granted via requestPermission() is checked for after other
existing checks (if the requires feature policy checks fail, for example, we
still do not register the event handler at all).

The spec is somewhat vague in how permission handling should be implemented.
For Chromium, we have settled on the following behavior:
* If sensor access is set to "Allow", event listeners can be registered at
  any time, and calling requestPermission() returns a promise that resolves
  to "granted".
* If sensor access is set to "Block", event listeners will only receive a
  single null event, and calling requestPermission() returns a promise that
  resolves to "blocked".
* If sensor access is set to "Ask", event listeners will only receive a
  single null event until requestPermission() is called and access is
  granted (i.e. the user explicitly clicked "Allow" in the permission
  bubble, any other behavior including dismissing the bubble results in
  denial). If requestPermission() is NOT called through a user gesture, it
  will return a promise that rejecs with a NotAllowedError DOMException. If
  access is granted, requestPermission() returns a promise that resolves to
  "granted"; if access is denied, requestPermission() returns a promise that
  resolves to "blocked".

Bug: 947112
Change-Id: Ibb6ad43b78ca54189cf8f7ef802a4f812c5030df
  • Loading branch information
rakuco authored and chromium-wpt-export-bot committed Jun 20, 2019
1 parent 341842e commit 3ad86aa
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 0 deletions.

0 comments on commit 3ad86aa

Please sign in to comment.