diff options
Diffstat (limited to 'testing/web-platform/tests/accelerometer')
17 files changed, 282 insertions, 0 deletions
diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-disabled-by-feature-policy.https.html b/testing/web-platform/tests/accelerometer/Accelerometer-disabled-by-feature-policy.https.html new file mode 100644 index 0000000000..041ddc4470 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-disabled-by-feature-policy.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<body> +<title>Accelerometer 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('Accelerometer'); +run_fp_tests_disabled('LinearAccelerationSensor'); +run_fp_tests_disabled('GravitySensor'); +</script> +</body> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-disabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/accelerometer/Accelerometer-disabled-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..beea0422d9 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-disabled-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer 'none' diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy-attribute-redirect-on-load.https.html new file mode 100644 index 0000000000..53f6960ce5 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy-attribute-redirect-on-load.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<body> +<title>Accelerometer 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('Accelerometer'); +run_fp_tests_enabled_by_attribute_redirect_on_load('LinearAccelerationSensor'); +run_fp_tests_enabled_by_attribute_redirect_on_load('GravitySensor'); +</script> +</body> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy-attribute.https.html b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy-attribute.https.html new file mode 100644 index 0000000000..3dd49d330e --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy-attribute.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<body> +<title>Accelerometer 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('Accelerometer'); +run_fp_tests_enabled_by_attribute('LinearAccelerationSensor'); +run_fp_tests_enabled_by_attribute('GravitySensor'); +</script> +</body> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy.https.html b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy.https.html new file mode 100644 index 0000000000..f5d08972d5 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<body> +<title>Accelerometer 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('Accelerometer'); +run_fp_tests_enabled('LinearAccelerationSensor'); +run_fp_tests_enabled('GravitySensor'); +</script> +</body> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..5df2754abf --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer * diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-enabled-on-self-origin-by-feature-policy.https.html b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-on-self-origin-by-feature-policy.https.html new file mode 100644 index 0000000000..2074562b7a --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-on-self-origin-by-feature-policy.https.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<body> +<title>Accelerometer 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('Accelerometer'); +run_fp_tests_enabled_on_self_origin('LinearAccelerationSensor'); +run_fp_tests_enabled_on_self_origin('GravitySensor'); +</script> +</body> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-enabled-on-self-origin-by-feature-policy.https.html.headers b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-on-self-origin-by-feature-policy.https.html.headers new file mode 100644 index 0000000000..cdefed843e --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-enabled-on-self-origin-by-feature-policy.https.html.headers @@ -0,0 +1 @@ +Feature-Policy: accelerometer 'self' diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-iframe-access.https.html b/testing/web-platform/tests/accelerometer/Accelerometer-iframe-access.https.html new file mode 100644 index 0000000000..bec1705780 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-iframe-access.https.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Accelerometer iframe test</title> +<meta name="timeout" content="long"> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/accelerometer/"> +<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('Accelerometer'); +run_generic_sensor_iframe_tests('LinearAccelerationSensor'); +run_generic_sensor_iframe_tests('GravitySensor'); +</script> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer-supported-by-feature-policy.html b/testing/web-platform/tests/accelerometer/Accelerometer-supported-by-feature-policy.html new file mode 100644 index 0000000000..8e09c7acdf --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer-supported-by-feature-policy.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<title>Test that accelerometer is advertised in the feature list</title> +<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features"> +<link rel="help" href="https://w3c.github.io/sensors/#feature-policy-api"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(() => { + assert_in_array('accelerometer', document.featurePolicy.features()); +}, 'document.featurePolicy.features should advertise accelerometer.'); +</script> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer.https.html b/testing/web-platform/tests/accelerometer/Accelerometer.https.html new file mode 100644 index 0000000000..0db87d2efc --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer.https.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Accelerometer Test</title> +<meta name="timeout" content="long"> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/accelerometer/"> +<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> + +'use strict'; + +const kReadings = { + readings: [ + [1.12345, 2.12345, 3.12345] + ], + expectedReadings: [ + [1.12345, 2.12345, 3.12345] + ], + expectedRemappedReadings: [ + [-2.12345, 1.12345, 3.12345] + ] +}; + +runGenericSensorTests( + 'Accelerometer', + kReadings, + verifyXyzSensorReading, + ['accelerometer']); + +</script> diff --git a/testing/web-platform/tests/accelerometer/Accelerometer_insecure_context.html b/testing/web-platform/tests/accelerometer/Accelerometer_insecure_context.html new file mode 100644 index 0000000000..ff1f0832c3 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/Accelerometer_insecure_context.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Accelerometer Test: insecure context</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/accelerometer/"> +<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("Accelerometer"); +runGenericSensorInsecureContext("GravitySensor"); +runGenericSensorInsecureContext("LinearAccelerationSensor"); + +</script> diff --git a/testing/web-platform/tests/accelerometer/GravitySensor.https.html b/testing/web-platform/tests/accelerometer/GravitySensor.https.html new file mode 100644 index 0000000000..6fb21e5572 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/GravitySensor.https.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Gravity Sensor Test</title> +<meta name="timeout" content="long"> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/accelerometer/"> +<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> + +'use strict'; + +const kReadings = { + readings: [ + [1.12345, 2.12345, 3.12345] + ], + expectedReadings: [ + [1.12345, 2.12345, 3.12345] + ], + expectedRemappedReadings: [ + [-2.12345, 1.12345, 3.12345] + ] +}; + +runGenericSensorTests( + 'GravitySensor', + kReadings, + verifyXyzSensorReading, + ['accelerometer']); + +</script> diff --git a/testing/web-platform/tests/accelerometer/LinearAccelerationSensor-shake-threshold-manual.https.html b/testing/web-platform/tests/accelerometer/LinearAccelerationSensor-shake-threshold-manual.https.html new file mode 100644 index 0000000000..c0746e5ebd --- /dev/null +++ b/testing/web-platform/tests/accelerometer/LinearAccelerationSensor-shake-threshold-manual.https.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>LinearAccelerationSensor Shake Threshold Test</title> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://w3c.github.io/accelerometer/#examples"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<p class="instructions"> + Shake gesture along x axis of the device. +</p> +<script> + +setup({explicit_timeout: true}); + +async_test(t => { + const shakeThreshold = 25; + const sensor = new LinearAccelerationSensor({frequency: 60}); + + sensor.onreading = t.step_func(() => { + if (sensor.x > shakeThreshold) { + t.done(); + } + }); + + sensor.onerror = t.step_func_done(event => { + assert_unreached(event.error.name + ":" + event.error.message); + }); + + sensor.start(); +}, "Test that when shaking gesture along x axis of the device, the shake threshold can be greater than 25"); + +</script> diff --git a/testing/web-platform/tests/accelerometer/LinearAccelerationSensor.https.html b/testing/web-platform/tests/accelerometer/LinearAccelerationSensor.https.html new file mode 100644 index 0000000000..8dd3446f40 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/LinearAccelerationSensor.https.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Linear Acceleration Sensor Test</title> +<meta name="timeout" content="long"> +<link rel="author" title="Intel" href="http://www.intel.com"> +<link rel="help" href="https://www.w3.org/TR/accelerometer/"> +<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> + +'use strict'; + +const kReadings = { + readings: [ + [1.12345, 2.12345, 3.12345] + ], + expectedReadings: [ + [1.12345, 2.12345, 3.12345] + ], + expectedRemappedReadings: [ + [-2.12345, 1.12345, 3.12345] + ] +}; + +runGenericSensorTests( + 'LinearAccelerationSensor', + kReadings, + verifyXyzSensorReading, + ['accelerometer']); + +</script> diff --git a/testing/web-platform/tests/accelerometer/META.yml b/testing/web-platform/tests/accelerometer/META.yml new file mode 100644 index 0000000000..dbfac71522 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/META.yml @@ -0,0 +1,5 @@ +spec: https://w3c.github.io/accelerometer/ +suggested_reviewers: + - riju + - Honry + - rakuco diff --git a/testing/web-platform/tests/accelerometer/idlharness.https.window.js b/testing/web-platform/tests/accelerometer/idlharness.https.window.js new file mode 100644 index 0000000000..1e041e9a23 --- /dev/null +++ b/testing/web-platform/tests/accelerometer/idlharness.https.window.js @@ -0,0 +1,18 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +// https://w3c.github.io/accelerometer/ + +"use strict"; + +idl_test( + ['accelerometer'], + ['generic-sensor', 'dom'], + idl_array => { + idl_array.add_objects({ + Accelerometer: ['new Accelerometer();'], + LinearAccelerationSensor: ['new LinearAccelerationSensor();'], + GravitySensor: ['new GravitySensor();'] + }); + } +); |