summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/geolocation-sensor
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/geolocation-sensor')
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html25
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html13
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute.https.html13
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html13
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers1
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-iframe-access.https.html17
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor-supported-by-feature-policy.html11
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor.https.html16
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor_insecure_context.html13
-rw-r--r--testing/web-platform/tests/geolocation-sensor/GeolocationSensor_read.https.html39
-rw-r--r--testing/web-platform/tests/geolocation-sensor/META.yml5
-rw-r--r--testing/web-platform/tests/geolocation-sensor/idlharness.https.window.js16
-rw-r--r--testing/web-platform/tests/geolocation-sensor/resources/sensor-data.js17
16 files changed, 214 insertions, 0 deletions
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html
new file mode 100644
index 0000000000..8fb9ea81b5
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<body>
+<title>GeolocationSensor 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('GeolocationSensor');
+
+promise_test(async t => {
+ await promise_rejects_dom(t, 'SecurityError', GeolocationSensor.read());
+}, "GeolocationSensor.read(): 'SecurityError' is thrown when disabled by Feature Policy");
+
+promise_test(async t => {
+ const controller = new AbortController();
+ const signal = controller.signal;
+ controller.abort();
+
+ await promise_rejects_dom(t, 'AbortError', GeolocationSensor.read({ signal }));
+}, "GeolocationSensor.read(): 'AbortError' takes priority");
+</script>
+</body>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html.headers
new file mode 100644
index 0000000000..7e75481ea6
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-disabled-by-feature-policy.https.html.headers
@@ -0,0 +1 @@
+Feature-Policy: geolocation 'none'
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html
new file mode 100644
index 0000000000..2bc55d6d60
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute-redirect-on-load.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>GeolocationSensor 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('GeolocationSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute.https.html
new file mode 100644
index 0000000000..81c8c7b57f
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy-attribute.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>GeolocationSensor 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('GeolocationSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html
new file mode 100644
index 0000000000..d641a03d5e
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>GeolocationSensor 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('GeolocationSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html.headers b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html.headers
new file mode 100644
index 0000000000..40e9bc16ff
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-by-feature-policy.https.html.headers
@@ -0,0 +1 @@
+Feature-Policy: geolocation *
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html
new file mode 100644
index 0000000000..f253596eca
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<body>
+<title>GeolocationSensor 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('GeolocationSensor');
+</script>
+</body>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers
new file mode 100644
index 0000000000..b83264eee7
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-enabled-on-self-origin-by-feature-policy.https.html.headers
@@ -0,0 +1 @@
+Feature-Policy: geolocation 'self'
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-iframe-access.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-iframe-access.https.html
new file mode 100644
index 0000000000..a3d39e3606
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-iframe-access.https.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>GeolocationSensor iframe test</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://wicg.github.io/geolocation-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(kGeolocationSensorData, kGeolocationReadings);
+</script>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-supported-by-feature-policy.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-supported-by-feature-policy.html
new file mode 100644
index 0000000000..aa05f33a5e
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor-supported-by-feature-policy.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<title>Test that geolocation 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('geolocation', document.featurePolicy.features());
+}, 'document.featurePolicy.features should advertise geolocation.');
+</script>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor.https.html
new file mode 100644
index 0000000000..3b4b94e5bb
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor.https.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>GeolocationSensor Test</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://wicg.github.io/geolocation-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="/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(kGeolocationSensorData, kGeolocationReadings);
+</script>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor_insecure_context.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor_insecure_context.html
new file mode 100644
index 0000000000..6a3a126c78
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor_insecure_context.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>GeolocationSensor Test: insecure context</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://wicg.github.io/geolocation-sensor/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/generic-sensor/generic-sensor-tests.js"></script>
+<script>
+
+runGenericSensorInsecureContext("GeolocationSensor");
+
+</script>
diff --git a/testing/web-platform/tests/geolocation-sensor/GeolocationSensor_read.https.html b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor_read.https.html
new file mode 100644
index 0000000000..96352f641a
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/GeolocationSensor_read.https.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>GeolocationSensor.read() Test</title>
+<link rel="author" title="Intel" href="http://www.intel.com">
+<link rel="help" href="https://wicg.github.io/geolocation-sensor/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+const properties = [
+ 'timestamp',
+ 'latitude',
+ 'longitude',
+ 'altitude',
+ 'accuracy',
+ 'altitudeAccuracy',
+ 'heading',
+ 'speed'
+];
+
+promise_test(async t => {
+ const geo = await GeolocationSensor.read({ signal: null });
+ assert_not_equals(geo.timestamp, null);
+ properties.forEach(property => assert_own_property(geo, property));
+}, "Test that read() method resolves with valid reading when signal is null");
+
+promise_test(async t => {
+ const geo = await GeolocationSensor.read();
+ assert_not_equals(geo.timestamp, null);
+ properties.forEach(property => assert_own_property(geo, property));
+}, "Test that read() method resolves with valid reading");
+
+promise_test(async t => {
+ const controller = new AbortController();
+ const signal = controller.signal;
+ controller.abort();
+
+ await promise_rejects_dom(t, 'AbortError', GeolocationSensor.read({ signal }));
+}, "Test that read() method rejects 'AbortError' if signal's aborted flag is set");
+</script>
diff --git a/testing/web-platform/tests/geolocation-sensor/META.yml b/testing/web-platform/tests/geolocation-sensor/META.yml
new file mode 100644
index 0000000000..939d6d0760
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/META.yml
@@ -0,0 +1,5 @@
+spec: https://w3c.github.io/geolocation-sensor/
+suggested_reviewers:
+ - anssiko
+ - Honry
+ - rakuco
diff --git a/testing/web-platform/tests/geolocation-sensor/idlharness.https.window.js b/testing/web-platform/tests/geolocation-sensor/idlharness.https.window.js
new file mode 100644
index 0000000000..d843dc67dd
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/idlharness.https.window.js
@@ -0,0 +1,16 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+
+// https://wicg.github.io/geolocation-sensor/
+
+'use strict';
+
+idl_test(
+ ['geolocation-sensor'],
+ ['generic-sensor', 'dom'],
+ idl_array => {
+ idl_array.add_objects({
+ GeolocationSensor: ['new GeolocationSensor'],
+ });
+ }
+);
diff --git a/testing/web-platform/tests/geolocation-sensor/resources/sensor-data.js b/testing/web-platform/tests/geolocation-sensor/resources/sensor-data.js
new file mode 100644
index 0000000000..5bbad44292
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-sensor/resources/sensor-data.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const kGeolocationSensorData = {
+ sensorName: 'GeolocationSensor',
+ permissionName: 'geolocation',
+ testDriverName: 'geolocation',
+ featurePolicyNames: ['geolocation']
+};
+
+const kGeolocationReadings = {
+ readings: [
+ [1.12345, 2.12345, 3.12345, 0.95, 0.96, 4.12345, 5.123]
+ ],
+ expectedReadings: [
+ [1.12345, 2.12345, 3.12345, 0.95, 0.96, 4.12345, 5.123]
+ ]
+};