camoucore 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/camoufox/__version__.d.ts +1 -1
- package/dist/camoufox/__version__.js +1 -1
- package/dist/camoufox/data-files/essential-fonts.json +1 -1
- package/dist/camoufox/data-files/font-bases.json +0 -1
- package/dist/camoufox/data-files/fonts.json +1 -1
- package/dist/camoufox/data-files/launcher-constants.json +1 -71
- package/dist/camoufox/data-files/media-devices.json +4 -36
- package/dist/camoufox/data-files/warnings.yml +0 -14
- package/dist/camoufox/display_profile.d.ts +8 -12
- package/dist/camoufox/display_profile.js +17 -74
- package/dist/camoufox/driver_defaults.d.ts +1 -3
- package/dist/camoufox/driver_defaults.js +5 -10
- package/dist/camoufox/exceptions.d.ts +10 -0
- package/dist/camoufox/exceptions.js +13 -0
- package/dist/camoufox/fingerprints.d.ts +2 -95
- package/dist/camoufox/fingerprints.js +10 -264
- package/dist/camoufox/multiversion.js +7 -8
- package/dist/camoufox/paths.js +0 -3
- package/dist/camoufox/pkgman.d.ts +1 -31
- package/dist/camoufox/pkgman.js +2 -96
- package/dist/camoufox/sync_api.js +3 -16
- package/dist/camoufox/utils.d.ts +20 -143
- package/dist/camoufox/utils.js +42 -554
- package/dist/camouwolf/__version__.d.ts +1 -1
- package/dist/camouwolf/__version__.js +1 -1
- package/package.json +1 -1
- package/dist/camoufox/data-files/audio-output-latency.json +0 -15
- package/dist/camoufox/data-files/display-profiles.json +0 -6
- package/dist/camoufox/data-files/font-prefs.json +0 -1046
package/dist/camoufox/utils.js
CHANGED
|
@@ -20,17 +20,17 @@ import { VirtualDisplay } from "../virtdisplay.js";
|
|
|
20
20
|
import { addDefaultAddons, confirmPaths } from "./addons.js";
|
|
21
21
|
import * as coherence from "./coherence.js";
|
|
22
22
|
import { applyDisplayProfile, } from "./display_profile.js";
|
|
23
|
-
import { InvalidOS, InvalidPropertyType, NonFirefoxFingerprint, UnknownIPLocation, } from "./exceptions.js";
|
|
24
|
-
import {
|
|
23
|
+
import { InvalidOS, InvalidPropertyType, NonFirefoxFingerprint, UnknownIPLocation, UnknownProperty, } from "./exceptions.js";
|
|
24
|
+
import { clampScreenToDisplay, clampWindowDimensions, clampWindowPosition, drawVoiceConfig, dropAudioSeed, fixHardwareConcurrency, fixNavigatorArch, followBaselineProtection, fromFpgen, fromPreset, generateFingerprint, generateRandomFontSubset, generateRandomVoiceSubset, getRandomPreset, identitySalt, identitySeed, loadOsFonts, raiseScreenToModernFloor, Screen, setCpuDefault, setMediaDevicesDefaults, targetOsFromPlatform, WINDOWS_11_MARKER_FONTS, } from "./fingerprints.js";
|
|
25
25
|
import { GPU_PREFS, GpuDisplay, proveGpu, selectGpu } from "./gpudisplay.js";
|
|
26
26
|
import { addCanvasPlaceholder, hasCanvasPlaceholder, hostGpu, setWebgpu, } from "./host_rendering.js";
|
|
27
27
|
import { normalize } from "./humanize.js";
|
|
28
28
|
import { proxyAuthEnv, proxyAuthInitScript, publicIPv6, socks5Auth, } from "./ip.js";
|
|
29
|
-
import { INSTALL_DIR, LAUNCHER_CONSTANTS,
|
|
29
|
+
import { INSTALL_DIR, LAUNCHER_CONSTANTS, OS_NAME } from "./paths.js";
|
|
30
30
|
import { buildFile, effectiveVersionMin, ensureBrowserProfileDir, ensureCamoufoxInstalled, getPath, installedVerStr, launchPath, resolvedPlaywrightVersionStr, selectedLaunchPath, Version, warnIfPackageOutdated, } from "./pkgman.js";
|
|
31
31
|
import { PRODUCT } from "./product.js";
|
|
32
32
|
import { comparePyStr, formatPyFloatRepr, isPlainObject, isPyError, orjsonDumps, PyFloat, pyRepr, pyStr, pyTruthy, pyTypeName, ValueError, } from "./pycompat.js";
|
|
33
|
-
import { FallbackWarning, LeakWarning, loadWarnings, warn,
|
|
33
|
+
import { FallbackWarning, LeakWarning, loadWarnings, warn, } from "./warnings.js";
|
|
34
34
|
import { firefoxGpus, sampleWebglForScreen, webglForGpu } from "./webgl.js";
|
|
35
35
|
/** The value a persistent profile's prefs.js holds for `pref` (undefined when none). Mirrors Python's saved_pref. */
|
|
36
36
|
export function savedPref(profileDir, pref) {
|
|
@@ -88,9 +88,6 @@ function hasSystemAvcodec() {
|
|
|
88
88
|
}
|
|
89
89
|
return true; // cannot tell: do not warn
|
|
90
90
|
}
|
|
91
|
-
// System colours stock Firefox reports on Windows 10/11 in the light theme,
|
|
92
|
-
// where they differ from a Linux host's GTK theme.
|
|
93
|
-
export const WINDOWS_UI_COLORS = LAUNCHER_CONSTANTS.windowsUiColors;
|
|
94
91
|
// Prefs whose Firefox default differs between the Windows and Linux builds and
|
|
95
92
|
// that a page or the user can observe, at the Windows default (see
|
|
96
93
|
// WINDOWS_BEHAVIOUR_PREFS in the Python launcher for each one's reason).
|
|
@@ -171,27 +168,6 @@ function stockProfileDiskCapacityKb() {
|
|
|
171
168
|
}
|
|
172
169
|
return null;
|
|
173
170
|
}
|
|
174
|
-
/**
|
|
175
|
-
* The font.* prefs that make a build for `buildOs` resolve fonts the way stock
|
|
176
|
-
* Firefox does on `targetOs` (font-prefs.json, from all.js by
|
|
177
|
-
* browser/scripts/gen-font-prefs.py): the target's values where they differ,
|
|
178
|
-
* and an empty list for name-lists only the build's platform sets.
|
|
179
|
-
*/
|
|
180
|
-
function stockFontPrefs(targetOs, buildOs = "lin") {
|
|
181
|
-
const table = loadDataFile("font-prefs.json");
|
|
182
|
-
const target = table[OS_NAMES[targetOs]];
|
|
183
|
-
const build = table[OS_NAMES[buildOs]];
|
|
184
|
-
const prefs = {};
|
|
185
|
-
for (const [k, v] of Object.entries(target)) {
|
|
186
|
-
if (build[k] !== v)
|
|
187
|
-
prefs[k] = v;
|
|
188
|
-
}
|
|
189
|
-
for (const [k, v] of Object.entries(build)) {
|
|
190
|
-
if (!(k in target) && typeof v === "string")
|
|
191
|
-
prefs[k] = "";
|
|
192
|
-
}
|
|
193
|
-
return prefs;
|
|
194
|
-
}
|
|
195
171
|
/**
|
|
196
172
|
* Injection points: everything launchOptions() reaches outside this module.
|
|
197
173
|
* Mirrors the names the Python tests monkeypatch on camoufox.utils.
|
|
@@ -510,15 +486,30 @@ function loadProperties(executablePath) {
|
|
|
510
486
|
out[prop.property] = prop;
|
|
511
487
|
return out;
|
|
512
488
|
}
|
|
489
|
+
/** True when CAMOUFOX_STRICT_CONFIG asks validateConfig to reject unknown keys. */
|
|
490
|
+
export function strictConfig() {
|
|
491
|
+
const value = (PRODUCT.getenv("STRICT_CONFIG") ?? "").trim().toLowerCase();
|
|
492
|
+
return !["", "0", "false", "no"].includes(value);
|
|
493
|
+
}
|
|
513
494
|
/**
|
|
514
495
|
* Validates the config map against the build's properties.json, and lifts a
|
|
515
496
|
* numeric value below its declared `min` up to it.
|
|
497
|
+
*
|
|
498
|
+
* A key the build does not declare is reported and skipped, so a newer library
|
|
499
|
+
* still launches an older build. With CAMOUFOX_STRICT_CONFIG=1 it throws
|
|
500
|
+
* UnknownProperty instead: CI sets it against the newest release, so the
|
|
501
|
+
* launcher cannot ship a writer for a key no released browser reads.
|
|
516
502
|
*/
|
|
517
503
|
export function validateConfig(configMap, executablePath) {
|
|
518
504
|
const properties = loadProperties(executablePath);
|
|
505
|
+
const strict = strictConfig();
|
|
519
506
|
for (const [key, value] of Object.entries(configMap)) {
|
|
520
507
|
const entry = properties[key];
|
|
521
508
|
if (!entry) {
|
|
509
|
+
if (strict) {
|
|
510
|
+
throw new UnknownProperty(`Unknown property '${key}': this Camoufox build reads no such config key ` +
|
|
511
|
+
`(${PRODUCT.envVar("STRICT_CONFIG")} is set).`);
|
|
512
|
+
}
|
|
522
513
|
if (key === "voices:speechd") {
|
|
523
514
|
LeakWarning.warn(loadWarnings().voices_unread);
|
|
524
515
|
}
|
|
@@ -546,108 +537,6 @@ export function validateConfig(configMap, executablePath) {
|
|
|
546
537
|
}
|
|
547
538
|
}
|
|
548
539
|
}
|
|
549
|
-
/**
|
|
550
|
-
* Applies the prefs and environment variables the build declares in its
|
|
551
|
-
* launch.json. A build that needs a pref or variable set at launch for a
|
|
552
|
-
* feature it compiles in says so there, so the launcher needs no knowledge of
|
|
553
|
-
* any particular build. Most builds ship no launch.json.
|
|
554
|
-
*
|
|
555
|
-
* Each rule may restrict itself to identity OSes (`target`) and host OSes
|
|
556
|
-
* (`host`), both in 'win'/'mac'/'lin' terms. `env` sets variables verbatim,
|
|
557
|
-
* `envPaths` to a file relative to the build's directory, which must exist,
|
|
558
|
-
* `envPathsOptional` likewise but only when the file exists, and
|
|
559
|
-
* `envFromConfig` to the value of a config key when the identity has one.
|
|
560
|
-
* `config` sets config keys. `ldPreload` appends each build-relative
|
|
561
|
-
* library that exists to LD_PRELOAD (appended, never replacing one the
|
|
562
|
-
* caller has), and `envCacheDirs` points each variable at a per-user cache
|
|
563
|
-
* directory of that name, created on demand. A pref or config key the caller
|
|
564
|
-
* set, or a variable already in the environment, is never replaced.
|
|
565
|
-
*
|
|
566
|
-
* An `exclusive` rule owns its variables: where it does not apply they are
|
|
567
|
-
* removed from the environment, the caller's included, so a feature meant for
|
|
568
|
-
* one target/host pairing cannot leak into another through an inherited
|
|
569
|
-
* variable. A rule's `warn` is emitted as a RuntimeWarning when it applies.
|
|
570
|
-
*/
|
|
571
|
-
export function applyLaunchRules(targetOs, config, firefoxUserPrefs, userPrefKeys, env, executablePath) {
|
|
572
|
-
const launchFile = executablePath
|
|
573
|
-
? buildFile(executablePath, "launch.json")
|
|
574
|
-
: utilsDeps.getPath("launch.json");
|
|
575
|
-
if (!fs.existsSync(launchFile))
|
|
576
|
-
return;
|
|
577
|
-
const rules = JSON.parse(fs.readFileSync(launchFile, "utf-8")).rules;
|
|
578
|
-
const hostOs = utilsDeps.hostOsKey();
|
|
579
|
-
const applies = (rule) => !(rule.target && !rule.target.includes(targetOs)) &&
|
|
580
|
-
!(rule.host && !(hostOs && rule.host.includes(hostOs)));
|
|
581
|
-
const owned = (rule) => [
|
|
582
|
-
...Object.keys(rule.env ?? {}),
|
|
583
|
-
...Object.keys(rule.envPaths ?? {}),
|
|
584
|
-
...Object.keys(rule.envPathsOptional ?? {}),
|
|
585
|
-
...Object.keys(rule.envFromConfig ?? {}),
|
|
586
|
-
...Object.keys(rule.envCacheDirs ?? {}),
|
|
587
|
-
];
|
|
588
|
-
const matched = rules.filter(applies);
|
|
589
|
-
const claimed = new Set(matched.flatMap(owned));
|
|
590
|
-
for (const rule of rules) {
|
|
591
|
-
if (!rule.exclusive || applies(rule))
|
|
592
|
-
continue;
|
|
593
|
-
for (const key of owned(rule)) {
|
|
594
|
-
if (!claimed.has(key))
|
|
595
|
-
delete env[key];
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
for (const rule of matched) {
|
|
599
|
-
if (rule.warn)
|
|
600
|
-
warn(String(rule.warn), "RuntimeWarning");
|
|
601
|
-
for (const [key, value] of Object.entries(rule.prefs ?? {})) {
|
|
602
|
-
if (!userPrefKeys.has(key))
|
|
603
|
-
firefoxUserPrefs[key] = value;
|
|
604
|
-
}
|
|
605
|
-
for (const [key, value] of Object.entries(rule.env ?? {})) {
|
|
606
|
-
if (!(key in env))
|
|
607
|
-
env[key] = value;
|
|
608
|
-
}
|
|
609
|
-
for (const [key, relative] of Object.entries(rule.envPaths ?? {})) {
|
|
610
|
-
if (key in env)
|
|
611
|
-
continue;
|
|
612
|
-
const resolved = path.join(path.dirname(launchFile), relative);
|
|
613
|
-
if (!fs.existsSync(resolved)) {
|
|
614
|
-
throw new Error(`${launchFile} needs ${resolved} for ${key}, and it does not exist.`);
|
|
615
|
-
}
|
|
616
|
-
env[key] = resolved;
|
|
617
|
-
}
|
|
618
|
-
for (const [key, relative] of Object.entries(rule.envPathsOptional ?? {})) {
|
|
619
|
-
const resolved = path.join(path.dirname(launchFile), relative);
|
|
620
|
-
if (!(key in env) && fs.existsSync(resolved))
|
|
621
|
-
env[key] = resolved;
|
|
622
|
-
}
|
|
623
|
-
for (const [key, value] of Object.entries(rule.config ?? {})) {
|
|
624
|
-
if (!(key in config))
|
|
625
|
-
config[key] = value;
|
|
626
|
-
}
|
|
627
|
-
// `env` is the caller's environment (a copy of process.env by default)
|
|
628
|
-
// and is spread last into the launch environment, so appending here is
|
|
629
|
-
// what keeps an LD_PRELOAD someone already has.
|
|
630
|
-
for (const relative of rule.ldPreload ?? []) {
|
|
631
|
-
const resolved = path.join(path.dirname(launchFile), relative);
|
|
632
|
-
const preload = env.LD_PRELOAD ? String(env.LD_PRELOAD) : "";
|
|
633
|
-
if (fs.existsSync(resolved) && !preload.split(":").includes(resolved)) {
|
|
634
|
-
env.LD_PRELOAD = preload ? `${preload}:${resolved}` : resolved;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
for (const [key, name] of Object.entries(rule.envCacheDirs ?? {})) {
|
|
638
|
-
if (key in env)
|
|
639
|
-
continue;
|
|
640
|
-
const cacheDir = userCacheDir(`camoufox-${name}`);
|
|
641
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
642
|
-
env[key] = cacheDir;
|
|
643
|
-
}
|
|
644
|
-
for (const [key, configKey] of Object.entries(rule.envFromConfig ?? {})) {
|
|
645
|
-
if (configKey in config && !(key in env)) {
|
|
646
|
-
env[key] = pyStr(config[configKey]);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
540
|
/**
|
|
652
541
|
* Validates the type of the value. (Python's bool is an int, so a boolean
|
|
653
542
|
* passes the numeric checks there, and here.)
|
|
@@ -961,11 +850,12 @@ export function socks5Host(proxy) {
|
|
|
961
850
|
/**
|
|
962
851
|
* Who resolves the names a proxied browser visits (docs/proxy-dns.md).
|
|
963
852
|
*
|
|
964
|
-
* "
|
|
965
|
-
* proxy, as a Firefox at the exit
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
853
|
+
* "exit", the default: the proxy is given names. "doh", behind a SOCKS5 proxy
|
|
854
|
+
* only: the browser, by DoH through the proxy, as a Firefox at the exit
|
|
855
|
+
* resolves its own; it gets HTTPS records, so it sends ECH where that Firefox
|
|
856
|
+
* does, and the proxy is given addresses. Starting HTTP/3 on them also needs
|
|
857
|
+
* the browser half that carries HTTP/3 over SOCKS5, which no released
|
|
858
|
+
* Camoufox has yet. An HTTP proxy is always given names.
|
|
969
859
|
*/
|
|
970
860
|
export async function applyProxyDns(proxyDns, proxy, config, firefoxUserPrefs, exitLookedUp) {
|
|
971
861
|
if (proxyDns != null && proxyDns !== "doh" && proxyDns !== "exit") {
|
|
@@ -978,7 +868,7 @@ export async function applyProxyDns(proxyDns, proxy, config, firefoxUserPrefs, e
|
|
|
978
868
|
}
|
|
979
869
|
return;
|
|
980
870
|
}
|
|
981
|
-
if (proxyDns
|
|
871
|
+
if (proxyDns !== "doh") {
|
|
982
872
|
return;
|
|
983
873
|
}
|
|
984
874
|
mergeInto(firefoxUserPrefs, PROXY_DOH_PREFS);
|
|
@@ -996,20 +886,6 @@ export async function applyProxyDns(proxyDns, proxy, config, firefoxUserPrefs, e
|
|
|
996
886
|
config["network:ipv4Only"] = true;
|
|
997
887
|
}
|
|
998
888
|
}
|
|
999
|
-
/**
|
|
1000
|
-
* Send a connection's TLS ClientHello behind its SOCKS5 CONNECT request,
|
|
1001
|
-
* before the proxy's reply. Only for a proxy that forwards what it has
|
|
1002
|
-
* received once it has connected (docs/proxy-dns.md).
|
|
1003
|
-
*/
|
|
1004
|
-
export function applyProxyOptimisticData(enabled, proxy, firefoxUserPrefs) {
|
|
1005
|
-
if (!enabled) {
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
if (proxy != null && socks5Host(proxy) === null) {
|
|
1009
|
-
throw new ValueError("proxy_optimistic_data needs a socks5:// proxy.");
|
|
1010
|
-
}
|
|
1011
|
-
firefoxUserPrefs["network.proxy.socks5_optimistic_data"] = true;
|
|
1012
|
-
}
|
|
1013
889
|
/**
|
|
1014
890
|
* Whether this host has a public IPv6 address that geolocates where the IPv4
|
|
1015
891
|
* identity does. Warns when it has one that does not.
|
|
@@ -1226,279 +1102,6 @@ export function attachSocks5Auth(target) {
|
|
|
1226
1102
|
owner.newContext = newContext;
|
|
1227
1103
|
return target;
|
|
1228
1104
|
}
|
|
1229
|
-
// Where a browser or context keeps the geometry its pages claim
|
|
1230
|
-
// (launchGeometry), where NewContext() leaves its identity's for the
|
|
1231
|
-
// newContext() it is about to make, and the mark of a fitted browser
|
|
1232
|
-
// (python/camoucore/src/camoucore/camoufox/utils.py _GEOMETRY, _NEXT_CONTEXT).
|
|
1233
|
-
const CAMOUFOX_GEOMETRY = Symbol.for("camoufox.geometry");
|
|
1234
|
-
const CAMOUFOX_NEXT_CONTEXT = Symbol.for("camoufox.nextContext");
|
|
1235
|
-
const CAMOUFOX_VIEWPORT_FIT = Symbol.for("camoufox.viewportFit");
|
|
1236
|
-
/** The viewport Playwright gives a context that asks for neither a viewport nor none. */
|
|
1237
|
-
export const PLAYWRIGHT_DEFAULT_VIEWPORT = { width: 1280, height: 720 };
|
|
1238
|
-
/**
|
|
1239
|
-
* What a launch's identity claims around its pages, from the CAMOU_CONFIG in
|
|
1240
|
-
* the launch options; null when the identity claims no screen
|
|
1241
|
-
* (python/camoucore/src/camoucore/camoufox/utils.py launch_geometry).
|
|
1242
|
-
*
|
|
1243
|
-
* The window is where CamoufoxWindow.sys.mjs puts the browser's real window,
|
|
1244
|
-
* which every page reports in outerWidth/outerHeight: the identity's outer
|
|
1245
|
-
* size, or, where the identity sets the content area instead, that with the
|
|
1246
|
-
* recorded chrome around it.
|
|
1247
|
-
*/
|
|
1248
|
-
export function launchGeometry(fromOptions) {
|
|
1249
|
-
const blob = camouConfigBlob(fromOptions);
|
|
1250
|
-
let config;
|
|
1251
|
-
try {
|
|
1252
|
-
config = blob ? JSON.parse(blob) : {};
|
|
1253
|
-
}
|
|
1254
|
-
catch {
|
|
1255
|
-
return null;
|
|
1256
|
-
}
|
|
1257
|
-
if (!isPlainObject(config))
|
|
1258
|
-
return null;
|
|
1259
|
-
const width = config["screen.width"];
|
|
1260
|
-
const height = config["screen.height"];
|
|
1261
|
-
if (!(width && height))
|
|
1262
|
-
return null;
|
|
1263
|
-
const osKey = getTargetOs(config);
|
|
1264
|
-
const size = ["Width", "Height"].map((axis, i) => {
|
|
1265
|
-
const inner = config[`window.inner${axis}`];
|
|
1266
|
-
return inner
|
|
1267
|
-
? inner + RECORDED_WINDOW_CHROME[osKey][i]
|
|
1268
|
-
: config[`window.outer${axis}`];
|
|
1269
|
-
});
|
|
1270
|
-
const window = size.every(Boolean)
|
|
1271
|
-
? {
|
|
1272
|
-
x: config["window.screenX"] || 0,
|
|
1273
|
-
y: config["window.screenY"] || 0,
|
|
1274
|
-
width: size[0],
|
|
1275
|
-
height: size[1],
|
|
1276
|
-
}
|
|
1277
|
-
: null;
|
|
1278
|
-
return { os: osKey, screen: [width, height], window };
|
|
1279
|
-
}
|
|
1280
|
-
function boxSize(value) {
|
|
1281
|
-
if (isPlainObject(value) && value.width && value.height)
|
|
1282
|
-
return [Math.trunc(value.width), Math.trunc(value.height)];
|
|
1283
|
-
return null;
|
|
1284
|
-
}
|
|
1285
|
-
function fmtSize(size) {
|
|
1286
|
-
return `${size[0]}x${size[1]}`;
|
|
1287
|
-
}
|
|
1288
|
-
function warnViewportScreen(geometry, viewport, claimed, reason) {
|
|
1289
|
-
LeakWarning.warn(warningText("viewport_screen", {
|
|
1290
|
-
viewport: fmtSize(viewport),
|
|
1291
|
-
screen: fmtSize(claimed),
|
|
1292
|
-
os: OS_NAMES[geometry.os],
|
|
1293
|
-
chrome: fmtSize(RECORDED_WINDOW_CHROME[geometry.os]),
|
|
1294
|
-
taskbar: BASELINE_TASKBAR_HEIGHT[geometry.os],
|
|
1295
|
-
reason,
|
|
1296
|
-
}));
|
|
1297
|
-
}
|
|
1298
|
-
function warnViewportWindow(viewport, window) {
|
|
1299
|
-
if (window && (viewport[0] > window.width || viewport[1] > window.height))
|
|
1300
|
-
LeakWarning.warn(warningText("viewport_window", {
|
|
1301
|
-
viewport: fmtSize(viewport),
|
|
1302
|
-
window: fmtSize([window.width, window.height]),
|
|
1303
|
-
}));
|
|
1304
|
-
}
|
|
1305
|
-
/**
|
|
1306
|
-
* The screen a new context must claim so that its pages fit on it, or null
|
|
1307
|
-
* when the identity's own already holds them
|
|
1308
|
-
* (python/camoucore/src/camoucore/camoufox/utils.py fit_context_screen).
|
|
1309
|
-
*
|
|
1310
|
-
* A viewport sits in a window the recorded chrome larger (screenFloor), and
|
|
1311
|
-
* the pages report the browser's window as theirs, so the screen holds both;
|
|
1312
|
-
* one that does not is replaced with a recorded screen that does
|
|
1313
|
-
* (drawScreen). Playwright's own `screen` option, which Juggler does not
|
|
1314
|
-
* apply, is the screen the caller chose: it is claimed as given. The caller's
|
|
1315
|
-
* viewport is never changed, so where no screen or no window can hold it,
|
|
1316
|
-
* this warns.
|
|
1317
|
-
*/
|
|
1318
|
-
export function fitContextScreen(geometry, options) {
|
|
1319
|
-
const { os: osKey, screen, window } = geometry;
|
|
1320
|
-
// `viewport: null` is the JS API's no viewport; left out, Playwright's default.
|
|
1321
|
-
const viewport = options.viewport === null
|
|
1322
|
-
? null
|
|
1323
|
-
: (boxSize(options.viewport) ?? boxSize(PLAYWRIGHT_DEFAULT_VIEWPORT));
|
|
1324
|
-
const floor = screenFloor(osKey, viewport && { width: viewport[0], height: viewport[1] }, window);
|
|
1325
|
-
const holds = (size) => size[0] >= floor[0] && size[1] >= floor[1];
|
|
1326
|
-
const shown = viewport ?? (window ? [window.width, window.height] : [0, 0]);
|
|
1327
|
-
let claimed = null;
|
|
1328
|
-
const requested = boxSize(options.screen);
|
|
1329
|
-
if (requested) {
|
|
1330
|
-
claimed =
|
|
1331
|
-
requested[0] !== screen[0] || requested[1] !== screen[1]
|
|
1332
|
-
? requested
|
|
1333
|
-
: null;
|
|
1334
|
-
if (!holds(requested))
|
|
1335
|
-
warnViewportScreen(geometry, shown, requested, "this one is the screen= the context was given, so it is kept");
|
|
1336
|
-
}
|
|
1337
|
-
else if (!holds(screen)) {
|
|
1338
|
-
claimed = drawScreen(osKey, floor);
|
|
1339
|
-
if (claimed === null)
|
|
1340
|
-
warnViewportScreen(geometry, shown, screen, `no recorded ${OS_NAMES[osKey]} screen is ${fmtSize(floor)} or larger`);
|
|
1341
|
-
}
|
|
1342
|
-
if (viewport)
|
|
1343
|
-
warnViewportWindow(viewport, window);
|
|
1344
|
-
return claimed;
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* The init script that makes a context claim a `width` x `height` screen
|
|
1348
|
-
* (screen-spoofing.patch; the available rect follows it).
|
|
1349
|
-
*/
|
|
1350
|
-
export function screenInitScript(width, height) {
|
|
1351
|
-
return `if (typeof window.setScreenDimensions === "function") window.setScreenDimensions(${Math.trunc(width)}, ${Math.trunc(height)});`;
|
|
1352
|
-
}
|
|
1353
|
-
/**
|
|
1354
|
-
* Make every newContext()/newPage() of `target` claim a screen its pages fit
|
|
1355
|
-
* on (python/camoucore/src/camoucore/camoufox/utils.py attach_viewport_fit).
|
|
1356
|
-
*
|
|
1357
|
-
* `geometry` is what the launch's identity claims (launchGeometry). A context
|
|
1358
|
-
* claims that, or the identity NewContext() hands over, with the screen
|
|
1359
|
-
* fitContextScreen() decides set through the per-context screen setter. The
|
|
1360
|
-
* context keeps what it claims, for setViewportSize().
|
|
1361
|
-
*/
|
|
1362
|
-
export function attachViewportFit(target, geometry) {
|
|
1363
|
-
const owner = target;
|
|
1364
|
-
if (geometry)
|
|
1365
|
-
owner[CAMOUFOX_GEOMETRY] = geometry;
|
|
1366
|
-
const original = owner?.newContext;
|
|
1367
|
-
// Marked on the browser, not the method: one check per context, however
|
|
1368
|
-
// many other wrappers sit around it.
|
|
1369
|
-
if (typeof original !== "function" || owner[CAMOUFOX_VIEWPORT_FIT])
|
|
1370
|
-
return target;
|
|
1371
|
-
owner[CAMOUFOX_VIEWPORT_FIT] = true;
|
|
1372
|
-
owner.newContext = async (options, ...rest) => {
|
|
1373
|
-
// Read before the first await: NewContext() set it just before this call.
|
|
1374
|
-
const claimed = owner[CAMOUFOX_NEXT_CONTEXT] ?? owner[CAMOUFOX_GEOMETRY] ?? null;
|
|
1375
|
-
delete owner[CAMOUFOX_NEXT_CONTEXT];
|
|
1376
|
-
const screen = claimed ? fitContextScreen(claimed, options ?? {}) : null;
|
|
1377
|
-
const context = await original.call(target, options, ...rest);
|
|
1378
|
-
if (screen)
|
|
1379
|
-
await context.addInitScript(screenInitScript(...screen));
|
|
1380
|
-
if (claimed)
|
|
1381
|
-
context[CAMOUFOX_GEOMETRY] = {
|
|
1382
|
-
...claimed,
|
|
1383
|
-
screen: screen ?? claimed.screen,
|
|
1384
|
-
};
|
|
1385
|
-
return context;
|
|
1386
|
-
};
|
|
1387
|
-
return target;
|
|
1388
|
-
}
|
|
1389
|
-
/**
|
|
1390
|
-
* Warn when page.setViewportSize() asks for a page its context's screen or
|
|
1391
|
-
* window cannot hold. The screen setter is sealed once a page has loaded, so
|
|
1392
|
-
* a context keeps the screen it started with.
|
|
1393
|
-
*/
|
|
1394
|
-
export function checkViewportSize(geometry, size, reason = "set_viewport_size() comes after the context's pages have loaded, so the screen stays") {
|
|
1395
|
-
const viewport = boxSize(size);
|
|
1396
|
-
if (!(geometry && viewport))
|
|
1397
|
-
return;
|
|
1398
|
-
const floor = screenFloor(geometry.os, {
|
|
1399
|
-
width: viewport[0],
|
|
1400
|
-
height: viewport[1],
|
|
1401
|
-
});
|
|
1402
|
-
if (geometry.screen[0] < floor[0] || geometry.screen[1] < floor[1])
|
|
1403
|
-
warnViewportScreen(geometry, viewport, geometry.screen, reason);
|
|
1404
|
-
warnViewportWindow(viewport, geometry.window);
|
|
1405
|
-
}
|
|
1406
|
-
/**
|
|
1407
|
-
* A persistent context's pages claim the launch's identity: keep it for
|
|
1408
|
-
* setViewportSize(), and warn when the launch's own viewport does not fit it.
|
|
1409
|
-
* launchOptions() draws the identity around a viewport it is given, so this
|
|
1410
|
-
* only catches one the options were built without.
|
|
1411
|
-
*/
|
|
1412
|
-
export function attachPersistentGeometry(context, fromOptions) {
|
|
1413
|
-
const geometry = launchGeometry(fromOptions);
|
|
1414
|
-
if (geometry) {
|
|
1415
|
-
context[CAMOUFOX_GEOMETRY] = geometry;
|
|
1416
|
-
checkViewportSize(geometry, fromOptions.viewport, "this persistent launch was given an identity drawn without the viewport");
|
|
1417
|
-
}
|
|
1418
|
-
return context;
|
|
1419
|
-
}
|
|
1420
|
-
/** The OS keys an `os` launch option may draw: all of them when it names none. */
|
|
1421
|
-
function osKeys(os) {
|
|
1422
|
-
const names = typeof os === "string" ? [os] : [...(os ?? [])];
|
|
1423
|
-
const keys = names
|
|
1424
|
-
.filter((name) => name in OS_CODE)
|
|
1425
|
-
.map((name) => OS_CODE[name]);
|
|
1426
|
-
return keys.length ? keys : Object.keys(OS_NAMES);
|
|
1427
|
-
}
|
|
1428
|
-
/**
|
|
1429
|
-
* The bound on a launch identity's screen that holds a `viewport` page in its
|
|
1430
|
-
* window (the caller's `window`, or one the recorded chrome larger), for
|
|
1431
|
-
* whichever OS the draw picks, within the caller's or the display's `screen`
|
|
1432
|
-
* bound (python/camoucore/src/camoucore/camoufox/utils.py viewport_screen_bound).
|
|
1433
|
-
*/
|
|
1434
|
-
export function viewportScreenBound(viewport, os, screen, window) {
|
|
1435
|
-
const floors = osKeys(os).map((key) => {
|
|
1436
|
-
const [chromeW, chromeH] = RECORDED_WINDOW_CHROME[key];
|
|
1437
|
-
const outer = window ?? [viewport[0] + chromeW, viewport[1] + chromeH];
|
|
1438
|
-
return screenFloor(key, { width: viewport[0], height: viewport[1] }, { width: outer[0], height: outer[1] });
|
|
1439
|
-
});
|
|
1440
|
-
return new Screen({
|
|
1441
|
-
minWidth: Math.max(...floors.map((f) => f[0]), screen?.minWidth ?? 0),
|
|
1442
|
-
maxWidth: screen?.maxWidth ?? null,
|
|
1443
|
-
minHeight: Math.max(...floors.map((f) => f[1]), screen?.minHeight ?? 0),
|
|
1444
|
-
maxHeight: screen?.maxHeight ?? null,
|
|
1445
|
-
});
|
|
1446
|
-
}
|
|
1447
|
-
/**
|
|
1448
|
-
* A bound on the screen a NewContext() identity draws, so that it holds the
|
|
1449
|
-
* context's pages: the viewport the caller asks for, with the recorded chrome
|
|
1450
|
-
* around it, and the browser's window, which the pages report as theirs
|
|
1451
|
-
* (screenFloor). Without a known OS, the bound holds them for any.
|
|
1452
|
-
*/
|
|
1453
|
-
export function contextScreenBound(browser, os, contextOptions) {
|
|
1454
|
-
const geometry = browser?.[CAMOUFOX_GEOMETRY];
|
|
1455
|
-
const window = geometry?.window ?? null;
|
|
1456
|
-
const viewport = boxSize(contextOptions.viewport);
|
|
1457
|
-
if (!(viewport || window))
|
|
1458
|
-
return null;
|
|
1459
|
-
const osKeys = os && os in OS_CODE
|
|
1460
|
-
? [OS_CODE[os]]
|
|
1461
|
-
: os && os in OS_NAMES
|
|
1462
|
-
? [os]
|
|
1463
|
-
: Object.keys(OS_NAMES);
|
|
1464
|
-
const floors = osKeys.map((key) => screenFloor(key, viewport && { width: viewport[0], height: viewport[1] }, window));
|
|
1465
|
-
return new Screen({
|
|
1466
|
-
minWidth: Math.max(...floors.map((f) => f[0])),
|
|
1467
|
-
minHeight: Math.max(...floors.map((f) => f[1])),
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* Tell attachViewportFit() what the next context of `browser` claims: the
|
|
1472
|
-
* NewContext() identity in `fingerprint`, in the browser's window.
|
|
1473
|
-
*/
|
|
1474
|
-
export function handOverContextGeometry(browser, fingerprint) {
|
|
1475
|
-
const config = fingerprint.config;
|
|
1476
|
-
const screen = fingerprint.preset?.screen ?? {};
|
|
1477
|
-
const width = screen.width || config["screen.width"];
|
|
1478
|
-
const height = screen.height || config["screen.height"];
|
|
1479
|
-
if (!(width && height)) {
|
|
1480
|
-
delete browser[CAMOUFOX_NEXT_CONTEXT];
|
|
1481
|
-
return;
|
|
1482
|
-
}
|
|
1483
|
-
const geometry = browser[CAMOUFOX_GEOMETRY];
|
|
1484
|
-
browser[CAMOUFOX_NEXT_CONTEXT] = {
|
|
1485
|
-
os: OS_CODE[targetOsFromPlatform(String(config["navigator.platform"] ?? ""))],
|
|
1486
|
-
screen: [width, height],
|
|
1487
|
-
window: geometry?.window ?? null,
|
|
1488
|
-
};
|
|
1489
|
-
}
|
|
1490
|
-
/** Drop a handOverContextGeometry() that no newContext() took. */
|
|
1491
|
-
export function takeBackContextGeometry(browser) {
|
|
1492
|
-
delete browser[CAMOUFOX_NEXT_CONTEXT];
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* page.setViewportSize() on a page of a Camoufox launch: checkViewportSize()
|
|
1496
|
-
* against what the page's context claims (attachDriverDefaults in
|
|
1497
|
-
* driver_defaults.ts calls it where the client sends the request).
|
|
1498
|
-
*/
|
|
1499
|
-
export function checkPageViewportSize(page, size) {
|
|
1500
|
-
checkViewportSize(page?._browserContext?.[CAMOUFOX_GEOMETRY], size);
|
|
1501
|
-
}
|
|
1502
1105
|
/**
|
|
1503
1106
|
* Warn when newPage()/newContext() asks for isMobile: Camoufox only has desktop
|
|
1504
1107
|
* identities, and Juggler ignores the option (TargetRegistry.js).
|
|
@@ -1739,12 +1342,7 @@ function toScreen(screen) {
|
|
|
1739
1342
|
export async function launchOptions(options = {}) {
|
|
1740
1343
|
return buildLaunchOptions(options);
|
|
1741
1344
|
}
|
|
1742
|
-
|
|
1743
|
-
windows: "win",
|
|
1744
|
-
macos: "mac",
|
|
1745
|
-
linux: "lin",
|
|
1746
|
-
};
|
|
1747
|
-
async function buildLaunchOptions({ config, os: targetOsOption, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, cpu, geoip, geoip_db, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, fingerprint_preset, ff_version, headless, main_world_eval, allow_addon_new_tab, executable_path, browser, firefox_user_prefs, proxy, proxy_dns, proxy_optimistic_data, enable_cache, args, env, i_know_what_im_doing, debug, virtual_display, pin_cpu_cores, canvas_noise, display_profile, ...passthrough }) {
|
|
1345
|
+
async function buildLaunchOptions({ config, os: targetOsOption, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, cpu, geoip, geoip_db, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, fingerprint_preset, ff_version, headless, main_world_eval, allow_addon_new_tab, executable_path, browser, firefox_user_prefs, proxy, proxy_dns, enable_cache, args, env, i_know_what_im_doing, debug, virtual_display, pin_cpu_cores, canvas_noise, display_profile, ...passthrough }) {
|
|
1748
1346
|
utilsDeps.ensureBrowserProfileDir(env);
|
|
1749
1347
|
// The launch fills these in, so it works on copies: a caller's object
|
|
1750
1348
|
// reused for a second launch would otherwise carry the first identity's
|
|
@@ -1755,8 +1353,8 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
1755
1353
|
firefox_user_prefs = { ...firefox_user_prefs };
|
|
1756
1354
|
// Set default values for optional arguments
|
|
1757
1355
|
headless ??= false;
|
|
1758
|
-
// The caller's own prefs, before the launcher adds any: a
|
|
1759
|
-
//
|
|
1356
|
+
// The caller's own prefs, before the launcher adds any: a display profile
|
|
1357
|
+
// never replaces one of these.
|
|
1760
1358
|
const userPrefKeys = new Set(Object.keys(firefox_user_prefs));
|
|
1761
1359
|
custom_fonts_only ??= false;
|
|
1762
1360
|
i_know_what_im_doing ??= false;
|
|
@@ -1891,22 +1489,11 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
1891
1489
|
// Bound the geometry to the real display. The generator only honours this
|
|
1892
1490
|
// when its pool has a match, so it is re-applied after generation as well.
|
|
1893
1491
|
// `headless` and "is there a display to probe" are separate questions.
|
|
1894
|
-
|
|
1492
|
+
const screenCons = screen
|
|
1895
1493
|
? toScreen(screen)
|
|
1896
1494
|
: utilsDeps.hasDisplay(env)
|
|
1897
1495
|
? utilsDeps.getScreenCons(headless)
|
|
1898
1496
|
: null;
|
|
1899
|
-
// launchPersistentContext({viewport}) shows its pages at that size from the
|
|
1900
|
-
// first one, so a drawn identity is drawn around it: a window the recorded
|
|
1901
|
-
// chrome larger than the viewport, on a screen that holds that window.
|
|
1902
|
-
const launchViewport = boxSize(passthrough.viewport);
|
|
1903
|
-
const fitViewport = launchViewport !== null &&
|
|
1904
|
-
!userSetScreenWindow &&
|
|
1905
|
-
!usedPreset &&
|
|
1906
|
-
fingerprint == null;
|
|
1907
|
-
if (fitViewport) {
|
|
1908
|
-
screenCons = viewportScreenBound(launchViewport, targetOsOption, screenCons, window);
|
|
1909
|
-
}
|
|
1910
1497
|
if (!usedPreset && fingerprint == null) {
|
|
1911
1498
|
// Default: synthetic generation via fpgen (infinite unique fingerprints)
|
|
1912
1499
|
fingerprint = await utilsDeps.generateFingerprint({
|
|
@@ -1943,29 +1530,9 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
1943
1530
|
// devicePixelRatio and matches another in matchMedia('(resolution)').
|
|
1944
1531
|
const callerScale = Number(firefox_user_prefs["layout.css.devPixelsPerPx"] ?? -1);
|
|
1945
1532
|
config["window.devicePixelRatio"] = drawnDpr;
|
|
1946
|
-
|
|
1947
|
-
if (fitViewport && launchViewport && scale === undefined) {
|
|
1948
|
-
// The screen was drawn to hold the viewport's window at the drawn
|
|
1949
|
-
// ratio, and a larger one shrinks it: the nearest display mode at
|
|
1950
|
-
// which it still does.
|
|
1951
|
-
const floor = screenFloor(targetOs, { width: launchViewport[0], height: launchViewport[1] }, window ? { width: window[0], height: window[1] } : null);
|
|
1952
|
-
for (const step of coherence.PLAUSIBLE_DPR[targetOs]) {
|
|
1953
|
-
const holds = ["width", "height"].every((axis, at) => coherence.roundHalfEven((config[`screen.${axis}`] * drawnDpr) / step) >= floor[at]);
|
|
1954
|
-
if (holds &&
|
|
1955
|
-
(scale === undefined ||
|
|
1956
|
-
Math.abs(step - drawnDpr) < Math.abs(scale - drawnDpr)))
|
|
1957
|
-
scale = step;
|
|
1958
|
-
}
|
|
1959
|
-
}
|
|
1960
|
-
coherence.repairDevicePixelRatio(config, targetOs, scale);
|
|
1533
|
+
coherence.repairDevicePixelRatio(config, targetOs, callerScale > 0 ? callerScale : undefined);
|
|
1961
1534
|
}
|
|
1962
1535
|
}
|
|
1963
|
-
// After the ratio moved, which rescales every CSS size: the viewport is in
|
|
1964
|
-
// the pixels the page reports, so its window is placed in them too.
|
|
1965
|
-
if (fitViewport && launchViewport && !window) {
|
|
1966
|
-
const [chromeW, chromeH] = RECORDED_WINDOW_CHROME[targetOs];
|
|
1967
|
-
placeWindow(config, launchViewport[0] + chromeW, launchViewport[1] + chromeH);
|
|
1968
|
-
}
|
|
1969
1536
|
// A preset whose screen is a phone viewport is not a real desktop device.
|
|
1970
1537
|
if (!userSetScreenWindow && coherence.screenIsImplausible(config)) {
|
|
1971
1538
|
coherence.repairScreenOrientation(config);
|
|
@@ -2040,53 +1607,15 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
2040
1607
|
updateFonts(config, targetOs);
|
|
2041
1608
|
}
|
|
2042
1609
|
}
|
|
2043
|
-
// After the draw, so a drawn list and a list the caller passes (a captured
|
|
2044
|
-
// enumeration, a profile's bundle) expand alike.
|
|
2045
|
-
if (targetOs === "win") {
|
|
2046
|
-
// Windows enumerates DirectWrite's families ("Arial", "Rockwell", "Sitka
|
|
2047
|
-
// Text"), and once its deferred font-info loader has landed a page can also
|
|
2048
|
-
// ask for the nameID 1/16 names of their faces (Arial Black, Rockwell Extra
|
|
2049
|
-
// Bold, the bare Sitka). The allowlist has to hold those names or it blocks
|
|
2050
|
-
// them for good: windowsLegacyFontFamilies maps each family to them. Arial
|
|
2051
|
-
// and Franklin Gothic ship with Windows, but Arial Narrow and Franklin
|
|
2052
|
-
// Gothic Demi/Heavy are faces Office adds to them, so
|
|
2053
|
-
// windowsOfficeLegacyFontFamilies applies only to a list that holds an
|
|
2054
|
-
// Office family.
|
|
2055
|
-
const expanded = [...(config.fonts || [])];
|
|
2056
|
-
const presented = new Set(expanded);
|
|
2057
|
-
const tables = [LAUNCHER_CONSTANTS.windowsLegacyFontFamilies];
|
|
2058
|
-
const office = fontUnitFamilies("win", "office");
|
|
2059
|
-
if (expanded.some((name) => office.has(name))) {
|
|
2060
|
-
tables.push(LAUNCHER_CONSTANTS.windowsOfficeLegacyFontFamilies);
|
|
2061
|
-
}
|
|
2062
|
-
for (const table of tables) {
|
|
2063
|
-
for (const [canonical, aliases] of Object.entries(table)) {
|
|
2064
|
-
if (!presented.has(canonical))
|
|
2065
|
-
continue;
|
|
2066
|
-
for (const alias of aliases) {
|
|
2067
|
-
if (!presented.has(alias)) {
|
|
2068
|
-
expanded.push(alias);
|
|
2069
|
-
presented.add(alias);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
config.fonts = expanded;
|
|
2075
|
-
}
|
|
2076
1610
|
// Draw the identity's media devices unless the caller set any mediaDevices:
|
|
2077
1611
|
// key. An empty enumerateDevices() list is a headless tell; a wrong label
|
|
2078
1612
|
// after a grant is a spoof tell.
|
|
2079
1613
|
if (!userSetMediaDevices) {
|
|
2080
1614
|
await utilsDeps.setMediaDevicesDefaults(config, salt);
|
|
2081
1615
|
}
|
|
2082
|
-
//
|
|
2083
|
-
//
|
|
2084
|
-
|
|
2085
|
-
// The display's ICC profile, which tagged images are converted to
|
|
2086
|
-
// (display_profile.ts; display-profiles.json).
|
|
2087
|
-
applyDisplayProfile(firefox_user_prefs, userPrefKeys, display_profile, config, utilsDeps.identitySeed(config, salt), targetOs, utilsDeps.hostOsKey(), utilsDeps.installDir());
|
|
2088
|
-
// When the Windows legacy styled-family aliases land (fonts.detect timing).
|
|
2089
|
-
setWindowsAliasLoadDefault(config, targetOs, utilsDeps.hostOsKey());
|
|
1616
|
+
// A caller's display ICC profile, which tagged images are converted to
|
|
1617
|
+
// (display_profile.ts).
|
|
1618
|
+
applyDisplayProfile(firefox_user_prefs, userPrefKeys, display_profile, utilsDeps.installDir());
|
|
2090
1619
|
// Scrollbars: pin the look-and-feel to the claimed OS so headless == headed
|
|
2091
1620
|
// == stock, and for Windows to the version the identity's font draw
|
|
2092
1621
|
// presents (Win11 fonts with classic scrollbars is a pair no real machine
|
|
@@ -2100,13 +1629,6 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
2100
1629
|
else {
|
|
2101
1630
|
setInto(firefox_user_prefs, "ui.useOverlayScrollbars", 1);
|
|
2102
1631
|
}
|
|
2103
|
-
// Colour scheme: on its own OS the browser follows the desktop like stock
|
|
2104
|
-
// Firefox. An identity of another OS has no desktop to follow (a window reads
|
|
2105
|
-
// the host's theme, headless reads none), so it gets the claimed OS's
|
|
2106
|
-
// out-of-the-box setting, light. colorScheme or the pref overrides it.
|
|
2107
|
-
if (targetOs !== utilsDeps.hostOsKey()) {
|
|
2108
|
-
setInto(firefox_user_prefs, "ui.systemUsesDarkTheme", 0);
|
|
2109
|
-
}
|
|
2110
1632
|
// Stock doubles a wheel's lines on Windows and Linux and never on macOS, and
|
|
2111
1633
|
// a page reads the result in deltaY (docs/input-dispatch.md).
|
|
2112
1634
|
setInto(firefox_user_prefs, "mousewheel.system_scroll_override.enabled", targetOs !== "mac");
|
|
@@ -2136,40 +1658,10 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
2136
1658
|
}
|
|
2137
1659
|
// Per-character font fallback, LINUX ONLY: with async fallback on, the
|
|
2138
1660
|
// first measurement of a character only one bundled family provides returns
|
|
2139
|
-
// the primary family's .notdef. macOS must NOT get this.
|
|
2140
|
-
|
|
2141
|
-
// too.
|
|
2142
|
-
const hostOs = utilsDeps.hostOsKey();
|
|
2143
|
-
if (targetOs === "lin" || hostOs === "lin") {
|
|
1661
|
+
// the primary family's .notdef. macOS must NOT get this.
|
|
1662
|
+
if (targetOs === "lin") {
|
|
2144
1663
|
setInto(firefox_user_prefs, "gfx.font_rendering.fallback.async", false);
|
|
2145
1664
|
}
|
|
2146
|
-
// Per-language and generic fonts: the build only has its own platform's
|
|
2147
|
-
// font.name-list defaults, so another OS's identity takes that OS's stock
|
|
2148
|
-
// values (with fallback-fonts-claimed-os.patch for the per-script table).
|
|
2149
|
-
// These and the settings below replace answers that come from the Linux
|
|
2150
|
-
// build's platform code (gfxPlatformGtk, FreeType, the GTK theme). Only a
|
|
2151
|
-
// Linux build has that code, so on a macOS or Windows host nothing is set.
|
|
2152
|
-
// A macOS identity gets the font defaults only: the values below were
|
|
2153
|
-
// measured against stock Windows alone (see utils.py).
|
|
2154
|
-
const rendersAnotherOs = hostOs === "lin" && (targetOs === "win" || targetOs === "mac");
|
|
2155
|
-
if (rendersAnotherOs) {
|
|
2156
|
-
for (const [pref, value] of Object.entries(stockFontPrefs(targetOs))) {
|
|
2157
|
-
setInto(firefox_user_prefs, pref, value);
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
if (rendersAnotherOs && targetOs === "win") {
|
|
2161
|
-
// Line boxes: DirectWrite's ascent, descent and em height rather than
|
|
2162
|
-
// FreeType's pixel-rounded ones (font-metrics-windows.patch).
|
|
2163
|
-
setInto(config, "fonts:metrics", "windows");
|
|
2164
|
-
// canPlayType()/isTypeSupported() and decodingInfo() answer for Windows
|
|
2165
|
-
// instead of the host's decoders (#558), as stock Firefox 158 on
|
|
2166
|
-
// Windows 11 answers.
|
|
2167
|
-
setInto(config, "media:spoof_codecs", true);
|
|
2168
|
-
// Windows' system colours instead of the host theme's.
|
|
2169
|
-
for (const [pref, value] of Object.entries(WINDOWS_UI_COLORS)) {
|
|
2170
|
-
setInto(firefox_user_prefs, pref, value);
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
1665
|
// Storage quota, from the host's own disk (see stockProfileDiskCapacityKb).
|
|
2174
1666
|
const quotaLimitKb = utilsDeps.stockProfileDiskCapacityKb();
|
|
2175
1667
|
if (quotaLimitKb) {
|
|
@@ -2253,10 +1745,12 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
2253
1745
|
config["network:ipv4Only"] = true;
|
|
2254
1746
|
}
|
|
2255
1747
|
}
|
|
2256
|
-
//
|
|
2257
|
-
// permissions.query '
|
|
2258
|
-
|
|
2259
|
-
|
|
1748
|
+
// A page that receives a position without a prompt must also see
|
|
1749
|
+
// permissions.query({name: 'geolocation'}) report "granted" (#769).
|
|
1750
|
+
if ("geolocation:latitude" in config && "geolocation:longitude" in config) {
|
|
1751
|
+
setInto(firefox_user_prefs, "permissions.default.geo", 1);
|
|
1752
|
+
}
|
|
1753
|
+
else if (
|
|
2260
1754
|
// Raise a warning when a proxy is being used without spoofing
|
|
2261
1755
|
// geolocation. This warning cannot be ignored with i_know_what_im_doing.
|
|
2262
1756
|
pyTruthy(proxy) &&
|
|
@@ -2271,11 +1765,6 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
2271
1765
|
LeakWarning.warn(loadWarnings().proxy_http_no_udp, i_know_what_im_doing);
|
|
2272
1766
|
}
|
|
2273
1767
|
await applyProxyDns(proxy_dns, proxy, config, firefox_user_prefs, pyTruthy(geoip));
|
|
2274
|
-
applyProxyOptimisticData(proxy_optimistic_data, proxy, firefox_user_prefs);
|
|
2275
|
-
// After geoip, which decides whether the machine has IPv6 at all.
|
|
2276
|
-
setHostIpv6Default(config, salt);
|
|
2277
|
-
// After geoip too: an identity given coordinates has location on.
|
|
2278
|
-
setLocationSettingDefault(config, salt, targetOs, utilsDeps.hostOsKey());
|
|
2279
1768
|
// Set locale
|
|
2280
1769
|
if (pyTruthy(locale)) {
|
|
2281
1770
|
await handleLocales(locale, config);
|
|
@@ -2475,7 +1964,6 @@ async function buildLaunchOptions({ config, os: targetOsOption, block_images, bl
|
|
|
2475
1964
|
console.log("[DEBUG] Config:");
|
|
2476
1965
|
console.log(inspect(config, { depth: null, sorted: true }));
|
|
2477
1966
|
}
|
|
2478
|
-
applyLaunchRules(targetOs, config, firefox_user_prefs, userPrefKeys, env, executable_path);
|
|
2479
1967
|
// Validate the config
|
|
2480
1968
|
warnIfExecutablePredatesPlaywright(executable_path);
|
|
2481
1969
|
utilsDeps.validateConfig(config, executable_path);
|