| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script src="../../../resources/mojo-helpers.js"></script> | |
| 6 <script src="resources/geolocation-mock.js"></script> | |
| 7 </head> | |
| 8 <body> | |
| 9 <script> | |
| 10 description("Tests that when Geolocation permission is denied, watches are stopp
ed, as well as one-shots."); | |
| 11 | |
| 12 var error; | |
| 13 | |
| 14 geolocationServiceMock.then(mock => { | |
| 15 | |
| 16 // Configure the mock Geolocation service to report a position to cause perm
ission | |
| 17 // to be requested, then deny it. | |
| 18 mock.setGeolocationPermission(false); | |
| 19 mock.setGeolocationPosition(51.478, -0.166, 100.0); | |
| 20 | |
| 21 var errorCallbackInvoked = false; | |
| 22 navigator.geolocation.watchPosition(function(p) { | |
| 23 testFailed('Success callback invoked unexpectedly'); | |
| 24 finishJSTest(); | |
| 25 }, function(e) { | |
| 26 if (errorCallbackInvoked) { | |
| 27 testFailed('Error callback invoked unexpectedly : ' + error.message)
; | |
| 28 finishJSTest(); | |
| 29 } | |
| 30 errorCallbackInvoked = true; | |
| 31 | |
| 32 error = e; | |
| 33 shouldBe('error.code', 'error.PERMISSION_DENIED'); | |
| 34 shouldBe('error.message', '"User denied Geolocation"'); | |
| 35 | |
| 36 // Update the mock Geolocation service to report a new position, then | |
| 37 // yield to allow a chance for the success callback to be invoked. | |
| 38 mock.setGeolocationPosition(55.478, -0.166, 100); | |
| 39 window.setTimeout(finishJSTest, 0); | |
| 40 }); | |
| 41 }); | |
| 42 | |
| 43 window.jsTestIsAsync = true; | |
| 44 </script> | |
| 45 </body> | |
| 46 </html> | |
| OLD | NEW |