Skip to content

Commit

Permalink
Drop old browsers support (#186)
Browse files Browse the repository at this point in the history
* Test in Samsung Internet
  • Loading branch information
Finesse authored Oct 18, 2024
1 parent c5404ec commit c8ecbc5
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 36 deletions.
8 changes: 4 additions & 4 deletions docs/browser_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ We aim to cover at least 99% of all users according to the Fingerprint Pro stati
At the moment, these browsers are:

- **Edge** 105+
- **Chrome** 65+
- **Firefox** 75+
- **Desktop Safari** 12.1+
- **Mobile Safari** 12.0+
- **Chrome** 73+
- **Firefox** 89+
- **Desktop Safari** 13.0+
- **Mobile Safari** 13.0+
- **Samsung Internet** 14.0+

Other browsers will probably also work, but we don't guarantee it.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"check:ssr": "node --require ./dist/botd.cjs.js --eval '' || (echo \"The distributive files can't be used with server side rendering. Make sure the code doesn't use browser API until an exported function is called.\" && exit 1)"
},
"devDependencies": {
"@fpjs-incubator/broyster": "^0.2.1",
"@fpjs-incubator/broyster": "^0.2.3",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^10.0.1",
Expand Down
4 changes: 3 additions & 1 deletion src/sources/app_version.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
getBrowserEngineVersion,
getBrowserVersion,
getOsMajorVersion,
isChromium,
Expand All @@ -13,15 +14,16 @@ describe('Sources', () => {
describe('appVersion', () => {
it('returns an expected value', () => {
const value = getAppVersion()
const version = getBrowserVersion() ?? { major: 0, minor: 0 }

if (isWebKit()) {
const version = getBrowserVersion() ?? { major: 0, minor: 0 }
expect(navigator.userAgent).toContain(value)
expect(value).toContain(`Version/${version.major}.${version.minor}`)
return
}

if (isChromium()) {
const version = getBrowserEngineVersion() ?? { major: 0, minor: 0 }
expect(navigator.userAgent).toContain(value)
expect(value).toContain(`Chrome/${version.major}.${version.minor}`)
return
Expand Down
9 changes: 0 additions & 9 deletions src/sources/document_element_keys.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { getBrowserMajorVersion, isChromium } from '../../tests/utils'
import { BotdError } from '../types'
import getDocumentElementKeys from './document_element_keys'

describe('Sources', () => {
describe('documentElementKeys', () => {
it('returns expected values or throws', () => {
if (isChromium() && (getBrowserMajorVersion() ?? 0) < 61) {
expect(() => getDocumentElementKeys()).toThrow(
new BotdError(-2, 'document.documentElement.getAttributeNames is not a function'),
)
return
}

const result = getDocumentElementKeys()
// There are no document keys when running the tests using Karma
expect(result).toEqual([])
Expand Down
4 changes: 2 additions & 2 deletions src/sources/error_trace.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getBrowserMajorVersion, isChromium } from '../../tests/utils'
import { getBrowserEngineMajorVersion, isChromium } from '../../tests/utils'
import getErrorTrace from './error_trace'

describe('Sources', () => {
Expand All @@ -8,7 +8,7 @@ describe('Sources', () => {

if (isChromium()) {
expect(result).toContain(
(getBrowserMajorVersion() ?? 0) < 93
(getBrowserEngineMajorVersion() ?? 0) < 93
? "TypeError: Cannot read property '0' of null"
: "TypeError: Cannot read properties of null (reading '0')",
)
Expand Down
4 changes: 2 additions & 2 deletions src/sources/rtt.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getBrowserMajorVersion, isChromium, isGecko, isWebKit } from '../../tests/utils'
import { isGecko, isWebKit } from '../../tests/utils'
import { BotdError } from '../types'
import getRTT from './rtt'

describe('Sources', () => {
describe('rtt', () => {
it('returns an expected value or throws', () => {
if (isGecko() || isWebKit() || (isChromium() && (getBrowserMajorVersion() ?? 0) < 61)) {
if (isGecko() || isWebKit()) {
expect(() => getRTT()).toThrow(new BotdError(-1, 'navigator.connection is undefined'))
return
}
Expand Down
9 changes: 3 additions & 6 deletions src/sources/user_agent.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { getBrowserVersion } from '../../tests/utils'
import { getBrowserEngineVersion } from '../../tests/utils'
import getUserAgent from './user_agent'

describe('Sources', () => {
describe('userAgent', () => {
it('returns an expected value', () => {
const value = getUserAgent()
const version = getBrowserVersion() ?? { major: 0, minor: 0 }

// We do not want to call ua-parser-js in these tests, as those likely
// use navigator.userAgent internally.
expect(value).toMatch(new RegExp(`(Version|Chrome|Firefox)/${version.major}.${version.minor}`))
const version = getBrowserEngineVersion() ?? { major: 0, minor: 0 }
expect(value).toMatch(new RegExp(`(AppleWebKit|Chrome|Firefox)/${version.major}.${version.minor}`))
})
})
})
8 changes: 1 addition & 7 deletions src/sources/webdriver.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { getBrowserMajorVersion, isChromium, isHeadlessChrome } from '../../tests/utils'
import { isHeadlessChrome } from '../../tests/utils'
import getWebDriver from './webdriver'
import { BotdError } from '../types'

describe('Sources', () => {
describe('webdriver', () => {
it('returns an expected value or throws', () => {
if (isChromium() && (getBrowserMajorVersion() ?? 0) < 63) {
expect(() => getWebDriver()).toThrow(new BotdError(-1, 'navigator.webdriver is undefined'))
return
}

const result = getWebDriver()

if (isHeadlessChrome()) {
Expand Down
20 changes: 20 additions & 0 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ export function getBrowserMajorVersion(): number | undefined {
return parseInt(version.split('.')[0])
}

export function getBrowserEngineMajorVersion(): number | undefined {
const version = new UAParser().getEngine().version
if (version === undefined) {
return undefined
}
return parseInt(version.split('.')[0])
}

export function getBrowserVersion(): { major: number; minor: number } | undefined {
const version = new UAParser().getBrowser().version
if (version === undefined) {
Expand All @@ -61,3 +69,15 @@ export function getBrowserVersion(): { major: number; minor: number } | undefine
minor: parseInt(version.split('.')[1]),
}
}

export function getBrowserEngineVersion(): { major: number; minor: number } | undefined {
const version = new UAParser().getEngine().version
if (version === undefined) {
return undefined
}

return {
major: parseInt(version.split('.')[0]),
minor: parseInt(version.split('.')[1]),
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@fpjs-incubator/broyster@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@fpjs-incubator/broyster/-/broyster-0.2.1.tgz#05fb1052da23e53aebedd9f62b4ecab61e27ff4c"
integrity sha512-GmE8/6wrACogDszd8Z5y52z/rGRPvhKvYTmuVFmmIe7udSELpRC+F1qliBD4Oa/lJUY4GKqiDKOSjc91hxLntA==
"@fpjs-incubator/broyster@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@fpjs-incubator/broyster/-/broyster-0.2.3.tgz#04b94db87080f2de1ec87edee31f4a22cb69c2c4"
integrity sha512-q/zi2hYHMqUf4kzp0HkMgvoIvD8s3jLw3XB+FW0bV2vOyQvI7oMMcUao9T39RBQOnBpaWXd3TxlDLnyP0EGjQg==
dependencies:
"@types/karma" "^6.3.3"
async-lock "^1.4.0"
Expand Down

0 comments on commit c8ecbc5

Please sign in to comment.