| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script src="../../../resources/mojo-helpers.js"></script> | |
| 6 <script src="resources/geolocation-mock.js"></script> | |
| 7 </head> | |
| 8 <body> | |
| 9 <script> | |
| 10 description("Tests that Geolocation correctly handles multiple concurrent reques
ts."); | |
| 11 | |
| 12 var mockLatitude = 51.478; | |
| 13 var mockLongitude = -0.166; | |
| 14 var mockAccuracy = 100; | |
| 15 | |
| 16 var position; | |
| 17 var watchCallbackInvoked = false; | |
| 18 var oneShotCallbackInvoked = false; | |
| 19 | |
| 20 geolocationServiceMock.then(mock => { | |
| 21 mock.setGeolocationPermission(true); | |
| 22 mock.setGeolocationPosition(mockLatitude, mockLongitude, mockAccuracy); | |
| 23 | |
| 24 navigator.geolocation.watchPosition(function(p) { | |
| 25 shouldBeFalse('watchCallbackInvoked'); | |
| 26 watchCallbackInvoked = true; | |
| 27 maybeFinishTest(p); | |
| 28 }, function() { | |
| 29 testFailed('Error callback invoked unexpectedly'); | |
| 30 finishJSTest(); | |
| 31 }); | |
| 32 | |
| 33 navigator.geolocation.getCurrentPosition(function(p) { | |
| 34 shouldBeFalse('oneShotCallbackInvoked'); | |
| 35 oneShotCallbackInvoked = true; | |
| 36 maybeFinishTest(p); | |
| 37 }, function() { | |
| 38 testFailed('Error callback invoked unexpectedly'); | |
| 39 finishJSTest(); | |
| 40 }); | |
| 41 | |
| 42 function maybeFinishTest(p) { | |
| 43 position = p; | |
| 44 shouldBe('position.coords.latitude', 'mockLatitude'); | |
| 45 shouldBe('position.coords.longitude', 'mockLongitude'); | |
| 46 shouldBe('position.coords.accuracy', 'mockAccuracy'); | |
| 47 if (watchCallbackInvoked && oneShotCallbackInvoked) | |
| 48 finishJSTest(); | |
| 49 } | |
| 50 }); | |
| 51 | |
| 52 window.jsTestIsAsync = true; | |
| 53 </script> | |
| 54 </body> | |
| 55 </html> | |
| OLD | NEW |