diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/mochitest/geolocation/test_native_provider.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
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> |