diff --git a/index.bs b/index.bs
index 84d0a37..d7ef951 100644
--- a/index.bs
+++ b/index.bs
@@ -213,6 +213,29 @@ The rotation rate measures the rate at which the device rotates about
Note: [[MOTION-SENSORS]] and [[GYROSCOPE]] both contain a more detailed discussion of gyroscopes, rotation rates and measurements.
+Permissions API integration {#permissions-api-integration}
+===========================
+
+This specification defines the following default powerful features:
+
+ * "accelerometer
"
+ * "gyroscope
"
+ * "magnetometer
"
+
+
deviceorientation
event requires "accelerometer
" and "gyroscope
" when providing relative orientation data. For the implementation to fall back to absolute orientation data, "magnetometer
" is also required.
+ - The deviceorientationabsolute
event requires "accelerometer
", "gyroscope
" and "magnetometer
".
+ - The devicemotion
event requires "accelerometer
" and "gyroscope
".
+
+Let promise be a new promise. - -
Run these steps in parallel: - -
Let permission be permission for - relevant settings object's origin. - -
If permission is "default
" and the relevant global object does not have transient activation, then reject promise with a
- {{NotAllowedError!!exception}} {{DOMException}} and abort these steps.
-
-
If permission is "default
", ask the user whether sharing device orientation
- for the relevant settings object's
- origin is acceptable. If it is, set
- permission to "granted
", and "denied
" otherwise.
-
-
Queue a task to run these steps: +The requestPermission(absolute) method steps are: + + 1. Let global be the current global object. + 1. If this's relevant global object does not have transient activation, return a promise rejected with a "{{NotAllowedError}}" {{DOMException}}. + 1. Let result be a new promise in this's relevant Realm. + 1. Run these steps in parallel: + 1. If absolute is true: + 1. Let permissions be « "accelerometer", "gyroscope", "magnetometer" ». + 1. Otherwise: + 1. Let permissions be « "accelerometer", "gyroscope" ». + 1. Let permissionState be "granted". + 1. For each name of permissions: + + Note: There is no algorithm for requesting multiple permissions at once. However, user agents are encouraged to bundle concurrent requests for different kinds of media into a single user-facing permission prompt. + + 1. If the result of requesting permission to use name is "denied": + 1. Set permissionState to "denied". + 1. Break + 1. Queue a global task on the device motion and orientation task source given global to resolve result with permissionState.
Set permission for the relevant settings object's - origin to permission. - -
Fulfill promise with permission. -
Return promise. -
Let promise be a new promise. - -
Run these steps in parallel: - -
Let permission be permission for - relevant settings object's origin. + 1. Let global be the current global object. + 1. If this's relevant global object does not have transient activation, return a promise rejected with a "{{NotAllowedError}}" {{DOMException}}. + 1. Let result be a new promise in this's relevant Realm. + 1. Run these steps in parallel: + 1. Let permissionState be "granted". + 1. For each name of « "accelerometer", "gyroscope" »: -
If permission is "default
" and the relevant global object does not have transient activation, then reject promise with a
- {{NotAllowedError!!exception}} {{DOMException}} and abort these steps.
+ Note: There is no algorithm for requesting multiple permissions at once. However, user agents are encouraged to bundle concurrent requests for different kinds of media into a single user-facing permission prompt.
-
If permission is "default
", ask the user whether sharing device motion
- for the relevant settings object's
- origin is acceptable. If it is, set
- permission to "granted
", and "denied
" otherwise.
+ 1. If the result of requesting permission to use name is "denied":
+ 1. Set permissionState to "denied".
+ 1. Break
+ 1. Queue a global task on the device motion and orientation task source given global to resolve result with permissionState.
Queue a task to run these steps: - -
Set permission for the relevant settings object's - origin to permission. - -
Fulfill promise with permission. -
Return promise. -
devicemotion
at window, using {{DeviceMotionEvent}}, with the {{DeviceMotionEvent/acceleration}} attribute initialized to acceleration, the {{DeviceMotionEvent/accelerationIncludingGravity}} attribute initialized to accelerationIncludingGravity, the {{DeviceMotionEvent/rotationRate}} attribute initialized to rotationRate, and the {{DeviceMotionEvent/interval}} attribute initialized to interval.
+ 1. Let environment be window's relevant settings object.
+ 1. Run these steps in parallel:
+ 1. For each permission name in « "accelerometer", "gyroscope" »:
+ 1. Let state be the result of getting the current permission state with permission name and environment.
+ 1. If state is not "granted", return.
+ 1. Queue a global task on the device motion and orientation task source given window to run the following steps:
+ 1. If the implementation is able to provide linear acceleration:
+ 1. Set acceleration to a new {{DeviceMotionEventAcceleration}} created in window's realm.
+ 1. Set acceleration's x axis acceleration to the device's linear acceleration along the X axis, or null if it cannot be provided.
+ 1. If acceleration's x axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set acceleration's y axis acceleration to the device's linear acceleration along the Y axis, or null if it cannot be provided.
+ 1. If acceleration's y axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set acceleration's z axis acceleration to the device's linear acceleration along the Z axis, or null if it cannot be provided.
+ 1. If acceleration's z axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
+ 1. If the implementation is able to provide acceleration with gravity:
+ 1. Set accelerationIncludingGravity to a new {{DeviceMotionEventAcceleration}} created in window's realm.
+ 1. Set accelerationIncludingGravity's x axis acceleration to the device's acceleration with gravity along the X axis, or null if it cannot be provided.
+ 1. If accelerationIncludingGravity's x axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set accelerationIncludingGravity's y axis acceleration to the device's acceleration with gravity along the Y axis, or null if it cannot be provided.
+ 1. If accelerationIncludingGravity's y axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
+ 1. Set accelerationIncludingGravity's z axis acceleration to the device's acceleration with gravity along the Z axis, or null if it cannot be provided.
+ 1. If accelerationIncludingGravity's z axis acceleration is not null, limit its precision to no more than 0.1 m/s2.
+ 1. If the implementation is able to provide rotation rate:
+ 1. Set rotationRate to a new {{DeviceMotionEventRotationRate}} created in window's realm.
+ 1. Set rotationRate's x axis rotation rate to the device's rotation rate about the X axis, or null if it cannot be provided.
+ 1. If rotationRate's x axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.
+ 1. Set rotationRate's y axis rotation rate to the device's rotation rate about the Y axis, or null if it cannot be provided.
+ 1. If rotationRate's y axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.
+ 1. Set rotationRate's z axis rotation rate to the device's rotation rate about the Z axis, or null if it cannot be provided.
+ 1. If rotationRate's z axis rotation rate is not null, limit its precision to no more than 0.1 deg/s.
+ 1. Fire an event named devicemotion
at window, using {{DeviceMotionEvent}}, with the {{DeviceMotionEvent/acceleration}} attribute initialized to acceleration, the {{DeviceMotionEvent/accelerationIncludingGravity}} attribute initialized to accelerationIncludingGravity, the {{DeviceMotionEvent/rotationRate}} attribute initialized to rotationRate, and the {{DeviceMotionEvent/interval}} attribute initialized to interval.
Implementations may choose to share device orientation & motion only if the -user (or user agent on behalf of the user) has granted permission. -The permission to share device orientation & motion -for a given origin is one of three strings: - -
default
"
- This is equivalent to "denied
", but the user has made no
- explicit choice thus far.
-
-
denied
"
- This means the user does not want - to share device orientation or motion. - -
granted
"
- This means device orientation or motion may be shared. -
There is no equivalent to "default
"
-meaning "granted
". In that case
-"granted
" is simply returned as there would be no reason
-for the application to ask for permission.
-
Security and privacy considerations {#security-and-privacy}
===========================================================
@@ -573,7 +555,9 @@ The API defined in this specification can be used to obtain information from har
* Location tracking [[INDOORPOS]]
* User identification [[FINGERPRINT]]
-In light of that, implementations may consider permissions or visual indicators to signify the use of sensors by the web page. Furthermore, to minimize privacy risks, the chance of fingerprinting and other attacks the implementations must:
+In light of that, implementations may consider visual indicators to signify the use of sensors by the web page. Additionally, this specification requires users to give express permission for the user agent to provide device motion and/or orientation data via the requestPermission()
API calls.
+
+Furthermore, to minimize privacy risks, the chance of fingerprinting and other attacks the implementations must:
* fire events only when a [=/navigable=]'s [=navigable/active document=]'s [=visibility state=] is "visible
",
* fire events only on the [=/top-level traversable=]'s [=navigable/active window=] and [=child navigables=]' [=navigable/active windows=] whose [=relevant settings object=]'s [=environment settings object/origin=] is [=same origin=] with the [=/top-level traversable=]'s [=navigable/active window=]'s [=relevant settings object=]'s [=environment settings object/origin=].