Home | History | Annotate | Download | only in script-tests
      1 description("Tests formatting of position.toString().");
      2 
      3 var mockLatitude = 51.478;
      4 var mockLongitude = -0.166;
      5 var mockAccuracy = 100.0;
      6 
      7 if (window.layoutTestController) {
      8     layoutTestController.setGeolocationPermission(true);
      9     layoutTestController.setMockGeolocationPosition(mockLatitude,
     10                                                     mockLongitude,
     11                                                     mockAccuracy);
     12 } else
     13     debug('This test can not be run without the LayoutTestController');
     14 
     15 var position;
     16 navigator.geolocation.getCurrentPosition(function(p) {
     17     // shouldBe can't use local variables yet.
     18     position = p;
     19     shouldBe('position.coords.latitude', 'mockLatitude');
     20     shouldBe('position.coords.longitude', 'mockLongitude');
     21     shouldBe('position.coords.accuracy', 'mockAccuracy');
     22     shouldBe('position.toString()', '"[object Geoposition]"');
     23     shouldBe('position.coords.toString()', '"[object Coordinates]"');
     24     finishJSTest();
     25 }, function(e) {
     26     testFailed('Error callback invoked unexpectedly');
     27     finishJSTest();
     28 });
     29 
     30 window.jsTestIsAsync = true;
     31 window.successfullyParsed = true;
     32