Home | History | Annotate | Download | only in resources
      1 description("Tests that reentrant calls to Geolocation methods from the error callback are OK.");
      2 
      3 var mockCode = 0;
      4 var mockMessage = 'test';
      5 
      6 window.layoutTestController.setMockGeolocationError(mockCode, mockMessage);
      7 
      8 var error;
      9 var errorCallbackInvoked = false;
     10 navigator.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 
     27 function 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 }
     44 window.layoutTestController.waitUntilDone();
     45 
     46 var isAsynchronous = true;
     47 var successfullyParsed = true;
     48