1 description("Tests that when multiple requests are waiting for permission, no callbacks are invoked until permission is allowed."); 2 3 if (window.layoutTestController) 4 window.layoutTestController.setMockGeolocationPosition(51.478, -0.166, 100); 5 6 function allowPermission() { 7 permissionSet = true; 8 if (window.layoutTestController) 9 layoutTestController.setGeolocationPermission(true); 10 } 11 12 var watchCallbackInvoked = false; 13 var oneShotCallbackInvoked = false; 14 15 navigator.geolocation.watchPosition(function() { 16 if (permissionSet) { 17 testPassed('Success callback invoked'); 18 watchCallbackInvoked = true; 19 maybeFinishTest(); 20 return; 21 } 22 testFailed('Success callback invoked unexpectedly'); 23 finishJSTest(); 24 }, function(err) { 25 testFailed('Error callback invoked unexpectedly'); 26 finishJSTest(); 27 }); 28 29 navigator.geolocation.getCurrentPosition(function() { 30 if (permissionSet) { 31 testPassed('Success callback invoked'); 32 oneShotCallbackInvoked = true; 33 maybeFinishTest(); 34 return; 35 } 36 testFailed('Success callback invoked unexpectedly'); 37 finishJSTest(); 38 }, function(err) { 39 testFailed('Error callback invoked unexpectedly'); 40 finishJSTest(); 41 }); 42 43 window.setTimeout(allowPermission, 100); 44 45 function maybeFinishTest() { 46 if (watchCallbackInvoked && oneShotCallbackInvoked) 47 finishJSTest(); 48 } 49 50 window.jsTestIsAsync = true; 51 window.successfullyParsed = true; 52