| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| description("Tests that we do not process Geolocation request until the page become visible. Once the page becomes visible, the request should go through. This test cannot be run manually, it relies on the testRunner."); |
| window.jsTestIsAsync = true; |
| |
| var testingPhase = "initialization"; |
| |
| function geolocationWatchFunction() |
| { |
| if (testingPhase === "initialization") |
| testFailed("The geolocation request was processed while the page was still hidden."); |
| else |
| testPassed("The geolocation request was processed after the page became visible."); |
| |
| finishJSTest(); |
| } |
| |
| function onVisibilityChange() { |
| if (document.hidden) { |
| navigator.geolocation.watchPosition(geolocationWatchFunction); |
| setTimeout(function() { |
| testingPhase = "changing page to visible"; |
| testRunner.setPageVisibility("visible"); |
| }, 15); |
| } |
| } |
| |
| document.addEventListener("visibilitychange", onVisibilityChange, false) |
| |
| if (window.testRunner) { |
| testRunner.setPageVisibility("hidden"); |
| testRunner.setGeolocationPermission(true); |
| testRunner.setMockGeolocationPosition(1, 2, 3); |
| } |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |