Bug 593358 - Avoid use of setTimeout to check more geolocation results. r=dougt a=test-only

--HG--
extra : rebase_source : e023865e5f432a87a981fe19c09dbab5fd603cd4
This commit is contained in:
Josh Matthews 2010-10-27 02:14:45 -04:00
parent 0268cab922
commit 3c024e757b
2 changed files with 16 additions and 7 deletions

View File

@ -24,21 +24,30 @@ SimpleTest.waitForExplicitFinish();
resume_geolocationProvider();
force_prompt(true);
var successCallbackCalled = false;
var successCallbackCalled = 0;
var failureCallbackCalled = 0;
const totalResults = 100;
function successCallback(position) {
successCallbackCalled = true;
successCallbackCalled++;
testPassed();
}
for (var x = 0; x < 100; x++)
navigator.geolocation.getCurrentPosition(successCallback);
function failureCallback(code) {
failureCallbackCalled++;
testPassed();
}
for (var x = 0; x < totalResults; x++)
navigator.geolocation.getCurrentPosition(successCallback, failureCallback);
function testPassed() {
ok(successCallbackCalled, "if nothing crashed, all okay");
if (successCallbackCalled + failureCallbackCalled != totalResults)
return;
is(failureCallbackCalled, 0, "no failure callbacks should have been received");
reset_prompt();
SimpleTest.finish();
}
setTimeout(testPassed, 1000);
</script>
</pre>

View File

@ -44,7 +44,7 @@ for (var x = 0; x < totalResults; x++)
function testPassed() {
if (successCallbackCalled + failureCallbackCalled != totalResults)
return;
is(failureCallbackCalled, 0, "if nothing crashed, all okay");
is(failureCallbackCalled, 0, "no failure callbacks should have been received");
reset_prompt();
SimpleTest.finish();
}