From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- ...ionSensor-disabled-by-feature-policy.https.html | 13 +++ ...r-disabled-by-feature-policy.https.html.headers | 1 + ...re-policy-attribute-redirect-on-load.https.html | 13 +++ ...-enabled-by-feature-policy-attribute.https.html | 13 +++ ...tionSensor-enabled-by-feature-policy.https.html | 13 +++ ...or-enabled-by-feature-policy.https.html.headers | 1 + ...led-on-self-origin-by-feature-policy.https.html | 13 +++ ...elf-origin-by-feature-policy.https.html.headers | 1 + ...oluteOrientationSensor-iframe-access.https.html | 18 ++++ .../AbsoluteOrientationSensor.https.html | 25 +++++ .../web-platform/tests/orientation-sensor/META.yml | 5 + .../OrientationSensor_insecure_context.html | 21 +++++ ...ionSensor-disabled-by-feature-policy.https.html | 13 +++ ...r-disabled-by-feature-policy.https.html.headers | 1 + ...re-policy-attribute-redirect-on-load.https.html | 13 +++ ...-enabled-by-feature-policy-attribute.https.html | 13 +++ ...tionSensor-enabled-by-feature-policy.https.html | 13 +++ ...or-enabled-by-feature-policy.https.html.headers | 1 + ...led-on-self-origin-by-feature-policy.https.html | 13 +++ ...elf-origin-by-feature-policy.https.html.headers | 1 + ...ativeOrientationSensor-iframe-access.https.html | 18 ++++ .../RelativeOrientationSensor.https.html | 25 +++++ .../orientation-sensor/idlharness.https.window.js | 18 ++++ .../orientation-sensor/orientation-sensor-tests.js | 104 +++++++++++++++++++++ .../orientation-sensor/resources/sensor-data.js | 30 ++++++ 25 files changed, 400 insertions(+) create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html.headers create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html.headers create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/META.yml create mode 100644 testing/web-platform/tests/orientation-sensor/OrientationSensor_insecure_context.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html.headers create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html.headers create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html create mode 100644 testing/web-platform/tests/orientation-sensor/idlharness.https.window.js create mode 100644 testing/web-platform/tests/orientation-sensor/orientation-sensor-tests.js create mode 100644 testing/web-platform/tests/orientation-sensor/resources/sensor-data.js (limited to 'testing/web-platform/tests/orientation-sensor') diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html new file mode 100644 index 0000000000..7f4257165f --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html @@ -0,0 +1,13 @@ + + +AbsoluteOrientationSensor Feature Policy Test: Disabled + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..47d761713a --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer 'none'; gyroscope 'none'; magnetometer 'none' diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html new file mode 100644 index 0000000000..ab34f5b454 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,13 @@ + + +AbsoluteOrientationSensor Feature Policy Test: Enabled by attribute redirect on load + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute.https.html new file mode 100644 index 0000000000..cb23e8b6ae --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute.https.html @@ -0,0 +1,13 @@ + + +AbsoluteOrientationSensor Feature Policy Test: Enabled by attribute + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html new file mode 100644 index 0000000000..cc09eeaea4 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html @@ -0,0 +1,13 @@ + + +AbsoluteOrientationSensor Feature Policy Test: Enabled + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..58366d90bd --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer *; gyroscope *; magnetometer * diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html new file mode 100644 index 0000000000..62e21beb90 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html @@ -0,0 +1,13 @@ + + +AbsoluteOrientationSensor Feature Policy Test: Enabled on self origin + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..31cab0de68 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer 'self'; gyroscope 'self'; magnetometer 'self' diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html new file mode 100644 index 0000000000..4831b5e719 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html @@ -0,0 +1,18 @@ + + +AbsoluteOrientationSensor iframe test + + + + + + + + + + +
+ diff --git a/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html new file mode 100644 index 0000000000..4c516da145 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html @@ -0,0 +1,25 @@ + + +OrientationSensor Test + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/META.yml b/testing/web-platform/tests/orientation-sensor/META.yml new file mode 100644 index 0000000000..b780d2c90c --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/META.yml @@ -0,0 +1,5 @@ +spec: https://w3c.github.io/orientation-sensor/ +suggested_reviewers: + - riju + - Honry + - rakuco diff --git a/testing/web-platform/tests/orientation-sensor/OrientationSensor_insecure_context.html b/testing/web-platform/tests/orientation-sensor/OrientationSensor_insecure_context.html new file mode 100644 index 0000000000..18d41cec9e --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/OrientationSensor_insecure_context.html @@ -0,0 +1,21 @@ + +AbsoluteOrientationSensor Test: insecure context + + + + + + +
+

Note:

+
    +
  1. + Run test in an insecure context, e.g. http://example.com/. +
  2. +
+ diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html new file mode 100644 index 0000000000..d97d40b6ca --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html @@ -0,0 +1,13 @@ + + +RelativeOrientationSensor Feature Policy Test: Disabled + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..01f1b4b554 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer 'none'; gyroscope 'none' diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html new file mode 100644 index 0000000000..3a6173a2c1 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,13 @@ + + +RelativeOrientationSensor Feature Policy Test: Enabled by attribute redirect on load + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute.https.html new file mode 100644 index 0000000000..e8d30020c2 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute.https.html @@ -0,0 +1,13 @@ + + +RelativeOrientationSensor Feature Policy Test: Enabled by attribute + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html new file mode 100644 index 0000000000..d9f38f2dcc --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html @@ -0,0 +1,13 @@ + + +RelativeOrientationSensor Feature Policy Test: Enabled + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..717e3dd762 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer *; gyroscope * diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html new file mode 100644 index 0000000000..d63bf4e19b --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html @@ -0,0 +1,13 @@ + + +RelativeOrientationSensor Feature Policy Test: Enabled on self origin + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..ad428b2ea9 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer 'self'; gyroscope 'self' diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html new file mode 100644 index 0000000000..fe995e2d1b --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html @@ -0,0 +1,18 @@ + + +RelativeOrientationSensor iframe test + + + + + + + + + + +
+ diff --git a/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html new file mode 100644 index 0000000000..35dc8c3111 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html @@ -0,0 +1,25 @@ + + +OrientationSensor Test + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/orientation-sensor/idlharness.https.window.js b/testing/web-platform/tests/orientation-sensor/idlharness.https.window.js new file mode 100644 index 0000000000..86f277487a --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/idlharness.https.window.js @@ -0,0 +1,18 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +// https://w3c.github.io/orientation-sensor/"> + +'use strict'; + +idl_test( + ['orientation-sensor'], + ['generic-sensor', 'dom'], + idl_array => { + idl_array.add_objects({ + AbsoluteOrientationSensor: ['new AbsoluteOrientationSensor();'], + RelativeOrientationSensor: ['new RelativeOrientationSensor();'] + }); + idl_array.prevent_multiple_testing('OrientationSensor'); + } +); diff --git a/testing/web-platform/tests/orientation-sensor/orientation-sensor-tests.js b/testing/web-platform/tests/orientation-sensor/orientation-sensor-tests.js new file mode 100644 index 0000000000..d69fa3e54c --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/orientation-sensor-tests.js @@ -0,0 +1,104 @@ +'use strict'; + +async function checkQuaternion( + t, sensorType, testDriverName, permissionName, readings) { + await test_driver.set_permission({name: permissionName}, 'granted'); + await test_driver.create_virtual_sensor(testDriverName); + const sensor = new sensorType(); + t.add_cleanup(async () => { + sensor.stop(); + await test_driver.remove_virtual_sensor(testDriverName); + }); + const sensorWatcher = + new EventWatcher(t, sensor, ['activate', 'reading', 'error']); + sensor.start(); + + await sensorWatcher.wait_for('activate'); + await Promise.all([ + test_driver.update_virtual_sensor(testDriverName, readings.next().value), + sensorWatcher.wait_for('reading') + ]); + assert_equals(sensor.quaternion.length, 4, 'Quaternion length must be 4'); + assert_true( + sensor.quaternion instanceof Array, 'Quaternion is must be array'); +}; + +async function checkPopulateMatrix( + t, sensorProvider, sensorType, testDriverName, permissionName, readings) { + await test_driver.set_permission({name: permissionName}, 'granted'); + await test_driver.create_virtual_sensor(testDriverName); + const sensor = new sensorType(); + t.add_cleanup(async () => { + sensor.stop(); + await test_driver.remove_virtual_sensor(testDriverName); + }); + const sensorWatcher = + new EventWatcher(t, sensor, ['activate', 'reading', 'error']); + + // Throws with insufficient buffer space. + assert_throws_js( + TypeError, () => sensor.populateMatrix(new Float32Array(15))); + + // Throws if no orientation data available. + assert_throws_dom( + 'NotReadableError', () => sensor.populateMatrix(new Float32Array(16))); + + // Throws if passed SharedArrayBuffer view. + assert_throws_js( + TypeError, + // See https://github.com/whatwg/html/issues/5380 for why not `new + // SharedArrayBuffer()` WebAssembly.Memory's size is in multiples of 64KiB + () => sensor.populateMatrix(new Float32Array( + new WebAssembly.Memory({shared: true, initial: 1, maximum: 1}) + .buffer))); + + sensor.start(); + await sensorWatcher.wait_for('activate'); + + await Promise.all([ + test_driver.update_virtual_sensor(testDriverName, readings.next().value), + sensorWatcher.wait_for('reading') + ]); + + // Works for all supported types. + const rotationMatrix32 = new Float32Array(16); + sensor.populateMatrix(rotationMatrix32); + assert_array_approx_equals(rotationMatrix32, kRotationMatrix, kEpsilon); + + let rotationMatrix64 = new Float64Array(16); + sensor.populateMatrix(rotationMatrix64); + assert_array_approx_equals(rotationMatrix64, kRotationMatrix, kEpsilon); + + let rotationDOMMatrix = new DOMMatrix(); + sensor.populateMatrix(rotationDOMMatrix); + assert_array_approx_equals( + rotationDOMMatrix.toFloat64Array(), kRotationMatrix, kEpsilon); + + // Sets every matrix element. + rotationMatrix64.fill(123); + sensor.populateMatrix(rotationMatrix64); + assert_array_approx_equals(rotationMatrix64, kRotationMatrix, kEpsilon); +} + +function runOrientationSensorTests(sensorData, readingData) { + validate_sensor_data(sensorData); + validate_reading_data(readingData); + + const {sensorName, permissionName, testDriverName} = sensorData; + const sensorType = self[sensorName]; + + const readings = new RingBuffer(readingData.readings); + + promise_test(async t => { + assert_implements(sensorName in self, `${sensorName} is not supported.`); + return checkQuaternion( + t, sensorType, testDriverName, permissionName, readings); + }, `${sensorName}.quaternion return a four-element FrozenArray.`); + + promise_test(async (t, sensorProvider) => { + assert_implements(sensorName in self, `${sensorName} is not supported.`); + return checkPopulateMatrix( + t, sensorProvider, sensorType, testDriverName, permissionName, + readings); + }, `${sensorName}.populateMatrix() method works correctly.`); +} diff --git a/testing/web-platform/tests/orientation-sensor/resources/sensor-data.js b/testing/web-platform/tests/orientation-sensor/resources/sensor-data.js new file mode 100644 index 0000000000..a2886e7553 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/resources/sensor-data.js @@ -0,0 +1,30 @@ +'use strict'; + +const kAbsoluteOrientationSensorData = { + sensorName: 'AbsoluteOrientationSensor', + permissionName: 'accelerometer', + testDriverName: 'absolute-orientation', + featurePolicyNames: ['accelerometer', 'gyroscope', 'magnetometer'] +}; + +const kRelativeOrientationSensorData = { + sensorName: 'RelativeOrientationSensor', + permissionName: 'accelerometer', + testDriverName: 'relative-orientation', + featurePolicyNames: ['accelerometer', 'gyroscope'] +}; + +const kOrientationReadings = { + // WebDriver input data must be given in Euler angles according to + // https://w3c.github.io/deviceorientation/#parse-orientation-data-reading-algorithm + // and converted to quaternions via + // https://w3c.github.io/orientation-sensor/#create-a-quaternion-from-euler-angles. + readings: [{alpha: 0, beta: -180, gamma: 0}], + expectedReadings: [{quaternion: [-1, 0, 0, 0]}], + expectedRemappedReadings: [{quaternion: [0.70710678, -0.70710678, 0, 0]}] +}; + +const kRotationMatrix = [1, 0, 0, 0, + 0, -1, 0, 0, + 0, 0, -1, 0, + 0, 0, 0, 1]; -- cgit v1.2.3