| OLD | NEW |
| 1 description("Tests that when Geolocation permission has been denied prior to a c
all to a Geolocation method, the error callback is invoked with code PERMISSION_
DENIED, when the Geolocation service encounters an error."); | 1 description("Tests that when Geolocation permission has been denied prior to a c
all to a Geolocation method, the error callback is invoked with code PERMISSION_
DENIED, when the Geolocation service encounters an error."); |
| 2 | 2 |
| 3 if (!window.testRunner || !window.internals) | 3 if (!window.testRunner || !window.mojo) |
| 4 debug('This test can not run without testRunner or internals'); | 4 debug('This test can not run without testRunner or mojo'); |
| 5 | |
| 6 internals.setGeolocationClientMock(document); | |
| 7 internals.setGeolocationPermission(document, false); | |
| 8 internals.setGeolocationPosition(document, 51.478, -0.166, 100); | |
| 9 | 5 |
| 10 var error; | 6 var error; |
| 11 navigator.geolocation.getCurrentPosition(function(p) { | |
| 12 testFailed('Success callback invoked unexpectedly'); | |
| 13 finishJSTest(); | |
| 14 }, function(e) { | |
| 15 error = e; | |
| 16 shouldBe('error.code', 'error.PERMISSION_DENIED'); | |
| 17 shouldBe('error.message', '"User denied Geolocation"'); | |
| 18 debug(''); | |
| 19 continueTest(); | |
| 20 }); | |
| 21 | 7 |
| 22 function continueTest() | 8 geolocationServiceMock.then(mock => { |
| 23 { | 9 mock.setGeolocationPermission(false); |
| 24 // Make another request, with permission already denied. | 10 mock.setGeolocationPosition(51.478, -0.166, 100); |
| 25 internals.setGeolocationPositionUnavailableError(document, 'test'); | |
| 26 | 11 |
| 27 navigator.geolocation.getCurrentPosition(function(p) { | 12 navigator.geolocation.getCurrentPosition(function(p) { |
| 28 testFailed('Success callback invoked unexpectedly'); | 13 testFailed('Success callback invoked unexpectedly'); |
| 29 finishJSTest(); | 14 finishJSTest(); |
| 30 }, function(e) { | 15 }, function(e) { |
| 31 error = e; | 16 error = e; |
| 32 shouldBe('error.code', 'error.PERMISSION_DENIED'); | 17 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| 33 shouldBe('error.message', '"User denied Geolocation"'); | 18 shouldBe('error.message', '"User denied Geolocation"'); |
| 34 finishJSTest(); | 19 debug(''); |
| 20 continueTest(); |
| 35 }); | 21 }); |
| 36 } | 22 |
| 23 function continueTest() |
| 24 { |
| 25 // Make another request, with permission already denied. |
| 26 mock.setGeolocationPositionUnavailableError('test'); |
| 27 |
| 28 navigator.geolocation.getCurrentPosition(function(p) { |
| 29 testFailed('Success callback invoked unexpectedly'); |
| 30 finishJSTest(); |
| 31 }, function(e) { |
| 32 error = e; |
| 33 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| 34 shouldBe('error.message', '"User denied Geolocation"'); |
| 35 finishJSTest(); |
| 36 }); |
| 37 } |
| 38 }); |
| 37 | 39 |
| 38 window.jsTestIsAsync = true; | 40 window.jsTestIsAsync = true; |
| OLD | NEW |