1 description("Tests that reentrant calls to Geolocation methods from the success callback are OK."); 2 3 var mockLatitude = 51.478; 4 var mockLongitude = -0.166; 5 var mockAccuracy = 100.0; 6 7 window.layoutTestController.setGeolocationPermission(true); 8 window.layoutTestController.setMockGeolocationPosition(mockLatitude, 9 mockLongitude, 10 mockAccuracy); 11 12 var position; 13 var successCallbackInvoked = false; 14 navigator.geolocation.getCurrentPosition(function(p) { 15 if (successCallbackInvoked) { 16 testFailed('Success callback invoked unexpectedly'); 17 window.layoutTestController.notifyDone(); 18 } 19 successCallbackInvoked = true; 20 21 position = p; 22 shouldBe('position.coords.latitude', 'mockLatitude'); 23 shouldBe('position.coords.longitude', 'mockLongitude'); 24 shouldBe('position.coords.accuracy', 'mockAccuracy'); 25 debug(''); 26 continueTest(); 27 }, function(e) { 28 testFailed('Error callback invoked unexpectedly'); 29 window.layoutTestController.notifyDone(); 30 }); 31 32 function continueTest() { 33 window.layoutTestController.setMockGeolocationPosition(++mockLatitude, 34 ++mockLongitude, 35 ++mockAccuracy); 36 37 navigator.geolocation.getCurrentPosition(function(p) { 38 position = p; 39 shouldBe('position.coords.latitude', 'mockLatitude'); 40 shouldBe('position.coords.longitude', 'mockLongitude'); 41 shouldBe('position.coords.accuracy', 'mockAccuracy'); 42 debug('<br /><span class="pass">TEST COMPLETE</span>'); 43 window.layoutTestController.notifyDone(); 44 }, function(e) { 45 testFailed('Error callback invoked unexpectedly'); 46 window.layoutTestController.notifyDone(); 47 }); 48 } 49 window.layoutTestController.waitUntilDone(); 50 51 var isAsynchronous = true; 52 var successfullyParsed = true; 53