summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/ambient-light
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/ambient-light')
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html13
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute.https.html13
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-iframe-access.https.html17
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor-supported-by-feature-policy.html11
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor.https.html17
-rw-r--r--testing/web-platform/tests/ambient-light/AmbientLightSensor_insecure_context.html20
-rw-r--r--testing/web-platform/tests/ambient-light/META.yml5
-rw-r--r--testing/web-platform/tests/ambient-light/idlharness.https.window.js16
-rw-r--r--testing/web-platform/tests/ambient-light/resources/sensor-data.js47
15 files changed, 201 insertions, 0 deletions
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html
new file mode 100644
index 0000000000..fb20d70d93
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>AmbientLightSensor 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('AmbientLightSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html.headers
new file mode 100644
index 0000000000..b8073a87be
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-disabled-by-feature-policy.https.html.headers
@@ -0,0 +1 @@
+Feature-Policy: ambient-light-sensor 'none'
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html
new file mode 100644
index 0000000000..1d28792cbc
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>AmbientLightSensor 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('AmbientLightSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute.https.html
new file mode 100644
index 0000000000..4b58a26244
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy-attribute.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>AmbientLightSensor 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('AmbientLightSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html
new file mode 100644
index 0000000000..a1651b876d
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>AmbientLightSensor 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('AmbientLightSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html.headers
new file mode 100644
index 0000000000..f037f3ff57
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-by-feature-policy.https.html.headers
@@ -0,0 +1 @@
+Feature-Policy: ambient-light-sensor *
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html
new file mode 100644
index 0000000000..ab9848cb2c
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>AmbientLightSensor 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('AmbientLightSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html.headers b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html.headers
new file mode 100644
index 0000000000..1d22667050
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-enabled-on-self-origin-by-feature-policy.https.html.headers
@@ -0,0 +1 @@
+Feature-Policy: ambient-light-sensor 'self'
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-iframe-access.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-iframe-access.https.html
new file mode 100644
index 0000000000..765c1bee1f
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-iframe-access.https.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AmbientLightSensor iframe test</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://w3c.github.io/ambient-light/">
+<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(kSensorData, kReadings);
+</script>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor-supported-by-feature-policy.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor-supported-by-feature-policy.html
new file mode 100644
index 0000000000..d5c27c8bef
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor-supported-by-feature-policy.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<title>Test that ambient-light-sensor 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('ambient-light-sensor', document.featurePolicy.features());
+}, 'document.featurePolicy.features should advertise ambient-light-sensor.');
+</script>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor.https.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor.https.html
new file mode 100644
index 0000000000..f2ed655082
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor.https.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AmbientLightSensor 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/ambient-light/">
+<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="resources/sensor-data.js"></script>
+<script>
+runGenericSensorTests(kSensorData, kReadings);
+</script>
diff --git a/testing/web-platform/tests/ambient-light/AmbientLightSensor_insecure_context.html b/testing/web-platform/tests/ambient-light/AmbientLightSensor_insecure_context.html
new file mode 100644
index 0000000000..9a7c91492b
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/AmbientLightSensor_insecure_context.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>AmbientLightSensor Test: insecure context</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://www.w3.org/TR/ambient-light/">
+<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>Precondition</h2>
+<ol>
+ <li>
+ Run test in an insecure context, e.g. http://example.com/.
+ </li>
+</ol>
+<script>
+
+runGenericSensorInsecureContext("AmbientLightSensor");
+
+</script>
diff --git a/testing/web-platform/tests/ambient-light/META.yml b/testing/web-platform/tests/ambient-light/META.yml
new file mode 100644
index 0000000000..e173970b5d
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/META.yml
@@ -0,0 +1,5 @@
+spec: https://w3c.github.io/ambient-light/
+suggested_reviewers:
+ - riju
+ - rakuco
+ - Honry
diff --git a/testing/web-platform/tests/ambient-light/idlharness.https.window.js b/testing/web-platform/tests/ambient-light/idlharness.https.window.js
new file mode 100644
index 0000000000..211e6aa017
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/idlharness.https.window.js
@@ -0,0 +1,16 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+
+// https://w3c.github.io/ambient-light/
+
+'use strict';
+
+idl_test(
+ ['ambient-light'],
+ ['generic-sensor', 'dom'],
+ idl_array => {
+ idl_array.add_objects({
+ AmbientLightSensor: ['new AmbientLightSensor()']
+ });
+ }
+);
diff --git a/testing/web-platform/tests/ambient-light/resources/sensor-data.js b/testing/web-platform/tests/ambient-light/resources/sensor-data.js
new file mode 100644
index 0000000000..c1f7bd5ca0
--- /dev/null
+++ b/testing/web-platform/tests/ambient-light/resources/sensor-data.js
@@ -0,0 +1,47 @@
+'use strict';
+
+const kSensorData = {
+ sensorName: 'AmbientLightSensor',
+ permissionName: 'ambient-light-sensor',
+ testDriverName: 'ambient-light',
+ featurePolicyNames: ['ambient-light-sensor']
+};
+
+const kReadings = {
+ readings: [
+ // Readings are selected so that illuminance significance check causes
+ // the following to happen:
+ // 1. First two values test situation when two values would be rounded
+ // to same value. As the second value would be rounded to same value
+ // as first it won't trigger reading event.
+ // 2. New value is set to 24. And test checks it is correctly rounded to
+ // 0.
+ // 3. New reading is attempted to set to 35.
+ // 4. Value is read from sensor and compared new reading. But as new
+ // reading was not significantly different compared to initial, for
+ // privacy reasons, service returns the initial value.
+ // 5. New value is set to 49. And test checks it is correctly rounded to
+ // 50. New value is allowed as it is significantly different compared
+ // to old value (24).
+ // 6. New reading is attempted to set to 35.
+ // 7. Value is read from sensor and compared new reading. But as new
+ // reading was not significantly different compared to initial, for
+ // privacy reasons, service returns the initial value.
+ // 8. New value is set to 23. And test checks it is correctly rounded to
+ // 0. New value is allowed as it is significantly different compared
+ // to old value (49).
+ //
+ // Note: Readings and expectedReadings wraps around correctly as next
+ // value would be 150 (output from 127).
+ { illuminance: 127 }, { illuminance: 165 }, { illuminance: 24 }, {
+ illuminance:
+ 35
+ }, { illuminance: 49 }, { illuminance: 35 }, { illuminance: 23 }
+ ],
+ expectedReadings: [
+ { illuminance: 150 }, // output from 127
+ { illuminance: 0 }, // output from 24
+ { illuminance: 50 }, // output from 49
+ { illuminance: 0 } // output from 23
+ ]
+};