| OLD | NEW |
| 1 description("Tests that when Geolocation permission is denied, watches are stopp
ed, as well as one-shots."); | 1 description("Tests that when Geolocation permission is denied, watches are stopp
ed, as well as one-shots."); |
| 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 | |
| 8 // Configure the mock Geolocation service to report a position to cause permissi
on | |
| 9 // to be requested, then deny it. | |
| 10 internals.setGeolocationPermission(document, false); | |
| 11 internals.setGeolocationPosition(document, 51.478, -0.166, 100.0); | |
| 12 | 5 |
| 13 var error; | 6 var error; |
| 14 var errorCallbackInvoked = false; | 7 |
| 15 navigator.geolocation.watchPosition(function(p) { | 8 geolocationServiceMock.then(mock => { |
| 16 testFailed('Success callback invoked unexpectedly'); | 9 |
| 17 finishJSTest(); | 10 // Configure the mock Geolocation service to report a position to cause perm
ission |
| 18 }, function(e) { | 11 // to be requested, then deny it. |
| 19 if (errorCallbackInvoked) { | 12 mock.setGeolocationPermission(false); |
| 20 testFailed('Error callback invoked unexpectedly : ' + error.message); | 13 mock.setGeolocationPosition(51.478, -0.166, 100.0); |
| 14 |
| 15 var errorCallbackInvoked = false; |
| 16 navigator.geolocation.watchPosition(function(p) { |
| 17 testFailed('Success callback invoked unexpectedly'); |
| 21 finishJSTest(); | 18 finishJSTest(); |
| 22 } | 19 }, function(e) { |
| 23 errorCallbackInvoked = true; | 20 if (errorCallbackInvoked) { |
| 21 testFailed('Error callback invoked unexpectedly : ' + error.message)
; |
| 22 finishJSTest(); |
| 23 } |
| 24 errorCallbackInvoked = true; |
| 24 | 25 |
| 25 error = e; | 26 error = e; |
| 26 shouldBe('error.code', 'error.PERMISSION_DENIED'); | 27 shouldBe('error.code', 'error.PERMISSION_DENIED'); |
| 27 shouldBe('error.message', '"User denied Geolocation"'); | 28 shouldBe('error.message', '"User denied Geolocation"'); |
| 28 | 29 |
| 29 // Update the mock Geolocation service to report a new position, then | 30 // 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 // yield to allow a chance for the success callback to be invoked. |
| 31 internals.setGeolocationPosition(document, 55.478, -0.166, 100); | 32 mock.setGeolocationPosition(55.478, -0.166, 100); |
| 32 window.setTimeout(finishJSTest, 0); | 33 window.setTimeout(finishJSTest, 0); |
| 34 }); |
| 33 }); | 35 }); |
| 34 | 36 |
| 35 | |
| 36 window.jsTestIsAsync = true; | 37 window.jsTestIsAsync = true; |
| OLD | NEW |