()
| 509 | * GSTACK_DEVICE_MEMORY → --gstack-device-memory → worker-navigator-stealth.patch |
| 510 | */ |
| 511 | export function buildGStackLaunchArgs(): string[] { |
| 512 | const env = (globalThis as any).process?.env ?? {}; |
| 513 | const args: string[] = []; |
| 514 | |
| 515 | const vendor = env.GSTACK_GPU_VENDOR; |
| 516 | if (vendor) args.push(`--gstack-gpu-vendor=${vendor}`); |
| 517 | |
| 518 | const renderer = env.GSTACK_GPU_RENDERER; |
| 519 | if (renderer) args.push(`--gstack-gpu-renderer=${renderer}`); |
| 520 | |
| 521 | // Map gbd's "MacARM"/"MacIntel" classification to the UA-CH "macOS" |
| 522 | // platform string Chromium emits natively. Other future platforms |
| 523 | // would map similarly (Win32 → "Windows", Linux → "Linux"). |
| 524 | const platform = env.GSTACK_PLATFORM; |
| 525 | if (platform === 'MacARM' || platform === 'MacIntel') { |
| 526 | args.push('--gstack-ua-platform=macOS'); |
| 527 | } else if (platform === 'Win32') { |
| 528 | args.push('--gstack-ua-platform=Windows'); |
| 529 | } else if (platform && platform.startsWith('Linux')) { |
| 530 | args.push('--gstack-ua-platform=Linux'); |
| 531 | } |
| 532 | |
| 533 | const chipset = env.GSTACK_GPU_CHIPSET; |
| 534 | if (chipset) args.push(`--gstack-ua-model=${chipset}`); |
| 535 | |
| 536 | const hw = env.GSTACK_HW_CONCURRENCY; |
| 537 | if (hw) args.push(`--gstack-hw-concurrency=${hw}`); |
| 538 | |
| 539 | const memory = env.GSTACK_DEVICE_MEMORY; |
| 540 | if (memory) args.push(`--gstack-device-memory=${memory}`); |
| 541 | |
| 542 | // Pack 2 / B11: suppress user-defined Error.prepareStackTrace during |
| 543 | // V8 stack-trace formatting. Closes the Cloudflare Bot Management canary |
| 544 | // trick where a page sets prepareStackTrace and watches for it to fire |
| 545 | // during CDP serialization. |
| 546 | // |
| 547 | // OPT-IN (off by default): only emitted when GSTACK_CDP_STEALTH is |
| 548 | // on/1/true. This switch is read by a C++ patch that only exists in |
| 549 | // gbrowser builds; gbd opts in by exporting GSTACK_CDP_STEALTH=on. Stock |
| 550 | // Playwright Chromium leaves it unset, so the flag never reaches a |
| 551 | // Chromium that wouldn't understand it. (Previously this was on-by-default |
| 552 | // unless GSTACK_CDP_STEALTH=off, which contradicted this very comment.) |
| 553 | const cdpStealth = env.GSTACK_CDP_STEALTH; |
| 554 | if (cdpStealth === 'on' || cdpStealth === '1' || cdpStealth === 'true') { |
| 555 | args.push('--gstack-suppress-prepare-stack-trace'); |
| 556 | } |
| 557 | |
| 558 | return args; |
| 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Playwright default args to strip via ignoreDefaultArgs. |
no test coverage detected