diff --git a/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute-redirect-on-load.https.html b/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute-redirect-on-load.https.html new file mode 100644 index 00000000000000..7db2a7a6074df4 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,53 @@ + +
+ + + + + + + + + + diff --git a/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute.https.html b/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute.https.html new file mode 100644 index 00000000000000..a8f278179bd614 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute.https.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + diff --git a/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html b/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html new file mode 100644 index 00000000000000..72be5d7b184f53 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + diff --git a/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html.headers b/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..215be9b2b099f3 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=(), gyroscope=() diff --git a/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html b/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html new file mode 100644 index 00000000000000..d44b7461fb7609 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + diff --git a/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html.headers b/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..ed8e1b3466593a --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=*, gyroscope=* diff --git a/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html b/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html new file mode 100644 index 00000000000000..647df7532e3d73 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + diff --git a/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html.headers b/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..a9655f534b6169 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=self, gyroscope=self diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute-redirect-on-load.https.html b/orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute-redirect-on-load.https.html new file mode 100644 index 00000000000000..089ea612989c1f --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,53 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute.https.html b/orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute.https.html new file mode 100644 index 00000000000000..fec2127bda5921 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute.https.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html b/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html new file mode 100644 index 00000000000000..43edf2390e11ae --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html.headers b/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..215be9b2b099f3 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=(), gyroscope=() diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html new file mode 100644 index 00000000000000..f9bec906e8533e --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html.headers b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..ed8e1b3466593a --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=*, gyroscope=* diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html new file mode 100644 index 00000000000000..1dc2c33feb0d11 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html.headers b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..a9655f534b6169 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=self, gyroscope=self diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute-redirect-on-load.https.html b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute-redirect-on-load.https.html new file mode 100644 index 00000000000000..1ba721ef8d3d3d --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,53 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute.https.html b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute.https.html new file mode 100644 index 00000000000000..20cf098b1e641f --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute.https.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html new file mode 100644 index 00000000000000..4729144441a6eb --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html.headers b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..5e09c01ae3a0ff --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=(), gyroscope=(), magnetometer=() diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html new file mode 100644 index 00000000000000..588d97bf585ae5 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html @@ -0,0 +1,67 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html.headers b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..fc98a29a1edd86 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=*, gyroscope=*, magnetometer=* diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html new file mode 100644 index 00000000000000..f0533d3dc468dd --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,66 @@ + + + + + + + + + + + + diff --git a/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html.headers b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html.headers new file mode 100644 index 00000000000000..9305d94e95886f --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html.headers @@ -0,0 +1 @@ +Permissions-Policy: accelerometer=self, gyroscope=self, magnetometer=self diff --git a/permissions-policy/resources/orientation-event.js b/permissions-policy/resources/orientation-event.js new file mode 100644 index 00000000000000..85713418163781 --- /dev/null +++ b/permissions-policy/resources/orientation-event.js @@ -0,0 +1,64 @@ +"use strict"; + +async function waitForOrientationEvent(eventName) { + if ( + eventName !== "devicemotion" && + eventName !== "deviceorientation" && + eventName !== "deviceorientationabsolute" + ) { + return "ERROR"; + } + + let value; + + try { + // See https://github.com/w3c/deviceorientation/issues/148: the + // specification currently does not fire any events when the permissions + // policy checks fail, so what we do here is wait for the timeout and the + // devicemotion event handler to race each other. + value = await new Promise((resolve, reject) => { + const timeoutId = window.setTimeout(() => { + window.removeEventListener(eventName, handler); + reject("NO-EVENT"); + }, 1500); + function handler(event) { + window.clearTimeout(timeoutId); + + let data; + switch (event.type) { + case "devicemotion": + data = generateMotionData( + event.acceleration.x, + event.acceleration.y, + event.acceleration.z, + event.accelerationIncludingGravity.x, + event.accelerationIncludingGravity.y, + event.accelerationIncludingGravity.z, + event.rotationRate.alpha, + event.rotationRate.beta, + event.rotationRate.gamma + ); + break; + case "deviceorientation": + case "deviceorientationabsolute": + data = generateOrientationData( + event.alpha, + event.beta, + event.gamma, + event.absolute + ); + break; + default: + reject("UNEXPECTED-EVENT-TYPE"); + break; + } + resolve(JSON.stringify(data)); + } + window.addEventListener(eventName, handler, { once: true }); + }); + } catch (e) { + value = e; + } + + return value; +} diff --git a/permissions-policy/resources/permissions-policy-orientation-event.sub.html b/permissions-policy/resources/permissions-policy-orientation-event.sub.html new file mode 100644 index 00000000000000..31be86b6c0753c --- /dev/null +++ b/permissions-policy/resources/permissions-policy-orientation-event.sub.html @@ -0,0 +1,14 @@ + + + + + +