Failure to load when Geolocation is disabled in Firefox
yechs opened this issue · 0 comments
yechs commented
Observation
Gets stuck on "Computing ranking."
Console prints "navigator.geolocation is undefined"
Console output
Uncaught (in promise) TypeError: navigator.geolocation is undefined
geoCheck https://csrankings.org/csrankings.js:1397
CSRankings https://csrankings.org/csrankings.js:303
fulfilled https://csrankings.org/csrankings.js:11
promise callback*step https://csrankings.org/csrankings.js:13
fulfilled https://csrankings.org/csrankings.js:11
promise callback*step https://csrankings.org/csrankings.js:13
fulfilled https://csrankings.org/csrankings.js:11
promise callback*step https://csrankings.org/csrankings.js:13
fulfilled https://csrankings.org/csrankings.js:11
promise callback*step https://csrankings.org/csrankings.js:13
fulfilled https://csrankings.org/csrankings.js:11
promise callback*step https://csrankings.org/csrankings.js:13
__awaiter https://csrankings.org/csrankings.js:14
__awaiter https://csrankings.org/csrankings.js:10
CSRankings https://csrankings.org/csrankings.js:287
CSRankings https://csrankings.org/csrankings.js:340
<anonymous> https://csrankings.org/csrankings.js:1802
Similar to (but different causes): #718
Steps to Reproduce
- Go into
about:config
in Firefox - Set
geo.enabled
to false - Visit https://csrankings.org/
Speculated cause
In Firefox, when geo.enabled
is set to false, navigator.geolocation
returns null.
Although not specified in the MDN API Doc, this behavior is introduced in a commit in 2011.
Possible solution
Surround the following code block with a if "geolocation" in navigator
.
Or use optional chaining navigator.geolocation?.getCurrentPosition
Lines 1709 to 1726 in c7d9aeb