Closed Bug 681941 Opened 11 years ago Closed 11 years ago
update() method of ns
IGeolocation Update cannot be used with multiple tabs
the update() method of nsIGeolocationUpdate can be used to pass a location (coords) to every "geolocation listener" (watchPosition or getCurrentPosition). I'm trying to use it from an addon to be able to generate arbitrary locations. When the addon is active in multiple tabs, only the first tab is able to detect location updates. Worse: when the first tab is reloaded, it doesn't receive updates anymore. I have to reinstall the addon or restart firefox. Test case: 1. Open http://fiddle.jshell.net/louisremi/DXTmH/1/show/ to track your current location with watchPosition 2. set pref "devtools.chrome.enabled" to true (once for all) 3. Open scratchpad and switch "environment" to "browser" 3. paste the content of the attached file in it 4. Modify your location on line 66-68 5. Run the code 6. See your position updated in the test page 7. Repeat steps 4 to 6 at will 8. Open the test page in a new tab 9. Modify your location & run the code 10. See your position not being updated in the current tab 11. Switch to the first tab and see your position updated 12. Reload the first tab 13. Modify your location & run the code 14. See your position not being updated anymore
Thanks, this testcase was great. Patch coming up; look like we messed up the logic of when to cancel requests a bit.
Now without extra cruft.
Attachment #555807 - Flags: review?(doug.turner)
Hi Josh, I helped Louis-rémi building his addon around geolocation. I was wondering if there is any way to fix this issue by using geolocation xpcom component in a alternative way so that all tabs gets update correctly? (In order to get something working on current Firefox releases, before this fix finally end up in a release)
I can think of a couple ways - use getLocation and setInterval, but the logic error being fixed here is weird enough that this may not be foolproof. Alternatively, you could try getting the geolocation information from a chrome listener, then load a content script which has a message listener which listens for messages your addon sends whenever a geolocation update occurs. That's assuming that it's possible to add geolocation listeners from non-content pages.
Thank you for being so quick at fixing this bug Josh. I hope it gets reviewed and commited soon so I can move on with my own work.
Comment on attachment 555807 [details] [diff] [review] Ensure that we always clear geolocation requests that are not long-lived, and never clear ones that are. The white space looks kinda off in one place.
Attachment #555807 - Flags: review?(doug.turner) → review+
Wow that was really quick too! Thank you Doug.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
You need to log in before you can comment on or make changes to this bug.