Closed Bug 517510 Opened 15 years ago Closed 9 years ago

NetworkGeolocationProvider.js does not properly check for bad responses.

Categories

(Core :: DOM: Geolocation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bob, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB6
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB6

Every once in a rare while, this snippet of code breaks (line 232 on my copy of FF):

var newLocation = new WifiGeoPositionObject(response.location.latitude, response.location.longitude, response.location.accuracy);

The response doesn't have a location field, so you get a "response.location is undefined" error.

A simple check to verify that response.location isn't null should fix this.


Reproducible: Sometimes

Steps to Reproduce:
Impossible to reproduce on demand.
We are also seeing this while hacking on GeoLocation for Twitter.
The dupes seem to confirm this, but it's a Geolocation bug.
Status: UNCONFIRMED → NEW
Component: General → Geolocation
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → geolocation
OS->All per the duped bugs.
OS: Mac OS X → All
Hardware: x86 → All
With FF 3.5 I was able to catch the error and apply a workaround. With 3.6 the error seems to be uncatchable, and execution just stops.

On FF 3.6.3 (Linux), the error is "location is undefined" and appears at line 91 of file:///usr/lib/firefox-3.6.3/components/NetworkGeolocationProvider.js:

 this.coords = new WifiGeoCoordsObject(location.latitude,
                                       location.longitude,
                                       location.accuracy || 12450, // .5 * circumference of earth.
                                       location.altitude || 0,
                                       location.altitude_accuracy || 0);
This code today lives at https://dxr.mozilla.org/mozilla-central/source/dom/system/NetworkGeolocationProvider.js#515 which does a check for "!xhr.response || !xhr.response.location" before trying to access the ".location".
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.