import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { chromium } from "@playwright/test"; /** CI's capability-free container provides isolation; runtime flag policy stays unchanged. */ export async function testChromiumExecutable(root: string): Promise { const executable = chromium.executablePath(); if (process.env["CI"] !== "true") return executable; if (!process.env["PI_EXT_E2E_ROOT"]) throw new Error("Chrome CI requires the isolated E2E runner"); const wrapper = join(root, "chromium-ci"); const quoted = `'${executable.replaceAll("'", "'\\''")}'`; await writeFile(wrapper, `#!/bin/sh\nexec ${quoted} --no-sandbox "$@"\n`, { mode: 0o700, }); return wrapper; }