blob: b8bddd963e1ca9f6e53af75ca1cff425f7eb7822 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body onload="runTest()">
<script>
description("Tests that the GeolocationClient stops updating when the page becomes hidden");
window.jsTestIsAsync = true;
function geolocationWatchFunction()
{
}
function showPage()
{
debug("Changing page visibility to 'visible'");
testRunner.setPageVisibility("visible");
}
function onVisibilityChange() {
debug("Page visibility changed to " + !document.hidden);
if (document.hidden)
shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "false", showPage);
else
shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "true", finishJSTest);
}
document.addEventListener("visibilitychange", onVisibilityChange, false)
if (window.testRunner) {
testRunner.setGeolocationPermission(true);
testRunner.setMockGeolocationPosition(1, 2, 3);
}
function hidePage()
{
debug("Changing page visibility to 'hidden'");
if (window.testRunner)
testRunner.setPageVisibility("hidden");
}
function runTest()
{
debug("Page is initially visible");
shouldBeFalse("document.hidden");
shouldBeFalse("testRunner.isGeolocationProviderActive()");
debug("Adding Geolocation watcher");
navigator.geolocation.watchPosition(geolocationWatchFunction);
shouldBecomeEqual("testRunner.isGeolocationProviderActive()", "true", hidePage);
}
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>