summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html')
-rw-r--r--testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html82
1 files changed, 82 insertions, 0 deletions
diff --git a/testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html b/testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html
new file mode 100644
index 0000000000..d491086cf8
--- /dev/null
+++ b/testing/web-platform/tests/geolocation-API/non-secure-contexts.http.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<meta charset="utf-8" />
+<title>Geolocation Test: non-secure contexts</title>
+<link rel="help" href="https://github.com/w3c/geolocation-api/pull/34" />
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+ promise_test(() => {
+ return new Promise(resolve => {
+ let isAsync = true;
+ const successCallback = () => {
+ assert_unreached(
+ "successCallback must never be invoked in non-secure contexts."
+ );
+ };
+ const errorCallBack = () => {
+ isAsync = false;
+ resolve();
+ };
+ navigator.geolocation.getCurrentPosition(successCallback, errorCallBack);
+ assert_true(
+ isAsync,
+ "Expected the errorCallback to be called asynchronously."
+ );
+ });
+ }, "When in a non-secure context, getCurrentPosition()'s errorCallback is asynchronously called.");
+
+ promise_test(async () => {
+ return new Promise(resolve => {
+ let isAsync = true;
+ const successCallback = () => {
+ assert_unreached(
+ "successCallback must never be invoked in non-secure contexts."
+ );
+ };
+ const errorCallBack = () => {
+ isAsync = false;
+ resolve();
+ };
+ navigator.geolocation.watchPosition(successCallback, errorCallBack);
+ assert_true(isAsync, "errorCallback must be called asynchronously.");
+ });
+ }, "When in a non-secure context, watchPosition()'s errorCallback is asynchronously called.");
+
+ promise_test(async () => {
+ const positionErrorPromise = new Promise(errorCallBack => {
+ const successCallback = () => {
+ assert_unreached(
+ "successCallback must never be invoked in non-secure contexts."
+ );
+ };
+ navigator.geolocation.getCurrentPosition(successCallback, errorCallBack);
+ });
+ const positionError = await positionErrorPromise;
+ assert_equals(
+ positionError.code,
+ 1,
+ "Expected the value for PERMISSION_DENIED, which is 1."
+ );
+ }, "When in a non-secure context, the getCurrentPosition() errorCallBack gets a GeolocationPositionError with the correct error code.");
+
+ promise_test(async () => {
+ const positionErrorPromise = new Promise(errorCallBack => {
+ const successCallback = () => {
+ assert_unreached(
+ "successCallback must never be invoked in non-secure contexts."
+ );
+ };
+ const id = navigator.geolocation.watchPosition(
+ successCallback,
+ errorCallBack
+ );
+ assert_true(Number.isInteger(id), "Must return an identifier.");
+ });
+ const positionError = await positionErrorPromise;
+ assert_equals(
+ positionError.code,
+ 1,
+ "Expected the value for PERMISSION_DENIED, which is 1."
+ );
+ }, "When in a non-secure context, the watchPosition() errorCallBack gets a GeolocationPositionError with the correct error code.");
+</script>