Skip to content

Commit

Permalink
Add Permissions Policy integration
Browse files Browse the repository at this point in the history
This substantive change makes the firing of the events defined in this
specification dependent on a few different policy-controlled features:
"accelerometer", "gyroscope", and "magnetometer.

Both Blink and WebKit already integrate their implementations with the
Permissions Policy spec and use the same tokens, although a bit differently:

- Both require "accelerometer" and "gyroscope" for the devicemotion event.
- Blink requires "accelerometer" and "gyroscope" to provide relative
  orientation data for the deviceorientation event, and additionally the
  "magnetometer" feature to fall back to absolute orientation data. WebKit
  always requires the three tokens for the deviceorientation event.
- Blink requires "accelerometer", "gyroscope", and "magnetometer" for the
  deviceorientationabsolute event, whereas WebKit does not implement this
  event.

We have opted to codify Blink's behavior in the specification, as since
relative orientation data does not require a magnetometer sensor, the event
should not require the corresponding token either.

Fixes #64.
  • Loading branch information
rakuco committed Nov 10, 2023
1 parent c0a2640 commit 4f1f7dc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,24 @@ The <dfn>rotation rate</dfn> 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 Policy integration {#permissions-policy-integration}
==============================

This specification defines the following <a>policy-controlled features</a>:

- "<code><dfn data-lt="accelerometer-feature">accelerometer</dfn></code>", whose <a>default allowlist</a> is "<code>self</code>".
- "<code><dfn data-lt="gyroscope-feature">gyroscope</dfn></code>", whose <a>default allowlist</a> is "<code>self</code>".
- "<code><dfn data-lt="magnetometer-feature">gyroscope</dfn></code>", whose <a>default allowlist</a> is "<code>self</code>".

<div class="note">
<span class="marker">Note:</span> Usage of the <a>policy-controlled features</a> above by this specification is as follows:

- The <a event for="Window"><code>deviceorientation</code></a> event requires the "<a data-lt="accelerometer-feature"><code>accelerometer</code></a>" and "<a data-lt="gyroscope-feature"><code>gyroscope</code></a>" features when providing <a>relative orientation</a> data. For the implementation to fall back to <a>absolute orientation</a> data, the "<a data-lt="magnetometer-feature"><code>magnetometer</code></a>" feature is also used.
- The <a event for="Window"><code>deviceorientationabsolute</code></a> event requires the "<a data-lt="accelerometer-feature"><code>accelerometer</code></a>", "<a data-lt="gyroscope-feature"><code>gyroscope</code></a>" and "<a data-lt="magnetometer-feature"><code>magnetometer</code></a>" feature.
- The <a event for="Window"><code>devicemotion</code></a> event requires the "<a data-lt="accelerometer-feature"><code>accelerometer</code></a>" and "<a data-lt="gyroscope-feature"><code>gyroscope</code></a>".

</div>

API {#api}
==========================

Expand Down Expand Up @@ -312,8 +330,13 @@ Whenever a <a>significant change in orientation</a> occurs, the user agent must

1. If the implementation cannot provide <a>relative orientation</a> or the resulting <a>absolute orientation</a> data is more accurate:
1. Let <var>absolute</var> be true.
1. Let <var>policies</var> be « "<a data-lt="accelerometer-feature"><code>accelerometer</code></a>", "<a data-lt="gyroscope-feature"><code>gyroscope</code></a>", "<a data-lt="magnetometer-feature"><code>magnetometer</code></a>" ».
1. Otherwise:
1. Let <var>absolute</var> be false.
1. Let <var>policies</var> be « "<a data-lt="accelerometer-feature"><code>accelerometer</code></a>", "<a data-lt="gyroscope-feature"><code>gyroscope</code></a>" ».
1. Let <var>document</var> be <var>window</var>'s <a>associated Document</a>.
1. <a for="list">For each</a> <var>policy</var> of <var>policies</var>:
1. If <var>document</var> is not <a>allowed to use</a> the <a>policy-controlled feature</a> named <var>policy</var>, return.
1. Invoke <a>fire an orientation event</a> with <a event for="Window"><code>deviceorientation</code></a>, <var>window</var>, and <var>absolute</var>.

</div>
Expand Down Expand Up @@ -500,6 +523,9 @@ The <dfn method for="DeviceMotionEvent">requestPermission()</dfn> method steps a
<div algorithm="devicemotion firing steps">
At an <a>implementation-defined</a> interval <var>interval</var>, the user agent must execute the following steps on a <a for="/">navigable</a>'s <a for="navigable">active window</a> <var>window</var>:

1. Let <var>document</var> be <var>window</var>'s <a>associated Document</a>.
1. <a for="list">For each</a> <var>policy</var> of « "<a data-lt="accelerometer-feature"><code>accelerometer</code></a>", "<a data-lt="gyroscope-feature"><code>gyroscope</code></a>" »:
1. If <var>document</var> is not <a>allowed to use</a> the <a>policy-controlled feature</a> named <var>policy</var>, return.
1. Let <var>acceleration</var> be null.
1. Let <var>accelerationIncludingGravity</var> be null.
1. Let <var>rotationRate</var> be null.
Expand Down

0 comments on commit 4f1f7dc

Please sign in to comment.