Bug 645325 - Part 7: Always check location results in geolocation tests' success callbacks. r=garvank r?jdm
MozReview-Commit-ID: DVQAvxfzJNx
--- a/dom/tests/mochitest/geolocation/test_cachedPosition.html
+++ b/dom/tests/mochitest/geolocation/test_cachedPosition.html
@@ -13,16 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<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">
+"use strict";
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,
@@ -55,29 +56,32 @@ function errorCallback(err) {
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
+ // first call is just to warm up the cache
+ check_geolocation(pos);
navigator.geolocation.getCurrentPosition(function(pos) {
+ check_geolocation(pos);
cached = pos;
navigator.geolocation.getCurrentPosition(function(pos) {
+ check_geolocation(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
+ check_geolocation(pos);
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>
-
--- a/dom/tests/mochitest/geolocation/test_clearWatch.html
+++ b/dom/tests/mochitest/geolocation/test_clearWatch.html
@@ -13,16 +13,17 @@ https://bugzilla.mozilla.org/show_bug.cg
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478911">Mozilla Bug 478911</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
SimpleTest.waitForExplicitFinish();
resume_geolocationProvider(function() {
force_prompt(true, test1);
});
var hasBeenCleared = false;
@@ -32,25 +33,28 @@ var firstCallback = true;
function failureCallback(error)
{
ok(0, "we should not be seeing failures from this watchPosition");
}
function successCallback(position) {
ok(true, "successCallback was called, hasBeenCleared=" + hasBeenCleared +
", successWasCalledAfterClear=" + successWasCalledAfterClear);
+ check_geolocation(position);
if (hasBeenCleared == true) {
successWasCalledAfterClear = true;
}
if (firstCallback) {
SimpleTest.executeSoon(clearWatch);
firstCallback = false;
}
}
+let watchID;
+
function clearWatch() {
ok(true, "clearWatch was called, hasBeenCleared=" + hasBeenCleared +
", successWasCalledAfterClear=" + successWasCalledAfterClear);
navigator.geolocation.clearWatch(watchID);
hasBeenCleared = true;
SimpleTest.executeSoon(testAccepted);
}
--- a/dom/tests/mochitest/geolocation/test_clearWatchBeforeAllowing.html
+++ b/dom/tests/mochitest/geolocation/test_clearWatchBeforeAllowing.html
@@ -14,36 +14,39 @@ https://bugzilla.mozilla.org/show_bug.cg
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=886026">Mozilla Bug 886026</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
SimpleTest.waitForExplicitFinish();
resume_geolocationProvider(function() {
force_prompt(true, run_test);
});
function run_test() {
var successCallbackCalled = false,
errorCallbackCalled = false;
var watchId = navigator.geolocation.watchPosition(
function(pos) {
+ check_geolocation(pos);
successCallbackCalled = true;
}, function(err) {
errorCallbackCalled = true;
}
);
navigator.geolocation.getCurrentPosition(
function(pos) {
+ check_geolocation(pos);
SimpleTest.executeSoon(function() {
ok(successCallbackCalled == false,
"getCurrentPosition : Success callback should not have been called");
ok(errorCallbackCalled == false,
"getCurrentPosition : Error callback should not have been called");
SimpleTest.finish();
--- a/dom/tests/mochitest/geolocation/test_manyCurrentConcurrent.html
+++ b/dom/tests/mochitest/geolocation/test_manyCurrentConcurrent.html
@@ -13,28 +13,30 @@ https://bugzilla.mozilla.org/show_bug.cg
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
SimpleTest.waitForExplicitFinish();
resume_geolocationProvider(function() {
force_prompt(true, test1);
});
var successCallbackCalled = 0;
var failureCallbackCalled = 0;
const totalResults = 100;
function successCallback(position) {
+ check_geolocation(position);
successCallbackCalled++;
testPassed();
}
function failureCallback(code) {
failureCallbackCalled++;
testPassed();
}
--- a/dom/tests/mochitest/geolocation/test_manyWatchConcurrent.html
+++ b/dom/tests/mochitest/geolocation/test_manyWatchConcurrent.html
@@ -13,28 +13,30 @@ https://bugzilla.mozilla.org/show_bug.cg
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
SimpleTest.waitForExplicitFinish();
resume_geolocationProvider(function() {
force_prompt(true, test1);
});
var successCallbackCalled = 0;
var failureCallbackCalled = 0;
const totalResults = 100;
function successCallback(position) {
+ check_geolocation(position);
successCallbackCalled++;
testPassed();
}
function failureCallback(code) {
failureCallbackCalled++;
testPassed();
}
--- a/dom/tests/mochitest/geolocation/test_manyWatchSerial.html
+++ b/dom/tests/mochitest/geolocation/test_manyWatchSerial.html
@@ -9,32 +9,34 @@ https://bugzilla.mozilla.org/show_bug.cg
<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=482260">Mozilla Bug 482260</a>
<p id="display"></p>
<div id="content" style="display: none">
-
+
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
SimpleTest.waitForExplicitFinish();
resume_geolocationProvider(function() {
force_prompt(true, test1);
});
var watchID = 0;
var completeCount = 10;
function successCallback(position) {
+ check_geolocation(position);
navigator.geolocation.clearWatch(watchID);
completeCount--;
if (completeCount==0) {
ok(1, "all watchPosition successCallbacks called");
SimpleTest.finish();
--- a/dom/tests/mochitest/geolocation/test_timerRestartWatch.html
+++ b/dom/tests/mochitest/geolocation/test_timerRestartWatch.html
@@ -9,20 +9,21 @@ https://bugzilla.mozilla.org/show_bug.cg
<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=526326">Mozilla Bug 526326</a>
<p id="display"></p>
<div id="content" style="display: none">
-
+
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
SimpleTest.waitForExplicitFinish();
// ensure we are using the right testing provider
resume_geolocationProvider(function() {
force_prompt(true, test1);
});
@@ -40,16 +41,17 @@ function errorCallback(err) {
set_network_request_cache_enabled(true,
function() { SimpleTest.finish(); } );
});
}
}
function successCallback(position) {
ok(1, "on success");
+ check_geolocation(position);
// Now that we got a success callback, lets try to ensure
// that we get a timeout error.
// The network cache is already off, now stop the sjs from reponding to requests
stop_geolocationProvider(function(){});
}
var options = {
maximumAge: 0,
--- a/dom/tests/mochitest/geolocation/windowTest.html
+++ b/dom/tests/mochitest/geolocation/windowTest.html
@@ -9,23 +9,27 @@ https://bugzilla.mozilla.org/show_bug.cg
<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=493615">Mozilla Bug 493615</a>
<p id="display"></p>
<div id="content" style="display: none">
-
+
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
+"use strict";
+
var finished = false;
function successCallback(position) {
+ check_geolocation(position);
+
// watchPosition can notify more than once.
if (finished) {
return;
}
finished = true;
var opener = window.opener;
window.close();