diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/orientation-sensor | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/orientation-sensor')
24 files changed, 345 insertions, 0 deletions
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 @@ +<!DOCTYPE html> +<body> +<title>AbsoluteOrientationSensor Feature Policy Test: Disabled</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_disabled('AbsoluteOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>AbsoluteOrientationSensor Feature Policy Test: Enabled by attribute redirect on load</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled_by_attribute_redirect_on_load('AbsoluteOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>AbsoluteOrientationSensor Feature Policy Test: Enabled by attribute</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled_by_attribute('AbsoluteOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>AbsoluteOrientationSensor Feature Policy Test: Enabled</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled('AbsoluteOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>AbsoluteOrientationSensor Feature Policy Test: Enabled on self origin</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled_on_self_origin('AbsoluteOrientationSensor'); +</script> +</body> 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..e99b5c6365 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>AbsoluteOrientationSensor iframe test</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/orientation-sensor/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script> +<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<div id="log"></div> +<script> + +run_generic_sensor_iframe_tests('AbsoluteOrientationSensor'); +</script> 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..e6f5dd9138 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>OrientationSensor Test</title> +<meta name="timeout" content="long"> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://w3c.github.io/orientation-sensor/"> +<link rel="help" href="https://w3c.github.io/sensors/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script> +<script src="/generic-sensor/generic-sensor-tests.js"></script> +<script src="/orientation-sensor/orientation-sensor-tests.js"></script> +<script> + +runGenericSensorTests( + 'AbsoluteOrientationSensor', + kReadings, + verifyQuatSensorReading, + ['accelerometer', 'gyroscope', 'magnetometer']); + +runOrientationSensorTests('AbsoluteOrientationSensor'); + +</script> 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 @@ +<meta charset="utf-8"> +<title>AbsoluteOrientationSensor Test: insecure context</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://w3c.github.io/orientation-sensor/"> +<link rel="help" href="https://w3c.github.io/sensors/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/generic-sensor/generic-sensor-tests.js"></script> +<div id="log"></div> +<h2>Note:</h2> +<ol> + <li> + Run test in an insecure context, e.g. http://example.com/. + </li> +</ol> +<script> + +runGenericSensorInsecureContext("AbsoluteOrientationSensor"); +runGenericSensorInsecureContext("RelativeOrientationSensor"); + +</script> 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 @@ +<!DOCTYPE html> +<body> +<title>RelativeOrientationSensor Feature Policy Test: Disabled</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_disabled('RelativeOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>RelativeOrientationSensor Feature Policy Test: Enabled by attribute redirect on load</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled_by_attribute_redirect_on_load('RelativeOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>RelativeOrientationSensor Feature Policy Test: Enabled by attribute</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled_by_attribute('RelativeOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>RelativeOrientationSensor Feature Policy Test: Enabled</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled('RelativeOrientationSensor'); +</script> +</body> 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 @@ +<!DOCTYPE html> +<body> +<title>RelativeOrientationSensor Feature Policy Test: Enabled on self origin</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/feature-policy/resources/featurepolicy.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<script> +"use strict"; + +run_fp_tests_enabled_on_self_origin('RelativeOrientationSensor'); +</script> +</body> 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..5d30534841 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>RelativeOrientationSensor iframe test</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/orientation-sensor/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script> +<script src="/generic-sensor/generic-sensor-iframe-tests.sub.js"></script> +<script src="/generic-sensor/generic-sensor-feature-policy-test.sub.js"></script> +<div id="log"></div> +<script> + +run_generic_sensor_iframe_tests('RelativeOrientationSensor'); +</script> 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..499e7df8ce --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>OrientationSensor Test</title> +<meta name="timeout" content="long"> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://w3c.github.io/orientation-sensor/"> +<link rel="help" href="https://w3c.github.io/sensors/"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/generic-sensor/resources/generic-sensor-helpers.js"></script> +<script src="/generic-sensor/generic-sensor-tests.js"></script> +<script src="/orientation-sensor/orientation-sensor-tests.js"></script> +<script> + +runGenericSensorTests( + 'RelativeOrientationSensor', + kReadings, + verifyQuatSensorReading, + ['accelerometer', 'gyroscope']); + +runOrientationSensorTests('RelativeOrientationSensor'); + +</script> 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..88fd432d47 --- /dev/null +++ b/testing/web-platform/tests/orientation-sensor/orientation-sensor-tests.js @@ -0,0 +1,89 @@ +'use strict'; + +const kDefaultReading = [ + [ 1, 0, 0, 0 ] // 180 degrees around X axis. +]; +const kRotationMatrix = [1, 0, 0, 0, + 0, -1, 0, 0, + 0, 0, -1, 0, + 0, 0, 0, 1]; +const kReadings = { + readings: kDefaultReading, + expectedReadings: kDefaultReading, + expectedRemappedReadings: [ + // For 'orientation.angle == 270', which is set for tests at + // at SensorProxy::GetScreenOrientationAngle(). + [-0.707107, 0.707107, 0, 0] + ] +}; + +async function checkQuaternion(t, sensorType) { + const sensor = new sensorType(); + const eventWatcher = new EventWatcher(t, sensor, ["reading", "error"]); + sensor.start(); + + await eventWatcher.wait_for("reading"); + assert_equals(sensor.quaternion.length, 4); + assert_true(sensor.quaternion instanceof Array); + sensor.stop(); +}; + +async function checkPopulateMatrix(t, sensorProvider, sensorType) { + const sensor = new sensorType(); + const eventWatcher = new EventWatcher(t, sensor, ["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 64 KiB + () => sensor.populateMatrix(new Float32Array(new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer))); + + sensor.start(); + + const mockSensor = await sensorProvider.getCreatedSensor(sensorType.name); + await mockSensor.setSensorReading(kDefaultReading); + + await eventWatcher.wait_for("reading"); + + // Works for all supported types. + const rotationMatrix32 = new Float32Array(16); + sensor.populateMatrix(rotationMatrix32); + assert_array_equals(rotationMatrix32, kRotationMatrix); + + let rotationMatrix64 = new Float64Array(16); + sensor.populateMatrix(rotationMatrix64); + assert_array_equals(rotationMatrix64, kRotationMatrix); + + let rotationDOMMatrix = new DOMMatrix(); + sensor.populateMatrix(rotationDOMMatrix); + assert_array_equals(rotationDOMMatrix.toFloat64Array(), kRotationMatrix); + + // Sets every matrix element. + rotationMatrix64.fill(123); + sensor.populateMatrix(rotationMatrix64); + assert_array_equals(rotationMatrix64, kRotationMatrix); + + sensor.stop(); +} + +function runOrientationSensorTests(sensorName) { + const sensorType = self[sensorName]; + + sensor_test(async t => { + assert_true(sensorName in self); + return checkQuaternion(t, sensorType); + }, `${sensorName}.quaternion return a four-element FrozenArray.`); + + sensor_test(async (t, sensorProvider) => { + assert_true(sensorName in self); + return checkPopulateMatrix(t, sensorProvider, sensorType); + }, `${sensorName}.populateMatrix() method works correctly.`); +} |