Closed Bug 858827 Opened 13 years ago Closed 10 years ago

Error callback should be called when timeout is zero and there's no cached position for getCurrentLocation

Categories

(Core :: DOM: Geolocation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: ggp, Assigned: alchen)

Details

Attachments

(2 files, 1 obsolete file)

The spec says setting timeout to zero in getCurrentLocation should have the error callback be called unless there is a cached version with suitable age (that is, smaller than maximumAge) to be used. In particular, setting timeout to 0 and maximumAge to a high number (potentially Infinity) should result in a cached position be returned if possible, without ever contacting the geolocation provider. Our implementation, however, sets no timeout in that case, and if there's no cached position to be used, waits until a new position is obtained from the geolocation provider however long that takes.
Assignee: nobody → gkeeley
Assignee: garvankeeley+bmo → nobody
Attachment #8693708 - Flags: feedback+
Here is a fix for this symptom. Currently, we don't handle the case when timeout is zero. However, following the W3C spec, "Error callback" should be called with error code('TIMEOUT') when timeout is zero and there's no cached position for getCurrentLocation.
Attachment #8710817 - Flags: review?(kchen)
Attachment #8710817 - Flags: review?(josh)
For watchPosition, there is no definition in W3C spec. In my opinion, we can keep the current behavior.
Comment on attachment 8710817 [details] [diff] [review] (0122) Add a handling for getCurrentLocation when timeout is zero Review of attachment 8710817 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/geolocation/nsGeolocation.cpp @@ +512,5 @@ > Update(lastPosition.position); > } else { > + // if it is not a watch request and timeout is 0, > + // invoke the errorCallback (if present) with TIMEOUT code > + if ((mOptions && (mOptions->mTimeout == 0) > 0) && !mIsWatchPositionRequest) { I think this can be simplified to `if (mOptions && mOptions->Timeout == 0 && !mIsWatchPositionRequest) {`
Attachment #8710817 - Flags: review?(josh) → review+
Oh, and a test for this would be nice :)
Attachment #8710817 - Flags: review?(kchen)
The following is the try server result. It looks fine. https://treeherder.mozilla.org/#/jobs?repo=try&revision=3e53aae466d4
Attachment #8710817 - Attachment is obsolete: true
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Set owner to Alphan since he worked on and resolved this bug.
Assignee: nobody → alchen
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: