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 reentrant calls to Geolocation methods from the error ca
llback are OK."); | |
11 | |
12 var mockMessage = 'test'; | |
13 | |
14 var error; | |
15 | |
16 geolocationServiceMock.then(mock => { | |
17 mock.setGeolocationPermission(true); | |
18 mock.setGeolocationPositionUnavailableError(mockMessage); | |
19 | |
20 var errorCallbackInvoked = false; | |
21 navigator.geolocation.getCurrentPosition(function(p) { | |
22 testFailed('Success callback invoked unexpectedly'); | |
23 finishJSTest(); | |
24 }, function(e) { | |
25 if (errorCallbackInvoked) { | |
26 testFailed('Error callback invoked unexpectedly'); | |
27 finishJSTest(); | |
28 } | |
29 errorCallbackInvoked = true; | |
30 | |
31 error = e; | |
32 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); | |
33 shouldBe('error.message', 'mockMessage'); | |
34 debug(''); | |
35 continueTest(); | |
36 }); | |
37 | |
38 function continueTest() { | |
39 mockMessage += ' repeat'; | |
40 | |
41 mock.setGeolocationPositionUnavailableError(mockMessage); | |
42 | |
43 navigator.geolocation.getCurrentPosition(function(p) { | |
44 testFailed('Success callback invoked unexpectedly'); | |
45 finishJSTest(); | |
46 }, function(e) { | |
47 error = e; | |
48 shouldBe('error.code', 'error.POSITION_UNAVAILABLE'); | |
49 shouldBe('error.message', 'mockMessage'); | |
50 finishJSTest(); | |
51 }); | |
52 } | |
53 }); | |
54 | |
55 window.jsTestIsAsync = true; | |
56 </script> | |
57 </body> | |
58 </html> | |
OLD | NEW |