Index: third_party/WebKit/LayoutTests/fast/dom/Geolocation/watchPosition-page-visibility.html |
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/watchPosition-page-visibility.html b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/watchPosition-page-visibility.html |
index 944e5635c9e17e9a78b097c3de32eec60c95fd87..125affd1ccec319f94da9621dbd43c925e3560f3 100644 |
--- a/third_party/WebKit/LayoutTests/fast/dom/Geolocation/watchPosition-page-visibility.html |
+++ b/third_party/WebKit/LayoutTests/fast/dom/Geolocation/watchPosition-page-visibility.html |
@@ -2,82 +2,86 @@ |
<html> |
<head> |
<script src="../../../resources/js-test.js"></script> |
+<script src="../../../resources/mojo-helpers.js"></script> |
+<script src="resources/geolocation-mock.js"></script> |
</head> |
<body> |
<script> |
description("Tests that watchPosition does not report position changes when the page is not visible."); |
window.jsTestIsAsync = true; |
-if (!window.testRunner || !window.internals) |
- debug('This test can not run without testRunner or internals'); |
+if (!window.testRunner || !window.mojo) |
+ debug('This test can not run without testRunner or mojo'); |
-internals.setGeolocationClientMock(document); |
-internals.setGeolocationPermission(document, true); |
+var position; |
+var error; |
+var isPageVisible = true; |
-debug("* Page is visible"); |
+geolocationServiceMock.then(mock => { |
+ mock.setGeolocationPermission(true); |
-var mockLatitude = 51.478; |
-var mockLongitude = -0.166; |
-var mockAccuracy = 100.0; |
+ debug("* Page is visible"); |
-function updatePosition() { |
- if (!window.testRunner) |
- return; |
- ++mockLatitude; |
- ++mockLongitude; |
- internals.setGeolocationPosition(document, mockLatitude, mockLongitude, mockAccuracy); |
- debug('device moved to (' + mockLatitude + ', ' + mockLongitude + ')'); |
-} |
+ var mockLatitude = 51.478; |
+ var mockLongitude = -0.166; |
+ var mockAccuracy = 100.0; |
-updatePosition(); |
+ function updatePosition() { |
+ if (!window.testRunner) |
+ return; |
+ ++mockLatitude; |
+ ++mockLongitude; |
+ mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); |
+ debug('device moved to (' + mockLatitude + ', ' + mockLongitude + ')'); |
+ } |
-var state = 0; |
-var position; |
-var error; |
-var isPageVisible = true; |
+ updatePosition(); |
-function checkPosition(p) { |
- position = p; |
- shouldBe('position.coords.latitude', '' + mockLatitude); |
- shouldBe('position.coords.longitude', '' + mockLongitude); |
- debug(''); |
-} |
+ var state = 0; |
-function showPageAndUpdatePosition() { |
- shouldBeFalse('isPageVisible'); |
- debug(''); |
- state++; |
- if (window.testRunner) { |
- debug("*Showing page"); |
- testRunner.setPageVisibility("visible"); |
- isPageVisible = true; |
+ function checkPosition(p) { |
+ position = p; |
+ shouldBe('position.coords.latitude', '' + mockLatitude); |
+ shouldBe('position.coords.longitude', '' + mockLongitude); |
+ debug(''); |
} |
- updatePosition(); |
-} |
-navigator.geolocation.watchPosition(function(p) { |
- debug("Page is notified of the position change"); |
- shouldBeTrue('isPageVisible'); |
- state++; |
- checkPosition(p); |
- switch(state) { |
- case 2: { |
- if (window.testRunner) { |
- debug("* Hiding page"); |
- testRunner.setPageVisibility("hidden"); |
- isPageVisible = false; |
- } |
- setTimeout(showPageAndUpdatePosition, 100); |
- break; |
+ function showPageAndUpdatePosition() { |
+ shouldBeFalse('isPageVisible'); |
+ debug(''); |
+ state++; |
+ if (window.testRunner) { |
+ debug("*Showing page"); |
+ testRunner.setPageVisibility("visible"); |
+ isPageVisible = true; |
} |
- case 4: |
- finishJSTest(); |
- return; |
+ updatePosition(); |
} |
- updatePosition(); |
-}, function(e) { |
- testFailed('Error callback invoked unexpectedly'); |
- finishJSTest(); |
+ |
+ navigator.geolocation.watchPosition(function(p) { |
+ debug("Page is notified of the position change"); |
+ shouldBeTrue('isPageVisible'); |
+ state++; |
+ checkPosition(p); |
+ switch(state) { |
+ case 2: { |
+ if (window.testRunner) { |
+ debug("* Hiding page"); |
+ testRunner.setPageVisibility("hidden"); |
+ isPageVisible = false; |
+ } |
+ setTimeout(showPageAndUpdatePosition, 100); |
+ break; |
+ } |
+ case 4: |
+ finishJSTest(); |
+ return; |
+ } |
+ updatePosition(); |
+ }, function(e) { |
+ testFailed('Error callback invoked unexpectedly'); |
+ finishJSTest(); |
+ }); |
}); |
</script> |