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