Re: geolocation.setCurrentPosition({...}): a way to debug geolocation and give more power to users.

So, in general, you want a way to setup a mock position for testing purposes?  Do you also want to be able to control the permission prompt in this case?

In FF's case, it is trivial to write an add-on that does this - something that you can share with other users.  (In fact, our test infrastructure basically has exactly this without the add-on packaging).

Doug

On Aug 17, 2011, at 8:31 AM, louis-rémi Babé wrote:

> Hi all,
> 
> I'm currently frustrated by the lack of debuging tools regarding the
> geolocation API, as opposed to other event based device APIs such as
> deviceorientation.
> 
> To debug deviceorientation, I can simply generate a custom event right
> from my js console using create/init/dispatchEvent.
> And I can do so on any website listening to deviceorientation events
> (I don't need to be the author).
> 
> It is impossible to do the same thing with the geolocation API. To
> debug it I need the following kind of code:
> 
>     // can't use inline handler
>     function positionHandler( event ) {
>         ...
>     }
>     navigator.geolocation.watchPosition( positionHandler );
>     // need to create a global "debug object" to make the
>     // positionHandler available from my js console
>     window.updatePosition = positionHandler;
> 
> It requires to add one extra line to my code for debugging purpose,
> and I need to be the author of the website.
> I can alternatively write a geolocation provider for my Web browser,
> but that requires a far larger amount of work, a kind of knowledge
> that Web developers do not necessarily have, and it isn't a cross
> browser solution.
> 
> geolocation.setCurrentPosition() would allow to create a fake position
> in the flow of "real" position updates.
> Users could simply ignore the "permission prompt" on a website and use
> setCurrentPosition() to have complete control over the position
> updates provided to a website.
> 
> Thank you in advance for your feedback,
> louisremi@mozilla.com
> 

Received on Wednesday, 17 August 2011 16:01:27 UTC