1 description("Tests that when Geolocation permission is denied, watches are stopped, as well as one-shots.");
3 if (!window.testRunner || !window.internals)
4 debug('This test can not run without testRunner or internals');
6 internals.setGeolocationClientMock(document);
8 // Configure the mock Geolocation service to report a position to cause permission
9 // to be requested, then deny it.
10 internals.setGeolocationPermission(document, false);
11 internals.setGeolocationPosition(document, 51.478, -0.166, 100.0);
14 var errorCallbackInvoked = false;
15 navigator.geolocation.watchPosition(function(p) {
16 testFailed('Success callback invoked unexpectedly');
19 if (errorCallbackInvoked) {
20 testFailed('Error callback invoked unexpectedly : ' + error.message);
23 errorCallbackInvoked = true;
26 shouldBe('error.code', 'error.PERMISSION_DENIED');
27 shouldBe('error.message', '"User denied Geolocation"');
29 // Update the mock Geolocation service to report a new position, then
30 // yield to allow a chance for the success callback to be invoked.
31 internals.setGeolocationPosition(document, 55.478, -0.166, 100);
32 window.setTimeout(finishJSTest, 0);
36 window.jsTestIsAsync = true;