• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1description("Tests that reentrant calls to Geolocation methods from the error callback are OK.");
2
3var mockCode = 0;
4var mockMessage = 'test';
5
6window.layoutTestController.setMockGeolocationError(mockCode, mockMessage);
7
8var error;
9var errorCallbackInvoked = false;
10navigator.geolocation.getCurrentPosition(function(p) {
11    testFailed('Success callback invoked unexpectedly');
12    window.layoutTestController.notifyDone();
13}, function(e) {
14    if (errorCallbackInvoked) {
15        testFailed('Error callback invoked unexpectedly');
16        window.layoutTestController.notifyDone();
17    }
18    errorCallbackInvoked = true;
19
20    error = e;
21    shouldBe('error.code', 'mockCode');
22    shouldBe('error.message', 'mockMessage');
23    debug('');
24    continueTest();
25});
26
27function continueTest() {
28    mockCode += 1;
29    mockMessage += ' repeat';
30
31    window.layoutTestController.setMockGeolocationError(mockCode, mockMessage);
32
33    navigator.geolocation.getCurrentPosition(function(p) {
34        testFailed('Success callback invoked unexpectedly');
35        window.layoutTestController.notifyDone();
36    }, function(e) {
37        error = e;
38        shouldBe('error.code', 'mockCode');
39        shouldBe('error.message', 'mockMessage');
40        debug('<br /><span class="pass">TEST COMPLETE</span>');
41        window.layoutTestController.notifyDone();
42    });
43}
44window.layoutTestController.waitUntilDone();
45
46var isAsynchronous = true;
47var successfullyParsed = true;
48