summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/orientation-sensor
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/orientation-sensor
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/orientation-sensor')
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-disabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy-attribute.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html18
-rw-r--r--testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html25
-rw-r--r--testing/web-platform/tests/orientation-sensor/META.yml5
-rw-r--r--testing/web-platform/tests/orientation-sensor/OrientationSensor_insecure_context.html21
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-disabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy-attribute.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html18
-rw-r--r--testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html25
-rw-r--r--testing/web-platform/tests/orientation-sensor/idlharness.https.window.js18
-rw-r--r--testing/web-platform/tests/orientation-sensor/orientation-sensor-tests.js104
-rw-r--r--testing/web-platform/tests/orientation-sensor/resources/sensor-data.js30
25 files changed, 400 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..4831b5e719
--- /dev/null
+++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor-iframe-access.https.html
@@ -0,0 +1,18 @@
+<!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="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.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>
+<script src="resources/sensor-data.js"></script>
+<div id="log"></div>
+<script>
+
+run_generic_sensor_iframe_tests(kAbsoluteOrientationSensorData, kOrientationReadings);
+</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..4c516da145
--- /dev/null
+++ b/testing/web-platform/tests/orientation-sensor/AbsoluteOrientationSensor.https.html
@@ -0,0 +1,25 @@
+<!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="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/page-visibility/resources/window_state_context.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 src="resources/sensor-data.js"></script>
+<script>
+
+'use strict';
+
+runGenericSensorTests(kAbsoluteOrientationSensorData, kOrientationReadings);
+
+runOrientationSensorTests(kAbsoluteOrientationSensorData, kOrientationReadings);
+
+</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..fe995e2d1b
--- /dev/null
+++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor-iframe-access.https.html
@@ -0,0 +1,18 @@
+<!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="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.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>
+<script src="resources/sensor-data.js"></script>
+<div id="log"></div>
+<script>
+
+run_generic_sensor_iframe_tests(kRelativeOrientationSensorData, kOrientationReadings);
+</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..35dc8c3111
--- /dev/null
+++ b/testing/web-platform/tests/orientation-sensor/RelativeOrientationSensor.https.html
@@ -0,0 +1,25 @@
+<!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="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/page-visibility/resources/window_state_context.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 src="resources/sensor-data.js"></script>
+<script>
+
+'use strict';
+
+runGenericSensorTests(kRelativeOrientationSensorData, kOrientationReadings);
+
+runOrientationSensorTests(kRelativeOrientationSensorData, kOrientationReadings);
+
+</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..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];