Files
mtusi2026lab7/student-tests/grafana-browser-launch.ts

28 lines
932 B
TypeScript

import { chromium } from "playwright-core";
import { mkdtemp } from "node:fs/promises";
import { requireThat, root, local } from "../scripts/runtime";
import { resolve } from "node:path";
requireThat(
root === "/mnt/data/home/bench-saves/mtuci-vp7-security-20261115",
"BROWSER_LAUNCH_REMOTE_REQUIRED",
);
const profile = await mkdtemp(resolve(local, "u-"));
requireThat(
Buffer.byteLength(profile + "/SingletonSocket") < 90,
"BROWSER_PROFILE_PATH_TOO_LONG",
);
const context = await chromium.launchPersistentContext(profile, {
executablePath: "/usr/bin/chromium",
headless: true,
args: ["--no-sandbox", "--disable-gpu"],
env: { ...process.env, TMPDIR: root },
});
try {
const page = await context.newPage();
await page.goto("about:blank");
requireThat(page.url() === "about:blank", "BROWSER_BLANK_PAGE_FAILED");
console.log("PASS_NATIVE_SHORT_PROFILE_BROWSER_LAUNCH");
} finally {
await context.close();
}