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

--HG--
extra : rebase_source : 32d8978acc50556bb41d4ea084fb8141e56529e2
This commit is contained in:
Josh Matthews 2010-10-19 14:58:00 -04:00
parent ae2adc2a2a
commit 95b9e429e1

View File

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