browserslist / browserslist-useragent

🦔A utility to match a browserslist query with user agent strings
MIT License
300 stars 30 forks source link

Why is Gecko version used for the Firefox user agent? #80

Open rdsedmundo opened 1 year ago

rdsedmundo commented 1 year ago

https://github.com/browserslist/browserslist-useragent/blob/b767e4d53dc712715ca9fe2d0e440b755da652c2/index.ts#L84-L90

I'm using Firefox 118.0.1 with user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/118.0.

My browserslist query is as follows:

">0.3%",
"not dead",
"not op_mini all",
"not ie 11"

Which returns, as of now, the following browsers:

'and_chr 115',       'and_uc 15.5',
'chrome 115',        'chrome 114',
'chrome 113',        'chrome 109',
'edge 115',          'edge 114',
'firefox 115',       'firefox 114',
'ios_saf 16.5',      'ios_saf 16.4',
'ios_saf 16.3',      'ios_saf 16.2',
'ios_saf 16.1',      'ios_saf 16.0',
'ios_saf 15.6-15.7', 'ios_saf 14.5-14.8',
'opera 100',         'opera 99',
'safari 16.5',       'safari 16.3',
'safari 15.6',       'samsung 21'

The browserslist-useragent package thinks my Firefox is 109.0 (the Gecko version) instead of 118.0 (I have allowHigherVersions set), so it detects my browser as not supported. This doesn't seem right.

rdsedmundo commented 1 year ago

Probably related: https://bugzilla.mozilla.org/show_bug.cgi?id=1805967 https://github.com/webcompat/web-bugs/issues/115507

tunailgaz commented 1 year ago

ye I was also confused then saw this issue, I guess we need something like that until it resolves for my case Fireforx 115 117 and >118 is fine ua-parser-js's getBrowser() functions gives the right firefox version at the moment.

import Parser from 'ua-parser-js'

const ua_browser = ua.getBrowser()
const hacky_solution = ua_browser.name ===  'Firefox' &&
  (Number(ua_browser.version) === 115 || Number(ua_browser.version) === 117 || Number(ua_browser.version) >= 118)
reckter commented 1 year ago

This just came up for us, because the newest firefox version 118, will be detected as 109, which is no longer included in the defaults browserslist configuration. (looking at the output of browserslist default I am not sure, why this didn't come up earlier for us, but ¯_(ツ)_/¯