Skip to content

fix: skip generated config properties the installed Camoufox dropped - #339

Open
goodchang77 wants to merge 1 commit into
apify:masterfrom
goodchang77:fix/filter-unsupported-properties
Open

goodchang77 wants to merge 1 commit into
apify:masterfrom
goodchang77:fix/filter-unsupported-properties

Conversation

@goodchang77

Copy link
Copy Markdown

Problem

Against the current Camoufox release (v156.0.1-beta.34), launch() fails with Unknown property <key> in config because the library generates config keys the browser no longer declares in its bundled properties.json:

  • BrowserForge-mapped: navigator.product, navigator.appCodeName, navigator.appName, battery:charging/chargingTime/dischargingTime, screen.pageXOffset/pageYOffset
  • Hardcoded in launchOptions(): window.history.length, canvas:aaOffset, canvas:aaCapOffset

Same failure class as #307 (audio:seed), which was fixed by guarding against knownProperties — but the browserforge-derived config and the two hardcoded spots were left unguarded, so any newer browser that drops a mapped property breaks launch entirely.

Reproduction (macOS arm64, Camoufox v156.0.1-beta.34):

CamoufoxFetcher install → npx camoufox-js fetch   # installs v156.0.1-beta.34
launch() → Error: Unknown property navigator.product in config

Fix

Load the installed build's properties.json before assembling the config (it was already loaded later for the seed guards — just moved earlier) and:

  1. Filter the fromBrowserforge() output against the schema before merging — forward-compatible with any future property removal, not just the v156 set.
  2. Guard the hardcoded window.history.length behind knownProperties, same pattern as the seeds.
  3. Guard canvas:aaOffset/aaCapOffset the same way.

Caller-supplied config keys are intentionally not filtered — validateConfig() still throws on user typos/mistakes (pinned by a new test), so the filter only ever touches keys the library generated itself.

Tests

  • Added test/utils.test.ts > launchOptions dropped-property filtering (2 tests): a simulated newer browser whose properties.json lacks the v156-dropped keys — generated config omits them; an explicitly passed dropped key still throws.
  • On Camoufox v156.0.1-beta.34:
    • test/basics.test.ts: 12/15 failing → 11/15 passing (on master the browser cannot launch at all). The one remaining failure (locale option overrides Intl locale) is a separate v156 behavioral issue, untouched by this change.
    • test/utils.test.ts: all new tests pass. The three pre-existing seeding tests pin against the installed browser's schema and fail on v156 with or without this change (v156 also dropped fonts:spacing_seed/audio:seed/canvas:seed) — flagging as a separate issue rather than expanding scope here.
  • pnpm build (tsc) clean.

Camoufox v156 removed several config properties that the library still
generates: BrowserForge-mapped navigator.product/appCodeName/appName,
battery:*, screen.pageXOffset/pageYOffset, plus the hardcoded
window.history.length and canvas:aaOffset/aaCapOffset. launch() then fails
with 'Unknown property <key> in config' from validateConfig.

Load the installed build's properties.json before assembling the config and
filter the fingerprint-derived keys against it; guard the hardcoded
window.history.length and canvas anti-fingerprinting additions the same way.
Caller-supplied config keys are untouched, so validateConfig still catches
user typos (covered by a new test).

On Camoufox v156.0.1-beta.34: test/basics.test.ts goes from 12/15 failing
(browser cannot launch) to 11/15 passing; the remaining locale test failure
is a separate v156 behavioral issue. The three 'seeding' tests in
test/utils.test.ts pin against the installed browser's schema and fail on
v156 with or without this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants