From 984ef970c964d14e722c9807cd633adbe739adef Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Wed, 27 Mar 2024 19:09:18 +0100 Subject: [PATCH 1/9] orientation-event: Add Permissions Policy integration tests Add tests for deviceorientationabsolute, deviceorientation and devicemotion as described in https://w3c.github.io/deviceorientation/#permissions-policy-integration: - The deviceorientation event requires the "accelerometer" and "gyroscope" features. - The deviceorientationabsolute event requires the "accelerometer", "gyroscope" and "magnetometer" features. - The devicemotion event requires the "accelerometer" and "gyroscope" features. (WebKit currently requires the "magnetometer" feature for deviceorientation events, see https://bugs.webkit.org/show_bug.cgi?id=271891). The tests being added follow permissions-policy/README.md's recommendations: - Tests with different Permissions-Policy header values and how they influence usage in the top-level frame, same-origin iframes and cross-origin iframes. - Different values for the "allow" attribute and how they influece same-origin and cross-origin iframes. - Usage of the "allow" attribute with redirection. This is the minimum amount of coverage we need. These tests can be expanded to include: - Calls to `run_all_fp_tests_allow_self()` to test the behavior of the default policy for each feature (it requires making the function work with more than one feature). - The relative orientation to absolute orientation fallback behavior that depends on whether the "magnetometer" feature is enabled. - Not enabling all features (it may cause an explosion in the number of tests though). --- ...licy-attribute-redirect-on-load.https.html | 57 +++++++++++++++ ...by-permissions-policy-attribute.https.html | 55 +++++++++++++++ ...-disabled-by-permissions-policy.https.html | 69 ++++++++++++++++++ ...d-by-permissions-policy.https.html.headers | 1 + ...n-enabled-by-permissions-policy.https.html | 70 +++++++++++++++++++ ...d-by-permissions-policy.https.html.headers | 1 + ...lf-origin-by-permissions-policy.https.html | 69 ++++++++++++++++++ ...n-by-permissions-policy.https.html.headers | 1 + ...licy-attribute-redirect-on-load.https.html | 53 ++++++++++++++ ...by-permissions-policy-attribute.https.html | 51 ++++++++++++++ ...-disabled-by-permissions-policy.https.html | 63 +++++++++++++++++ ...d-by-permissions-policy.https.html.headers | 1 + ...n-enabled-by-permissions-policy.https.html | 64 +++++++++++++++++ ...d-by-permissions-policy.https.html.headers | 1 + ...lf-origin-by-permissions-policy.https.html | 63 +++++++++++++++++ ...n-by-permissions-policy.https.html.headers | 1 + ...licy-attribute-redirect-on-load.https.html | 53 ++++++++++++++ ...by-permissions-policy-attribute.https.html | 51 ++++++++++++++ ...-disabled-by-permissions-policy.https.html | 63 +++++++++++++++++ ...d-by-permissions-policy.https.html.headers | 1 + ...e-enabled-by-permissions-policy.https.html | 64 +++++++++++++++++ ...d-by-permissions-policy.https.html.headers | 1 + ...lf-origin-by-permissions-policy.https.html | 63 +++++++++++++++++ ...n-by-permissions-policy.https.html.headers | 1 + .../resources/orientation-event.js | 60 ++++++++++++++++ ...missions-policy-orientation-event.sub.html | 13 ++++ 26 files changed, 990 insertions(+) create mode 100644 orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute-redirect-on-load.https.html create mode 100644 orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute.https.html create mode 100644 orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html create mode 100644 orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html.headers create mode 100644 orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html create mode 100644 orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html.headers create mode 100644 orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html create mode 100644 orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html.headers create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute-redirect-on-load.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-allowed-by-permissions-policy-attribute.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html.headers create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html.headers create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html.headers create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute-redirect-on-load.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-allowed-by-permissions-policy-attribute.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html.headers create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html.headers create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html create mode 100644 orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html.headers create mode 100644 permissions-policy/resources/orientation-event.js create mode 100644 permissions-policy/resources/permissions-policy-orientation-event.sub.html 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..ad9149635b1c2b --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,57 @@ + + + + + + + + + + + + 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..c8dc7a57fd9348 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-allowed-by-permissions-policy-attribute.https.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + 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..7e2ae84589e68a --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-disabled-by-permissions-policy.https.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + + 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..d4341c4405c074 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-enabled-by-permissions-policy.https.html @@ -0,0 +1,70 @@ + + + + + + + + + + + + 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..2c0a03f98a00e0 --- /dev/null +++ b/orientation-event/motion/permissions-policy/devicemotion-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,69 @@ + + + + + + + + + + + + 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..6fdd9f00e0e347 --- /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..d016e98e553ed2 --- /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..1e7528e68ae0f6 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-disabled-by-permissions-policy.https.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + 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..cdc14798a8c4bf --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-by-permissions-policy.https.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + 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..bcd0ef0ec56552 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientation-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + 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..ee5709cac7ba99 --- /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..2e63f0dd8f0bdd --- /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..421b92a1e7cad1 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-disabled-by-permissions-policy.https.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + + 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..ad0e08df3b80f5 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-by-permissions-policy.https.html @@ -0,0 +1,64 @@ + + + + + + + + + + + + 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..1540cdce346831 --- /dev/null +++ b/orientation-event/orientation/permissions-policy/deviceorientationabsolute-enabled-on-self-origin-by-permissions-policy.https.html @@ -0,0 +1,63 @@ + + + + + + + + + + + + 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..f6f7ae8dd5f4f7 --- /dev/null +++ b/permissions-policy/resources/orientation-event.js @@ -0,0 +1,60 @@ +'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..7fdf0d7c26cc4e --- /dev/null +++ b/permissions-policy/resources/permissions-policy-orientation-event.sub.html @@ -0,0 +1,13 @@ + + + + + + From 579a755273402750df2c6eba144c5fdf83e899c6 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 1 Apr 2024 15:06:51 +0200 Subject: [PATCH 2/9] Fix typos Co-authored-by: Reilly Grant --- ...-by-permissions-policy-attribute-redirect-on-load.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ee5709cac7ba99..dbc6b11931677a 100644 --- 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 @@ -48,6 +48,6 @@ 'NO-EVENT', "accelerometer; gyroscope; magnetometer", ); -}, `"allow" disallows allows cross-origin navigantion in an iframe`); +}, `"allow" disallows cross-origin navigation in an iframe`); From 8bd8ab4f14e779dea112b2222be3df9bcaf5fd6f Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 1 Apr 2024 15:06:58 +0200 Subject: [PATCH 3/9] Fix typos Co-authored-by: Reilly Grant --- ...-by-permissions-policy-attribute-redirect-on-load.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index dbc6b11931677a..cca94189752da9 100644 --- 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 @@ -32,7 +32,7 @@ JSON.stringify(orientationData), "accelerometer; gyroscope; magnetometer", ); -}, `"allow" attribute allows same-origin navigantion in an iframe`); +}, `"allow" attribute allows same-origin navigation in an iframe`); promise_test(async t => { const helper = new SensorTestHelper(t, 'deviceorientationabsolute'); From 85232de18baf93ac51a2970b018e94e021dd5911 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 1 Apr 2024 15:07:08 +0200 Subject: [PATCH 4/9] Fix typos Co-authored-by: Reilly Grant --- ...-by-permissions-policy-attribute-redirect-on-load.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 6fdd9f00e0e347..a250ed6ab5f061 100644 --- 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 @@ -32,7 +32,7 @@ JSON.stringify(orientationData), "accelerometer; gyroscope", ); -}, `"allow" attribute allows same-origin navigantion in an iframe`); +}, `"allow" attribute allows same-origin navigation in an iframe`); promise_test(async t => { const helper = new SensorTestHelper(t, 'deviceorientation'); From 1491d65cad1056e5eb6b834b75cf5a211f74b28e Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 1 Apr 2024 15:07:16 +0200 Subject: [PATCH 5/9] Fix typos Co-authored-by: Reilly Grant --- ...-by-permissions-policy-attribute-redirect-on-load.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index a250ed6ab5f061..3f977bbf131f56 100644 --- 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 @@ -48,6 +48,6 @@ 'NO-EVENT', "accelerometer; gyroscope", ); -}, `"allow" disallows allows cross-origin navigantion in an iframe`); +}, `"allow" disallows cross-origin navigation in an iframe`); From d4e25780a7cdd0d0495bc76d240e00265eda3290 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 1 Apr 2024 15:07:24 +0200 Subject: [PATCH 6/9] Fix typos Co-authored-by: Reilly Grant --- ...-by-permissions-policy-attribute-redirect-on-load.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index ad9149635b1c2b..6508b34dec64ca 100644 --- 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 @@ -52,6 +52,6 @@ 'NO-EVENT', "accelerometer; gyroscope", ); -}, `"allow" disallows allows cross-origin navigantion in an iframe`); +}, `"allow" disallows cross-origin navigation in an iframe`); From f3893ac7237740a74de4b19b17e9826c1457d04a Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Mon, 1 Apr 2024 15:07:39 +0200 Subject: [PATCH 7/9] Fix typos Co-authored-by: Reilly Grant --- ...-by-permissions-policy-attribute-redirect-on-load.https.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 6508b34dec64ca..ae5f1eb48c54c3 100644 --- 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 @@ -34,7 +34,7 @@ JSON.stringify(motionData), "accelerometer; gyroscope", ); -}, `"allow" attribute allows same-origin navigantion in an iframe`); +}, `"allow" attribute allows same-origin navigation in an iframe`); promise_test(async t => { const helper = new SensorTestHelper(t, 'devicemotion'); From 9033cdb04f9f50324218971352dd39582af62582 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Fri, 5 Apr 2024 14:18:01 +0200 Subject: [PATCH 8/9] Reformat files using the prettier VS Code extension --- ...licy-attribute-redirect-on-load.https.html | 90 ++++++------- ...by-permissions-policy-attribute.https.html | 86 ++++++------ ...-disabled-by-permissions-policy.https.html | 105 +++++++-------- ...n-enabled-by-permissions-policy.https.html | 108 ++++++++------- ...lf-origin-by-permissions-policy.https.html | 107 ++++++++------- ...licy-attribute-redirect-on-load.https.html | 86 ++++++------ ...by-permissions-policy-attribute.https.html | 82 ++++++------ ...-disabled-by-permissions-policy.https.html | 124 ++++++++--------- ...n-enabled-by-permissions-policy.https.html | 102 +++++++------- ...lf-origin-by-permissions-policy.https.html | 123 ++++++++--------- ...licy-attribute-redirect-on-load.https.html | 86 ++++++------ ...by-permissions-policy-attribute.https.html | 82 ++++++------ ...-disabled-by-permissions-policy.https.html | 125 +++++++++--------- ...e-enabled-by-permissions-policy.https.html | 103 ++++++++------- ...lf-origin-by-permissions-policy.https.html | 123 ++++++++--------- .../resources/orientation-event.js | 24 ++-- ...missions-policy-orientation-event.sub.html | 18 +-- 17 files changed, 789 insertions(+), 785 deletions(-) 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 index ae5f1eb48c54c3..7db2a7a6074df4 100644 --- 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 @@ -1,57 +1,53 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + "NO-EVENT", + "accelerometer; gyroscope" + ); + }, `"allow" disallows cross-origin navigation in an iframe`); + 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 index c8dc7a57fd9348..a8f278179bd614 100644 --- 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 @@ -1,55 +1,51 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + JSON.stringify(motionData), + "accelerometer; gyroscope" + ); + }, `Device Motion can be enabled in cross-origin iframes using "allow" attribute`); + 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 index 7e2ae84589e68a..72be5d7b184f53 100644 --- 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 @@ -1,69 +1,64 @@ - - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + "NO-EVENT" + ); + }, `${header} disallows cross-origin iframes.`); + 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 index d4341c4405c074..d44b7461fb7609 100644 --- 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 @@ -1,70 +1,66 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + JSON.stringify(motionData), + "accelerometer; gyroscope" + ); + }, `${header} allows cross-origin iframes.`); + 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 index 2c0a03f98a00e0..647df7532e3d73 100644 --- 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 @@ -1,69 +1,66 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + "NO-EVENT" + ); + }, `${header} disallows cross-origin iframes.`); + 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 index 3f977bbf131f56..089ea612989c1f 100644 --- 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 @@ -1,53 +1,53 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + "NO-EVENT", + "accelerometer; gyroscope" + ); + }, `"allow" disallows cross-origin navigation in an iframe`); + 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 index d016e98e553ed2..fec2127bda5921 100644 --- 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 @@ -1,51 +1,51 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + JSON.stringify(orientationData), + "accelerometer; gyroscope" + ); + }, `Device Orientation can be enabled in cross-origin iframes using "allow" attribute`); + 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 index 1e7528e68ae0f6..43edf2390e11ae 100644 --- 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 @@ -1,63 +1,67 @@ - - - - - - - - - - + + + + + + + + + + + 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 index cdc14798a8c4bf..f9bec906e8533e 100644 --- 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 @@ -1,64 +1,66 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + JSON.stringify(orientationData), + "accelerometer; gyroscope" + ); + }, `${header} allows cross-origin iframes.`); + 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 index bcd0ef0ec56552..1dc2c33feb0d11 100644 --- 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 @@ -1,63 +1,66 @@ - - - - - - - - - + + + + + + + + + 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 index cca94189752da9..1ba721ef8d3d3d 100644 --- 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 @@ -1,53 +1,53 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + "NO-EVENT", + "accelerometer; gyroscope; magnetometer" + ); + }, `"allow" disallows cross-origin navigation in an iframe`); + 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 index 2e63f0dd8f0bdd..20cf098b1e641f 100644 --- 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 @@ -1,51 +1,51 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + JSON.stringify(orientationData), + "accelerometer; gyroscope; magnetometer" + ); + }, `Device Orientation can be enabled in cross-origin iframes using "allow" attribute`); + 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 index 421b92a1e7cad1..4729144441a6eb 100644 --- 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 @@ -1,63 +1,68 @@ - - - - - - - - - - + + + + + + + + + + + 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 index ad0e08df3b80f5..588d97bf585ae5 100644 --- 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 @@ -1,64 +1,67 @@ - - - - - - - - - + + + + + + + + + return test_feature_availability_with_post_message_result( + t, + cross_origin_src, + JSON.stringify(orientationData), + "accelerometer; gyroscope; magnetometer" + ); + }, `${header} allows cross-origin iframes.`); + 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 index 1540cdce346831..f0533d3dc468dd 100644 --- 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 @@ -1,63 +1,66 @@ - - - - - - - - - + + + + + + + + + diff --git a/permissions-policy/resources/orientation-event.js b/permissions-policy/resources/orientation-event.js index f6f7ae8dd5f4f7..85713418163781 100644 --- a/permissions-policy/resources/orientation-event.js +++ b/permissions-policy/resources/orientation-event.js @@ -1,8 +1,12 @@ -'use strict'; +"use strict"; async function waitForOrientationEvent(eventName) { - if (eventName !== 'devicemotion' && eventName !== 'deviceorientation' && eventName !== 'deviceorientationabsolute') { - return 'ERROR'; + if ( + eventName !== "devicemotion" && + eventName !== "deviceorientation" && + eventName !== "deviceorientationabsolute" + ) { + return "ERROR"; } let value; @@ -15,14 +19,14 @@ async function waitForOrientationEvent(eventName) { value = await new Promise((resolve, reject) => { const timeoutId = window.setTimeout(() => { window.removeEventListener(eventName, handler); - reject('NO-EVENT'); + reject("NO-EVENT"); }, 1500); function handler(event) { window.clearTimeout(timeoutId); let data; switch (event.type) { - case 'devicemotion': + case "devicemotion": data = generateMotionData( event.acceleration.x, event.acceleration.y, @@ -32,20 +36,20 @@ async function waitForOrientationEvent(eventName) { event.accelerationIncludingGravity.z, event.rotationRate.alpha, event.rotationRate.beta, - event.rotationRate.gamma, + event.rotationRate.gamma ); break; - case 'deviceorientation': - case 'deviceorientationabsolute': + case "deviceorientation": + case "deviceorientationabsolute": data = generateOrientationData( event.alpha, event.beta, event.gamma, - event.absolute, + event.absolute ); break; default: - reject('UNEXPECTED-EVENT-TYPE'); + reject("UNEXPECTED-EVENT-TYPE"); break; } resolve(JSON.stringify(data)); diff --git a/permissions-policy/resources/permissions-policy-orientation-event.sub.html b/permissions-policy/resources/permissions-policy-orientation-event.sub.html index 7fdf0d7c26cc4e..5e68eb209d3f51 100644 --- a/permissions-policy/resources/permissions-policy-orientation-event.sub.html +++ b/permissions-policy/resources/permissions-policy-orientation-event.sub.html @@ -1,13 +1,13 @@ - - - + + + Promise.resolve().then(async () => { + const name = await waitForOrientationEvent("{{GET[eventName]}}"); + window.parent.postMessage({ type: "availability-result", name }, "*"); + }); + From e491ab0a47b89f92a79e7b4b09f746da96a0ffe6 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Fri, 5 Apr 2024 14:30:56 +0200 Subject: [PATCH 9/9] Add a load event handler instead of relying on Promise.resolve() The Promise.resolve() idea was copy-pasted from another file, but adding a load event handler makes it more clear and in line with other files in permissions-policy/resources. While here, use Promise.then() instead of async/await to match other files as well. --- .../permissions-policy-orientation-event.sub.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/permissions-policy/resources/permissions-policy-orientation-event.sub.html b/permissions-policy/resources/permissions-policy-orientation-event.sub.html index 5e68eb209d3f51..31be86b6c0753c 100644 --- a/permissions-policy/resources/permissions-policy-orientation-event.sub.html +++ b/permissions-policy/resources/permissions-policy-orientation-event.sub.html @@ -5,9 +5,10 @@