diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeolocationTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeolocationTest.kt index b89f0a510962..df33ba617081 100644 --- a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeolocationTest.kt +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/GeolocationTest.kt @@ -95,6 +95,17 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule error => reject(error.code))""").value as JSONObject } + private fun getCurrentPositionJSWithWait(): JSONObject { + return mainSession.evaluatePromiseJS(""" + new Promise((resolve, reject) => + setTimeout(() => { + window.navigator.geolocation.getCurrentPosition( + position => resolve( + {latitude: position.coords.latitude, longitude: position.coords.longitude})), + error => reject(error.code) + }, "750"))""").value as JSONObject + } + @GeckoSessionTestRule.NullDelegate(Autofill.Delegate::class) // General test that location can be requested from JS and that the mock provider is providing location @Test fun jsContentRequestForLocation() { @@ -170,13 +181,13 @@ import org.mozilla.geckoview.test.rule.GeckoSessionTestRule // Ensures a return to the foreground Handler(Looper.getMainLooper()).postDelayed({ setActivityToForeground() - }, 1000) + }, 1500) // Will cause onPause event to occur pressHome() // After/During onPause Event - val whilePausingPosition = getCurrentPositionJS() + val whilePausingPosition = getCurrentPositionJSWithWait() assertThat("Longitude after/during onPause matches.", whilePausingPosition["latitude"] as Number, equalTo(afterPauseLat)) assertThat("Longitude after/during onPause matches.", whilePausingPosition["longitude"] as Number, equalTo(afterPauseLon))