diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/tests/mochitest/geolocation/test_native_provider.html | |
parent | Initial commit. (diff) | |
download | firefox-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 'dom/tests/mochitest/geolocation/test_native_provider.html')
-rw-r--r-- | dom/tests/mochitest/geolocation/test_native_provider.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/dom/tests/mochitest/geolocation/test_native_provider.html b/dom/tests/mochitest/geolocation/test_native_provider.html new file mode 100644 index 0000000000..e0c26c611a --- /dev/null +++ b/dom/tests/mochitest/geolocation/test_native_provider.html @@ -0,0 +1,70 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1596164 +https://bugzilla.mozilla.org/show_bug.cgi?id=1765835 +--> +<head> + <title>Test for getCurrentPosition with native location provider</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1596164">Mozilla Bug 1596164</a> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1765835">Mozilla Bug 1765835</a> +<script type="text/javascript"> +"use strict"; + +add_task(async function test_maximumAge() { + await SpecialPowers.pushPrefEnv({ + set: [["geo.provider.testing", false]], + }); + + await new Promise(resolve => { + navigator.geolocation.getCurrentPosition(() => { + ok(true, "can get position"); + resolve(); + }, () => { + ok(false, "error callback should not have been called"); + resolve(); + }, + { maximumAge: 10000 }); + }); +}); + +add_task(async function test_highAccuracy() { + await SpecialPowers.pushPrefEnv({ + set: [["geo.provider.testing", false]], + }); + + const lowAccuracy = await new Promise(resolve => { + navigator.geolocation.getCurrentPosition((pos) => { + resolve(pos.coords.accuracy); + }, () => { + ok(false, "error callback should not have been called on low accuracy call"); + resolve(); + }, + { enableHighAccuracy: false}); + }); + + const highAccuracy = await new Promise(resolve => { + navigator.geolocation.getCurrentPosition((pos) => { + resolve(pos.coords.accuracy); + }, () => { + ok(false, "error callback should not have been called on high accuracy call"); + resolve(); + }, + { enableHighAccuracy: true}); + }); + + // Low accuracy can sometimes be the same as high accuracy + // if a location provider recently provided a value + if(highAccuracy >= lowAccuracy ){ + ok(true, "accuracy is correct"); + } else { + ok(false, "lower accuracy calls should not out perform high accuracy calls"); + } +}); +</script> +</body> +</html> |