diff --git a/dom/tests/mochitest/geolocation/geolocation.html b/dom/tests/mochitest/geolocation/geolocation.html index 5e60f14ea687..e62f13e7d399 100644 --- a/dom/tests/mochitest/geolocation/geolocation.html +++ b/dom/tests/mochitest/geolocation/geolocation.html @@ -3,7 +3,10 @@ Simple access of geolocation diff --git a/dom/tests/mochitest/geolocation/test_clearWatch.html b/dom/tests/mochitest/geolocation/test_clearWatch.html index 84b9cef166d7..7da510c861e7 100644 --- a/dom/tests/mochitest/geolocation/test_clearWatch.html +++ b/dom/tests/mochitest/geolocation/test_clearWatch.html @@ -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); - diff --git a/dom/tests/mochitest/geolocation/test_manyWindows.html b/dom/tests/mochitest/geolocation/test_manyWindows.html index 65463f4a6913..afe68f1e1e86 100644 --- a/dom/tests/mochitest/geolocation/test_manyWindows.html +++ b/dom/tests/mochitest/geolocation/test_manyWindows.html @@ -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); -