| OLD | NEW |
| (Empty) |
| 1 description("Tests that Geolocation correctly handles multiple concurrent reques
ts."); | |
| 2 | |
| 3 var mockLatitude = 51.478; | |
| 4 var mockLongitude = -0.166; | |
| 5 var mockAccuracy = 100; | |
| 6 | |
| 7 var position; | |
| 8 var watchCallbackInvoked = false; | |
| 9 var oneShotCallbackInvoked = false; | |
| 10 | |
| 11 geolocationServiceMock.then(mock => { | |
| 12 mock.setGeolocationPermission(true); | |
| 13 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); | |
| 14 | |
| 15 navigator.geolocation.watchPosition(function(p) { | |
| 16 shouldBeFalse('watchCallbackInvoked'); | |
| 17 watchCallbackInvoked = true; | |
| 18 maybeFinishTest(p); | |
| 19 }, function() { | |
| 20 testFailed('Error callback invoked unexpectedly'); | |
| 21 finishJSTest(); | |
| 22 }); | |
| 23 | |
| 24 navigator.geolocation.getCurrentPosition(function(p) { | |
| 25 shouldBeFalse('oneShotCallbackInvoked'); | |
| 26 oneShotCallbackInvoked = true; | |
| 27 maybeFinishTest(p); | |
| 28 }, function() { | |
| 29 testFailed('Error callback invoked unexpectedly'); | |
| 30 finishJSTest(); | |
| 31 }); | |
| 32 | |
| 33 function maybeFinishTest(p) { | |
| 34 position = p; | |
| 35 shouldBe('position.coords.latitude', 'mockLatitude'); | |
| 36 shouldBe('position.coords.longitude', 'mockLongitude'); | |
| 37 shouldBe('position.coords.accuracy', 'mockAccuracy'); | |
| 38 if (watchCallbackInvoked && oneShotCallbackInvoked) | |
| 39 finishJSTest(); | |
| 40 } | |
| 41 }); | |
| 42 | |
| 43 window.jsTestIsAsync = true; | |
| OLD | NEW |