summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/geolocation/test_cachedPosition.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/geolocation/test_cachedPosition.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/geolocation/test_cachedPosition.html')
-rw-r--r--dom/tests/mochitest/geolocation/test_cachedPosition.html83
1 files changed, 83 insertions, 0 deletions
diff --git a/dom/tests/mochitest/geolocation/test_cachedPosition.html b/dom/tests/mochitest/geolocation/test_cachedPosition.html
new file mode 100644
index 000000000..067bf205f
--- /dev/null
+++ b/dom/tests/mochitest/geolocation/test_cachedPosition.html
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=850442
+-->
+<head>
+ <title>Test for getCurrentPosition </title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="geolocation_common.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=850442">Mozilla Bug 850442</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+/*
+The request cache vs. the PositionOptions cache is confusing to the reader, to explain:
+
+Testing uses mochitest httpd, so the network cache must be disabled in order for requests
+to propagate to mochitest httpd. Otherwise, every request looks like a geoip request,
+and the network request cache sees no reason to make a web request for location for geoip
+if it has already made geoip (or better) requests.
+
+We should investigate providing fake wifi and cell scans to the
+network location provider, then the network cache does not need to be shut off
+AND it will get testing coverage.
+
+*/
+resume_geolocationProvider(function() {
+ force_prompt(true, function () {
+ set_network_request_cache_enabled(false, test_cachedPosition)
+ });
+});
+
+function done() {
+ set_network_request_cache_enabled(true, function() {
+ resume_geolocationProvider(function() {
+ SimpleTest.finish();
+ });
+ });
+}
+
+function errorCallback(err) {
+ ok(false, "error callback should not have been called");
+ done();
+}
+
+function areTimesEqual(loc1, loc2) {
+ return loc1.timestamp === loc2.timestamp;
+}
+
+function test_cachedPosition() {
+ var cached = null;
+ navigator.geolocation.getCurrentPosition(function(pos) {
+ // first call is just to warm up the cache
+
+ navigator.geolocation.getCurrentPosition(function(pos) {
+ cached = pos;
+
+ navigator.geolocation.getCurrentPosition(function(pos) {
+ ok(areTimesEqual(pos, cached), "position should be equal to cached position");
+ navigator.geolocation.getCurrentPosition(function(pos) {
+ // force new position, can't be the one we have
+ ok(!areTimesEqual(pos, cached), "position should not be equal to cached position");
+ done();
+ }, errorCallback, {maximumAge: 0});
+ }, errorCallback, {maximumAge: 21600000});
+ }, errorCallback, {maximumAge: 21600000});
+ }, errorCallback, {maximumAge: 21600000});
+ }
+</script>
+</pre>
+</body>
+</html>
+