Last Comment Bug 688158 - geo.enable => false should make navigator.geolocation undefined
: geo.enable => false should make navigator.geolocation undefined
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Geolocation (show other bugs)
: 8 Branch
: All All
: -- normal (vote)
: mozilla10
Assigned To: Josh Matthews [:jdm] (away until 9/3)
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-09-21 07:50 PDT by Paul Irish
Modified: 2011-09-30 07:37 PDT (History)
3 users (show)
josh: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Make navigator.geolocation if geolocation is disabled. (915 bytes, patch)
2011-09-21 08:12 PDT, Josh Matthews [:jdm] (away until 9/3)
jst: review+
doug.turner: feedback+
Details | Diff | Splinter Review

Description Paul Irish 2011-09-21 07:50:30 PDT
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.4 (KHTML, like Gecko) Chrome/16.0.887.0 Safari/535.4

Steps to reproduce:

- about:config
- set geo.enable to false
- try:

navigator.geolocation && navigator.geolocation.getCurrentPosition(
  function(){ console.log('success', arguments); },
  function(){ console.log('error', arguments);    }
);


Actual results:

getCurrentPosition threw an exception: 
[11:44:41.359] [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMGeoGeolocation.getCurrentPosition]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: Web Console :: <TOP_LEVEL> :: line 1"  data: no]


Expected results:

Ideally navigator.geolocation is undefined, so feature detection is accurate. Pages relying on detecting navigator.geolocation exists are changing behavior expecting it to succeed (or at least, prompt the user).

Next best thing is the error callback is executed.
Comment 1 Josh Matthews [:jdm] (away until 9/3) 2011-09-21 08:01:28 PDT
Agreed, this DOM call shouldn't throw.
Comment 2 Josh Matthews [:jdm] (away until 9/3) 2011-09-21 08:12:02 PDT
Created attachment 561469 [details] [diff] [review]
Make navigator.geolocation if geolocation is disabled.
Comment 3 Josh Matthews [:jdm] (away until 9/3) 2011-09-21 08:13:06 PDT
Comment on attachment 561469 [details] [diff] [review]
Make navigator.geolocation if geolocation is disabled.

Doug, is navigator.geolocation returning null a decent behaviour here?
Comment 4 Doug Turner (:dougt) 2011-09-29 07:47:36 PDT
Comment on attachment 561469 [details] [diff] [review]
Make navigator.geolocation if geolocation is disabled.

this is okay... but I still think people will be able to test for interface Geolocation, and NavigatorGeolocation.
Comment 5 Josh Matthews [:jdm] (away until 9/3) 2011-09-30 00:10:18 PDT
http://hg.mozilla.org/integration/mozilla-inbound/rev/8232007db7e5

Note You need to log in before you can comment on or make changes to this bug.