Bug 650579 - Avoid using flaky timeout values in geolocation tests; r=sicking

This commit is contained in:
Ehsan Akhgari 2011-04-26 16:27:48 -04:00
parent 7795895f27
commit 3376f6a4d0
3 changed files with 19 additions and 19 deletions

View File

@ -3,7 +3,10 @@
<title>Simple access of geolocation</title>
<head>
<script>
navigator.geolocation.getCurrentPosition(function () {}, null, {timeout:30000});
function loadedWindow() {
opener.postMessage("loaded", "*");
}
navigator.geolocation.getCurrentPosition(loadedWindow, loadedWindow, {timeout:30000});
</script>
</head>
<body></body>

View File

@ -36,11 +36,13 @@ function successCallback(position) {
if (hasBeenCleared == true) {
successWasCalledAfterClear = true;
}
SimpleTest.executeSoon(clearWatch);
}
function clearWatch() {
navigator.geolocation.clearWatch(watchID);
hasBeenCleared = true;
SimpleTest.executeSoon(testAccepted);
}
function testAccepted() {
@ -52,10 +54,6 @@ function testAccepted() {
watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);
setTimeout(clearWatch, 250);
setTimeout(testAccepted, 2000);
</script>
</pre>
</body>

View File

@ -28,10 +28,17 @@ force_prompt(true);
/** Test for Bug **/
var numberOfWindows = 5; // 20 seems to be the default max popups during the mochitest run
var totalWindows = numberOfWindows;
var loadedWindows = 0;
var windows = new Array(numberOfWindows);
addEventListener("message", function() {
++loadedWindows;
if (loadedWindows == numberOfWindows) {
SimpleTest.executeSoon(closeWindows);
}
}, false);
for(var i = 0; i < numberOfWindows; i++) {
windows[i] = window.open("geolocation.html", "_blank", "width=700,height=400");
}
@ -40,27 +47,19 @@ function closeWindows()
{
for(var i = 0; i < numberOfWindows; i++) {
windows[i].close();
totalWindows --;
}
SimpleTest.waitForFocus(done);
}
SimpleTest.waitForExplicitFinish();
function checkDone()
function done()
{
if (totalWindows == 0)
{
ok(navigator.geolocation, "Opened a bunch of windows and didn't crash.");
clearInterval(timer);
reset_prompt();
SimpleTest.finish();
}
ok(navigator.geolocation, "Opened a bunch of windows and didn't crash.");
reset_prompt();
SimpleTest.finish();
}
var timer = setInterval(checkDone, 1000);
setTimeout(closeWindows, 5000);
</script>
</pre>
</body>