mirror of
https://github.com/daijro/camoufox.git
synced 2026-11-19 00:07:28 +00:00
- 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>
60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""
|
|
launch_options() resolves the browser it will launch before reading its version.
|
|
|
|
It used to read the version of the active install first and resolve the binary
|
|
last. With nothing installed that raised CamoufoxNotInstalled ("run `camoufox
|
|
fetch`") before the download in camoufox_path() was ever reached (#835), while
|
|
the TypeScript launcher downloaded. With an outdated install it generated the
|
|
identity for the old Firefox version and then launched the upgraded one.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from camoufox import utils
|
|
from camoufox.exceptions import CamoufoxNotInstalled
|
|
|
|
|
|
@pytest.fixture
|
|
def nothing_installed(monkeypatch, tmp_path):
|
|
"""No active install; launch_path() is where the download happens."""
|
|
binary = tmp_path / "camoufox-bin"
|
|
downloads = []
|
|
|
|
def installed_verstr():
|
|
if not downloads:
|
|
raise CamoufoxNotInstalled("Official is not installed. Please run `camoufox fetch` to install.")
|
|
return "157.0-beta.34"
|
|
|
|
def launch_path(*_args, **_kwargs):
|
|
downloads.append(True)
|
|
return str(binary)
|
|
|
|
seen = {}
|
|
|
|
def from_fpgen(_fingerprint, ff_version, *_args, **_kwargs):
|
|
seen["ff_version"] = ff_version
|
|
return {}
|
|
|
|
monkeypatch.setattr(utils, "installed_verstr", installed_verstr)
|
|
monkeypatch.setattr(utils, "launch_path", launch_path)
|
|
monkeypatch.setattr(utils, "generate_fingerprint", lambda *args, **kwargs: object())
|
|
monkeypatch.setattr(utils, "from_fpgen", from_fpgen)
|
|
for name in ("add_default_addons", "get_screen_cons", "fix_navigator_arch",
|
|
"fix_screen_no_taskbar", "clamp_window_dimensions",
|
|
"set_media_devices_defaults", "validate_config"):
|
|
monkeypatch.setattr(utils, name, lambda *args, **kwargs: None)
|
|
monkeypatch.setattr(utils, "_generate_random_font_subset", lambda *args, **kwargs: [])
|
|
monkeypatch.setattr(utils, "_generate_random_voice_subset", lambda *args, **kwargs: [])
|
|
monkeypatch.setattr(utils, "get_env_vars", lambda *args, **kwargs: {})
|
|
return downloads, seen, str(binary)
|
|
|
|
|
|
def test_a_first_launch_installs_instead_of_raising(nothing_installed):
|
|
downloads, seen, binary = nothing_installed
|
|
|
|
options = utils.launch_options(headless=True, i_know_what_im_doing=True)
|
|
|
|
assert downloads
|
|
assert options["executable_path"] == binary
|
|
assert seen["ff_version"] == "157"
|