4 Commits
Author SHA1 Message Date
Jake WriterandClaude Opus 5.5 e90abccee6 Firefox 159: stock parity for a driven browser (#997)
* Firefox 159: stock parity for a driven browser

A page driven through Camoufox should read like stock Firefox in a
person's hands. This brings the Firefox 159 port up to that.

Stock defaults
- Remote Settings, Safe Browsing, region detection, Push, connectivity
  checks and the new tab keep Firefox's defaults; Nimbus is tied to
  Normandy so the new tab starts without it.
- No policies.json: any policy file puts Firefox in enterprise mode,
  which a page can see (DNS over HTTPS stands down).
- Firefox's 100% release rollouts are default prefs; stock's search
  engines are back.
- WebGL, devicePixelRatio and worker getters cost what stock's do; Linux
  builds use --enable-stdcxx-compat, as Mozilla's do.

Juggler
- Driver code defines no interfaces on the page's window, isolated and
  main-world evaluates included.
- Input arrives as a person's: click hold, hover dwell and double-click
  gap; fill() and insert_text() type key by key; the wheel turns notches;
  moves coalesce per frame; drags behave as a GTK drag session. Input
  waits for Firefox's user-input gate.
- Focus, Fission and bfcache stay Firefox's unless a driver needs them.
- Screenshots and document.fonts.ready leave the page alone.

Humanize
- One engine per channel (mouse, keyboard, scroll) behind one seam in
  Juggler, a seed for repeatable input, and custom(fn) engines run in the
  caller's process (Python). The build lists its engines in
  humanize-engines.json.

Network
- A SOCKS5 proxy with a username and password works for the launch and
  per context.
- The User-Agent header follows the context's identity.
- WebRTC UDP goes through a SOCKS5 proxy's UDP ASSOCIATE relay
  (webrtc-socks5-udp.patch), so a page's STUN server sees the exit and the
  srflx is real. Nothing goes around the proxy: a page with no HTTP-loaded
  document behind it counts as proxied, a proxy that carries no UDP gets
  none, and a relay address inside the proxy's own NAT is replaced by the
  proxy's public one.

Identity
- Bundled fonts and speech voices follow the drawn identity.
- The window holds the identity's size and position through startup, and
  on a virtual display a window outside the root is neither occluded nor
  refused focus.

CI runs every new guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BLGoGNeymhNcr3EAQX5hJE

* Paste inserted text; draw input delays from one normal helper

fill() and keyboard.insert_text() typed the text key by key, a quarter of a
second per character, which ran past Playwright's timeouts and is not how a
person enters a whole string. They now paste: the paste shortcut (Ctrl+V,
Cmd+V for a Mac platform) goes down, Firefox's own paste runs with the text
through nsIEditor.pasteTransferable (a trusted paste event with the text as
clipboardData, then beforeinput/input insertFromPaste), and the shortcut
comes up. The shortcut's keypress, where Firefox would read the system
clipboard, is cancelled in the system group, which content cannot observe;
the system clipboard is never used. A page that cancels the paste or the
shortcut gets nothing, and the call fails saying so.

input/HumanDelay.js holds normalDelay(mean, sd, min, max), the one draw for
the delays between a person's input events: the click hold (normal around
110 ms, SD 30, never under 50 ms, with no ceiling), the double-click gap,
the hover dwell, the paste key's hold, and the Shift and paste modifiers'
lead and trail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BLGoGNeymhNcr3EAQX5hJE

* Fix driven input and headless parity

* Headless with a display uses that display's GL

A headless probe that failed to load EGL still recorded TEST_TYPE EGL, so Firefox refused GLX and every headless WebGL context died. Probe EGL only when there is no display, and only claim it when that probe initialized. Move spacing starts when the move is sent, so a steps path stays a 125 Hz mouse instead of one move per frame.

* Fix focus, humanize-off, and WebRTC proxy parity

- A stock identity mirror adds no humanize keys when humanize is off.
- Keep the real focus and run the upstream focus tests.
- Add the per-context WebRTC proxy flag; do not fabricate a srflx behind a proxy.
- Refresh the Python/TypeScript parity tests, skiplist and docs.
- Install Mesa DRI so the software WebGL guards can run.

* Fix TypeScript humanize float encoding

Encode humanize option values as PyFloat so a duration serializes as 1.0, matching Python, and apply Biome's import formatting.

* Close a relay overflow, stop inventing srflx, and fix driven input gaps

WebRTC:
- A SOCKS5 relay read larger than the caller's buffer overran the stack
  buffer. A page-named STUN server could send one. Drop the datagram.
- Remove the fabricated srflx candidate; a srflx now only comes from a
  STUN answer, and the guards run against a server that answers.
- Juggler records each proxy it sets, so a caller's own
  new_context(proxy=...) cannot gather around it. This replaces the
  launcher's webrtc:proxied key and its page-visible setter.
- Headless GL probes use the surfaceless platform without launcher plumbing.

Input:
- A wheel without a scroll engine takes the activation slot per notch, so
  a long scroll no longer stalls input in every other context.
- Paste and fill work inside an iframe.
- Python fill honours the caller's timeout.

TypeScript humanize matches Python: off, seeds, duplicate options and the
scroll warning.

Guards with a missing prerequisite fail rather than pass. Add
navigation-preconnect-proxied. Move the tweened click test to a skiplist
pattern entry, since whether it passes depends on machine speed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Check the tweened click entry with its guard, not the audit

Whether test_click_with_tweened_mouse_movement passes depends on machine
speed: 0 of 20 runs on all cores here, 3 of 15 on two, and it passed on CI.
The audit cannot demand a failure from it, and a pattern entry would leave
its reason unchecked. A skiplist entry's checked_by now names the patch
guard that checks the reason, here driven-move-coalescing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Ask the display-less GL probe for a pbuffer config

Mesa's surfaceless platform has only pbuffer configs. The probe asked for
the default window surface type, so eglChooseConfig matched nothing and
eglCreateContext got an uninitialized config. With no GPU, a display-less
headless launch then had an empty gfxInfo: no WebGL and no WebRTC H264.

A host where NVIDIA's EGL answers first never reaches Mesa here, so the
guards only failed on machines without a GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Open about:blank for a driver and run first-page init scripts after PageAgent

A headed persistent launch opened about:home once the start page prefs went
back to stock. browser.startup.page now becomes 0 only when a driver attaches,
so a browser nobody drives keeps Firefox's start page.

Init scripts on a page's initial document ran before PageAgent existed, so
their binding calls and console messages had no listener and were lost. They
now run after PageAgent has reported the page's execution contexts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Warm up the crash growth test past Firefox 159's timed startup work

The parent holds up to 400 MB more for a while at fixed times after launch, in
stock Firefox 159 as well. Two RSS readings taken across one of those peaks
read as growth or shrinkage, and pushed the test over its limit with no leak.
Warm up by time instead of by context count. The metric and limit are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Close WebRTC paths around a proxy, stop background traffic, fix driven input

WebRTC behind a proxy no longer shows the host's address: ICE uses the proxy's
SOCKS5 UDP relay when it has one, and UDP is dropped otherwise. A page on the
bypass list behind a forced proxy is blocked on UDP and ICE TCP. A proxy hanging
up straight after CONNECT no longer crashes the parent process.

Remote Settings stops polling, with the page-visible lists bundled as a snapshot
pinned by scripts/remote_settings.py, and Push connects on demand.

fill clicks an unfocused text field and types when a page blocks paste. Click
throughput across contexts is restored. The TypeScript launcher gains custom
humanize engines and driver defaults, in step with Python, and caps WebGL2
MAX_UNIFORM_BLOCK_SIZE at Firefox 159's 64 KiB.

docs/input-dispatch.md records a person's wheel on macOS, which is one line a
notch where the driven wheel sends three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Leave the humanize engine system for its own pull request

Per-channel engines, seeded streams, custom() and the keyboard and
scroll-into-view plans are a separate feature. humanize keeps main's meaning
here: a human cursor move, on or off, with an optional duration cap, planned by
CursorTrajectory.js and paced by Pacer.js. The five per-channel config keys were
declared on this branch, so they stay declared as removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Warn, not raise, on a browser that cannot read voices:speechd

A new package has to launch an older build (#835, and the install gate launches
the last release). A Linux identity there reports no voices, so it warns and the
warning cannot be silenced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Give a macOS identity macOS's wheel

A person's notched mouse on macOS sends one line for a slow notch, with no native
tick, and accelerates a faster turn from there. Driven input sent Linux's three
ticked lines. A macOS identity now sends lines at 16 px each, starting at one and
growing, and stock's per-OS system scroll override follows the identity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Install the tracking lists where a clean build's reader looks

A relative wildcard keeps its directory under recursive make and drops it under
faster make. The clean build nested the attachments one directory too deep, so
the classifier had no tables. An incremental objdir hid this with old links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Make two guards deterministic: the wheel's OS and a dropped relay

A launch without `os` draws one, and a macOS draw now gets macOS's wheel, so the
guards asserting three notches failed by the draw. They assert Linux's now.

The browser flushes queued datagrams when UDP ASSOCIATE is granted, so a relay
closed just after the grant could forward one, and the STUN server heard the
proxy's own relay port as if it had gone around the proxy. It closes first now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-07 17:51:40 +00:00
Jake WriterandClaude Opus 5.5 0bb4f14b74 Keep the caller's launch inputs unchanged, and claim the avail screen and touch points baseline protection reports
launch_options/launchOptions filled the caller's config, prefs, args and
addons in place. A config reused for a second launch then carried the first
identity's webGl:vendor in, which read as a GPU the caller named: the second
launch covered its canvas while claiming the host's GPU. The TypeScript
end-to-end test caught it through its Python probe, which calls
launch_options before Camoufox with the same kwargs. Both launchers now work
on copies.

Firefox's baseline fingerprinting protection reports the available screen as
the screen less a fixed taskbar for the claimed OS (48px Windows, 76px macOS,
none on Linux) and collapses more than one touch point to 5, and the browser
applies that to the spoofed values. The launchers still claimed fpgen's
recorded avail rect, adjusted by fix_screen_no_taskbar, so a Linux identity's
config said availHeight 1053 while the page read 1080. follow_baseline_protection
/ followBaselineProtection replaces it and claims what the browser reports.

The end-to-end test now compares a covered canvas by being covered (its
readback is random on every read, so its size was too), launches the
NewContext scenario with canvas_noise, since an uncovered browser binds its
contexts to the host, and checks a headful launch against its own config,
because Xvfb can render on another device than headless.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:39:02 -06:00
Jake WriterandClaude Opus 5.5 5c1fd578ad Read a build's version from its own bundle, refuse browser= with a binary, and cover the canvas whenever the GPU is not the host's
- A named executable's application.ini is found beside it, or in
  Contents/Resources of a macOS app bundle (pkgman.build_file / buildFile),
  and a named executable without one raises instead of borrowing the paired
  build's version. browser= on macOS no longer raises CamoufoxNotInstalled
  or claims the wrong Firefox major.
- browser= together with executable_path or CAMOUFOX_EXECUTABLE_PATH raises
  ValueError instead of silently dropping browser=.
- One function per launcher (plan_rendering / planRendering) decides whether
  the identity claims the host's GPU or the canvas is covered, for the launch
  and for the host identity its contexts keep. A GPU named by webgl_config or
  a preset, or a host GPU fpgen never recorded, now covers the canvas by
  default, and such a browser binds no context to the host.
- setWebgpu keeps a caller pref set to null, as Python's setdefault does.
- stock-gpu-parity verifies SHA256SUMS.asc against Mozilla's release key and
  uses camoufox.webgl.recorded_devices instead of private helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 13:38:46 -06:00
Jake Writer 658806eb23 chore: major code cleanup/refactor 2026-10-06 19:10:22 -06:00