Files
archived-camoufox/python/tests/test_webgl.py
T
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

331 lines
15 KiB
Python

"""WebGL identities drawn from fpgen's recorded Firefox devices (camoufox.webgl)."""
import json
from pathlib import Path
import pytest
from test_identity_salt import host, launch
from camoufox import coherence, utils
from camoufox import fingerprints as fp
from camoufox import webgl
from camoufox.fingerprints import gpu_screen_is_plausible, is_software_renderer
from camoufox.webgl import sample_webgl_for_screen, webgl_for_gpu
PROPERTIES = Path(__file__).resolve().parents[2] / "browser" / "settings" / "properties.json"
SEEDS = range(300)
OSES = ("win", "mac", "lin")
_GTX_980_LINUX = ("NVIDIA Corporation", "NVIDIA GeForce GTX 980, or similar")
_BASIC_RENDER_DRIVER = (
"Google Inc. (Microsoft)",
"ANGLE (Microsoft, Microsoft Basic Render Driver Direct3D11 vs_5_0 ps_5_0), or similar",
)
# Limits WebGL1 and WebGL2 read from the same device: MAX_TEXTURE_SIZE,
# MAX_VIEWPORT_DIMS, MAX_RENDERBUFFER_SIZE, MAX_CUBE_MAP_TEXTURE_SIZE,
# MAX_VERTEX_ATTRIBS, MAX_TEXTURE_IMAGE_UNITS, MAX_VERTEX_TEXTURE_IMAGE_UNITS,
# MAX_COMBINED_TEXTURE_IMAGE_UNITS and the three uniform/varying vector limits.
_SHARED_LIMITS = ("3379", "3386", "34024", "34076", "34921", "34930", "35660", "35661", "36347", "36348", "36349")
def _as_json(value):
# JSON has one number type: 2**64 stored as an int and as a float is the
# same value to the browser's parser.
return json.loads(json.dumps(value), parse_int=float)
def test_converter_reproduces_the_recorded_device():
"""The fixture is what the retired webgl_data.db gave launch_options for
this GPU. fpgen records the same device, so everything the browser reads
must come out identical: parameters are compared where the old row had a
value, less the UNMASKED_* strings, which the browser takes from
webGl:vendor/renderer rather than the table. Keys since marked removed
(contextAttributes) are no longer sent. WebGL1's line width range is
WebGL2's since Firefox 156 (test_webgl1_line_width_range_is_webgl2s),
Firefox 158 adds EXT_polygon_offset_clamp on this desktop GL device
(test_polygon_offset_clamp_follows_the_backend), and Firefox 159 adds
EXT_clip_control and EXT_texture_mirror_clamp_to_edge to both contexts
(test_clip_control_and_mirror_clamp_follow_the_backend) and
EXT_texture_norm16 to its WebGL2 (test_texture_norm16_follows_the_backend)."""
removed = {
entry["property"]
for entry in json.loads(PROPERTIES.read_text())
if "removed" in entry
}
old = json.loads((Path(__file__).parent / "data" / "webgl-gtx980-linux.json").read_text())
old = {key: value for key, value in old.items() if key not in removed}
old["webGl:parameters"]["33902"] = old["webGl2:parameters"]["33902"]
for key in ("webGl:supportedExtensions", "webGl2:supportedExtensions"):
old[key] = sorted(
[*old[key], "EXT_clip_control", "EXT_polygon_offset_clamp", "EXT_texture_mirror_clamp_to_edge"],
key=str.casefold,
)
old["webGl2:supportedExtensions"] = sorted(
[*old["webGl2:supportedExtensions"], "EXT_texture_norm16"], key=str.casefold
)
new = webgl_for_gpu("lin", *_GTX_980_LINUX, seed=0)
assert new.keys() == old.keys()
for key in old:
if key.endswith(":parameters"):
recorded = {
pname: value
for pname, value in old[key].items()
if value is not None and pname not in ("37445", "37446")
}
assert _as_json({pname: new[key].get(pname) for pname in recorded}) == _as_json(recorded), key
else:
assert new[key] == old[key], key
def test_same_seed_same_device():
for target_os in OSES:
for seed in (0, 1, 12345):
assert sample_webgl_for_screen(target_os, 1920, 1080, seed) == sample_webgl_for_screen(
target_os, 1920, 1080, seed
)
gpu = ("AMD", "Radeon R9 200 Series, or similar")
assert webgl_for_gpu("lin", *gpu, seed=7) == webgl_for_gpu("lin", *gpu, seed=7)
def test_seed_chooses_among_a_gpus_recorded_devices():
# fpgen records several Linux R9 200 devices; one seed must not pin them all.
drawn = {json.dumps(webgl_for_gpu("lin", "AMD", "Radeon R9 200 Series, or similar", seed=s)) for s in range(40)}
assert len(drawn) > 1
@pytest.mark.parametrize("target_os", OSES)
def test_synthetic_draw_is_a_hardware_gpu_the_os_reports(target_os):
renderers = {sample_webgl_for_screen(target_os, 1920, 1080, s)["webGl:renderer"] for s in SEEDS}
for renderer in renderers:
assert not is_software_renderer(renderer), renderer
assert renderer != "Mozilla"
assert coherence.gpu_fits_os(renderer, target_os), renderer
# A single GPU per OS is its own tell.
assert len(renderers) >= 2
@pytest.mark.parametrize("target_os", OSES)
def test_netbook_screen_never_draws_a_discrete_gpu(target_os):
for seed in SEEDS:
renderer = sample_webgl_for_screen(target_os, 1024, 600, seed)["webGl:renderer"]
assert gpu_screen_is_plausible(renderer, 1024, 600), renderer
def test_no_coherent_gpu_raises(monkeypatch):
# A pool with nothing that fits is a data defect; substituting a GPU the
# filters rejected would present exactly what they exist to prevent.
only_software = tuple(r for r in webgl._trace("gpu", "lin") if is_software_renderer(r.value["renderer"]))
assert only_software
monkeypatch.setattr(webgl, "_trace", lambda *a, **kw: only_software)
with pytest.raises(ValueError, match="No recorded lin GPU"):
sample_webgl_for_screen("lin", 1920, 1080, seed=0)
@pytest.mark.parametrize("target_os", OSES)
def test_webgl2_comes_from_the_same_device_as_webgl1(target_os):
# webgl2 is pinned to the drawn webgl; drawn on the GPU alone, a Linux
# Intel identity paired MAX_TEXTURE_SIZE 8192 with 16384.
for seed in SEEDS:
config = sample_webgl_for_screen(target_os, 1920, 1080, seed)
for pname in _SHARED_LIMITS:
assert config["webGl:parameters"][pname] == config["webGl2:parameters"][pname], (seed, pname)
def test_gpu_is_pinned_by_vendor_and_renderer():
# "Mesa" and "AMD" both report this renderer on Linux. A dict condition on
# fpgen matches the renderer alone and mixed their devices.
for seed in range(40):
assert webgl_for_gpu("lin", "Mesa", "Radeon HD 3200 Graphics, or similar", seed)["webGl:vendor"] == "Mesa"
def test_device_without_webgl2():
config = webgl_for_gpu("win", *_BASIC_RENDER_DRIVER, seed=0)
assert config["webGl2Enabled"] is False
assert not any(key.startswith("webGl2:") for key in config)
with host():
options = utils.launch_options(
os="windows", webgl_config=_BASIC_RENDER_DRIVER, headless=True, i_know_what_im_doing=True
)
assert options["firefox_user_prefs"]["webgl.enable-webgl2"] is False
def test_unknown_webgl_config_raises():
with pytest.raises(ValueError, match="No recorded WebGL data"):
launch(os="windows", webgl_config=("Apple", "Apple M1, or similar"))
def test_preset_keeps_its_own_gpu():
preset = fp.load_presets("152")["presets"]["linux"][0]
gpu = (preset["webgl"]["unmaskedVendor"], preset["webgl"]["unmaskedRenderer"])
config = launch(os="linux", fingerprint_preset=preset)
assert (config["webGl:vendor"], config["webGl:renderer"]) == gpu
pinned = (webgl._pin("gpu", {"vendor": gpu[0], "renderer": gpu[1]}),)
recorded = [
webgl.to_config(w1.value, w2.value, "lin")["webGl:parameters"]
for w1 in webgl._trace("webgl", "lin", pinned)
for w2 in webgl._trace("webgl2", "lin", (*pinned, webgl._pin("webgl", w1.value)))
]
assert config["webGl:parameters"] in recorded
def test_preset_gpu_fpgen_has_never_seen_raises():
preset = fp.load_presets("152")["presets"]["windows"][0]
gpu = "ANGLE (Acme, Acme GPU 9000 Direct3D11 vs_5_0 ps_5_0)"
preset = {**preset, "webgl": {"unmaskedVendor": "Google Inc. (Acme)", "unmaskedRenderer": gpu}}
with pytest.raises(ValueError, match="Acme GPU 9000"):
launch(os="windows", fingerprint_preset=preset)
# -- extensions ---------------------------------------------------------------
def _extensions(target_os, key):
return [
set(sample_webgl_for_screen(target_os, 1920, 1080, s).get(key) or ()) for s in range(100)
]
def test_windows_keeps_ovr_multiview2_on_webgl2():
assert any("OVR_multiview2" in exts for exts in _extensions("win", "webGl2:supportedExtensions"))
def test_linux_filters_ovr_multiview2():
# fpgen records it on ~20% of Linux WebGL2 devices.
assert not any("OVR_multiview2" in exts for exts in _extensions("lin", "webGl2:supportedExtensions"))
def test_draft_extensions_filtered_on_every_os():
recorded = {
"vendor": "v",
"renderer": "r",
"contextAttributes": {},
"params": {"33902": {"value": [1, 1]}},
"shaderPrecisionFormats": [],
"supportedExtensions": ["ANGLE_instanced_arrays", "WEBGL_multi_draw", "WEBGL_compressed_texture_etc1"],
}
webgl2 = {**recorded, "supportedExtensions": ["EXT_texture_norm16", "WEBGL_clip_cull_distance", "OVR_multiview2"]}
for target_os in OSES:
config = webgl.to_config(recorded, webgl2, target_os)
# A device with WebGL2 is D3D11 feature level 10_0 or above, where ANGLE
# also clamps polygon offsets and has clip control; the recording
# carries no desktop GL mark.
backend = (
["EXT_clip_control", "EXT_depth_clamp", "EXT_polygon_offset_clamp", "EXT_texture_mirror_clamp_to_edge"]
if target_os == "win"
else []
)
assert config["webGl:supportedExtensions"] == ["ANGLE_instanced_arrays", *backend]
# The recorded EXT_texture_norm16 is dropped; Firefox 159 exposes it on
# every macOS and Linux WebGL2 context (test_texture_norm16_follows_the_backend).
webgl2_exts = backend + ["OVR_multiview2"] if target_os == "win" else ["EXT_texture_norm16"]
assert config["webGl2:supportedExtensions"] == webgl2_exts
def test_windows_exposes_ext_depth_clamp_on_every_device():
"""ANGLE's D3D11 backend reports depth clamp on every GPU from Firefox 156;
fpgen's Windows records come from Firefox 146, which did not."""
for key in ("webGl:supportedExtensions", "webGl2:supportedExtensions"):
assert all("EXT_depth_clamp" in exts for exts in _extensions("win", key) if exts), key
def test_polygon_offset_clamp_follows_the_backend():
"""Firefox 158 exposes EXT_polygon_offset_clamp on ANGLE's D3D11 backend
from feature level 10_0 (every device with WebGL2) and on Linux desktop GL
(the recordings with EXT_depth_clamp), never on macOS's GL 4.1; fpgen's
Firefox 146 records predate it."""
for target_os in OSES:
for s in range(100):
config = sample_webgl_for_screen(target_os, 1920, 1080, s)
desktop_gl = "EXT_depth_clamp" in config["webGl:supportedExtensions"]
want = {"win": config["webGl2Enabled"], "lin": desktop_gl, "mac": False}[target_os]
for key in ("webGl:supportedExtensions", "webGl2:supportedExtensions"):
if key in config:
assert ("EXT_polygon_offset_clamp" in config[key]) == want, (target_os, s, key)
def test_texture_norm16_follows_the_backend():
"""Firefox 159 exposes EXT_texture_norm16 on WebGL2 wherever the GL has
16-bit normalized textures (core in desktop GL 3.1): every macOS and Linux
device with WebGL2, never WebGL1. Measured on stock 159.0 on macOS (Apple
M1) and Linux (llvmpipe); 158.0.1 and fpgen's Firefox 146 records lack it."""
for target_os in OSES:
for s in range(100):
config = sample_webgl_for_screen(target_os, 1920, 1080, s)
assert "EXT_texture_norm16" not in config["webGl:supportedExtensions"], (target_os, s)
if config["webGl2Enabled"]:
want = target_os in ("mac", "lin")
assert ("EXT_texture_norm16" in config["webGl2:supportedExtensions"]) == want, (target_os, s)
def test_clip_control_and_mirror_clamp_follow_the_backend():
"""Firefox 159 adds EXT_clip_control (GL 4.5) and
EXT_texture_mirror_clamp_to_edge (GL 4.4) to WebGL1 and WebGL2. Linux
desktop GL (the recordings with EXT_depth_clamp) has both: measured on stock
159.0 on llvmpipe, x86_64 and aarch64, where 158.0.1 has neither. ANGLE's
D3D11 backend has mirror clamp on every device and clip control from
feature level 10_0 (every device with WebGL2). macOS's GL 4.1 has neither,
measured on stock 159.0 on Apple M1."""
for target_os in OSES:
for s in range(100):
config = sample_webgl_for_screen(target_os, 1920, 1080, s)
desktop_gl = "EXT_depth_clamp" in config["webGl:supportedExtensions"]
clip = {"win": config["webGl2Enabled"], "lin": desktop_gl, "mac": False}[target_os]
mirror = {"win": True, "lin": desktop_gl, "mac": False}[target_os]
for key in ("webGl:supportedExtensions", "webGl2:supportedExtensions"):
if key in config:
assert ("EXT_clip_control" in config[key]) == clip, (target_os, s, key)
assert ("EXT_texture_mirror_clamp_to_edge" in config[key]) == mirror, (target_os, s, key)
def test_extensions_are_in_firefoxs_order():
"""getSupportedExtensions lists in WebGLExtensionID order: alphabetical,
ignoring case. An extension the backend adds takes its place there."""
recorded = {
"vendor": "v",
"renderer": "r",
"params": {},
"shaderPrecisionFormats": [],
"supportedExtensions": ["ANGLE_instanced_arrays", "EXT_color_buffer_half_float", "EXT_disjoint_timer_query"],
}
assert webgl.to_config(recorded, [], "win")["webGl:supportedExtensions"] == [
"ANGLE_instanced_arrays",
"EXT_color_buffer_half_float",
"EXT_depth_clamp",
"EXT_disjoint_timer_query",
"EXT_texture_mirror_clamp_to_edge",
]
for target_os in OSES:
for s in range(100):
config = sample_webgl_for_screen(target_os, 1920, 1080, s)
for key in ("webGl:supportedExtensions", "webGl2:supportedExtensions"):
exts = config.get(key, [])
assert exts == sorted(exts, key=str.casefold), (target_os, s, key)
def test_a_uniform_block_is_at_most_what_firefox_allows():
"""Firefox 159 caps MAX_UNIFORM_BLOCK_SIZE at 64 KiB
(WebGL2ContextState.cpp, kMaxUniformBlockSize); fpgen recorded the drivers' own."""
def block_size(recorded):
record = {
"vendor": "v", "renderer": "r", "supportedExtensions": [], "shaderPrecisionFormats": [],
"params": {"33902": {"value": [1, 1]}, "35376": {"value": recorded}},
}
return webgl.to_config(record, record, "lin")["webGl2:parameters"]["35376"]
assert block_size(4120744960) == 65536
assert block_size(16384) == 16384
def test_webgl1_line_width_range_is_webgl2s():
"""Firefox 156 creates WebGL1 on the same GL profile as WebGL2. 146 forced
a compatibility profile for WebGL1, where fpgen recorded the driver's
wide-line range (Linux: [1, 2048], [1, 7.375], [1, 10] ...)."""
for target_os in OSES:
for s in range(100):
config = sample_webgl_for_screen(target_os, 1920, 1080, s)
if config["webGl2Enabled"]:
assert config["webGl:parameters"]["33902"] == config["webGl2:parameters"]["33902"], (target_os, s)