device_orientation: Add requestPermission() to Device{Orientation,Motion}Event #17397
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
any time, and calling requestPermission() returns a promise that resolves
to "granted".
single null event, and calling requestPermission() returns a promise that
resolves to "blocked".
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
Reviewed-on: https://chromium-review.googlesource.com/1583809
WPT-Export-Revision: 31ad6db314529fde6707b8fdb7c60d2d177dea5d