Skip to content

Computer use for the Pi coding agent — Windows apps, browsers and desktops through native UI trees, screenshots and real input.

Test reusable agent browser profile safety (#133)

alexshpunt-clanker[bot]b625d3af70ab
diff --git a/test/attach-browser.test.ts b/test/attach-browser.test.ts
index 64da2ea..c3fa40b 100644
--- a/test/attach-browser.test.ts
+++ b/test/attach-browser.test.ts
@@ -1,7 +1,7 @@
import { expect, test, vi } from "vitest";
import sharp from "sharp";
import { ComputerSession, type ComputerMode, type Driver, type DriverResult } from "../src/session.ts";
-import type { WebBrowser, WebLauncher } from "../src/web-browser.ts";
+import { WebError, type WebBrowser, type WebLauncher } from "../src/web-browser.ts";
import type { WindowObserver } from "../src/native-visuals.ts";
// LPT-850: Playwright attaches to a running Chrome or Edge only in YOLO, binds it to the addressed window, and the
@@ -19,7 +19,7 @@ function fixture(observer?: WindowObserver) {
opened: { pid: window.pid, version: "155", url: "data:", title: "Attach target", via: "cdp" } }));
const session = new ComputerSession({ call, identity: vi.fn(async () => `PiComputerUse.${"a".repeat(32)}:4100:1`), close: vi.fn(async () => {}) }, () => mode, undefined, observer, launch);
const ref = async () => ((await session.windows()).details.state!.windows as { window_ref: string }[])[0].window_ref;
- return { session, launch, browser, ref, setMode(value: ComputerMode) { mode = value; } };
+ return { session, launch, browser, call, ref, setMode(value: ComputerMode) { mode = value; } };
}
test("Playwright activity stays source-associated without exposing text or inventing a desktop point", async () => {
@@ -56,6 +56,173 @@ test("browser crop presentation uses the final derived pixels returned to the ag
expect(observer.mock.calls[0][0]).not.toHaveProperty("mark.region");
await f.session.close();
});
+test("opening a browser selects the page window instead of an owned browser dialog", async () => {
+ const f = fixture();
+ f.call.mockImplementation(async name => {
+ if (name === "list_windows") return { content: [], structuredContent: { windows: [
+ { ...window, window_id: 78, title: "Translate page?" }, window,
+ ] } };
+ throw new Error(`Unexpected native call ${name}`);
+ });
+ const opened = await f.session.openBrowser({ browser: "msedge", profile: "agent" });
+ expect(opened.details.status).toBe("observed");
+ expect(opened.details.target?.window_id).toBe(window.window_id);
+ await f.session.close();
+});
+test("opening waits when the first visible window is only a browser dialog", async () => {
+ const f = fixture();
+ let reads = 0;
+ f.call.mockImplementation(async name => {
+ if (name === "list_windows") return { content: [], structuredContent: { windows: ++reads === 1 ? [{ ...window, window_id: 78, title: "Translate page?" }] : [window] } };
+ throw new Error(`Unexpected native call ${name}`);
+ });
+ const opened = await f.session.openBrowser({ browser: "msedge", profile: "agent" });
+ expect(opened.details.target?.window_id).toBe(window.window_id);
+ expect(reads).toBeGreaterThan(1);
+ await f.session.close();
+});
+test("Safe mode only attaches to its own agent profile after approval", async () => {
+ const f = fixture();
+ f.setMode("safe");
+ const opened = await f.session.openBrowser({ browser: "chrome", profile: "agent" });
+ expect(opened.details.status).toBe("observed");
+ expect(f.launch).toHaveBeenCalledWith({ browser: "chrome", profile: "agent", approval: true }, undefined);
+ const ref = opened.details.window_ref!;
+ expect((await f.session.observeDom(ref)).details.status).toBe("refused");
+ expect((await f.session.attachBrowser(ref)).details.status).toBe("delivered");
+ expect(f.browser.request).toHaveBeenCalledWith("approve", {}, undefined, expect.any(Number));
+ expect((await f.session.observeDom(ref)).details.status).toBe("observed");
+ await f.session.close();
+ expect(f.browser.close).toHaveBeenCalledTimes(1);
+});
+test("a YOLO agent browser blocks Safe until it is closed", async () => {
+ const f = fixture();
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(false);
+ await f.session.openBrowser({ browser: "chrome", profile: "agent" });
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(true);
+ await f.session.close();
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(false);
+});
+
+test("an in-flight YOLO agent launch blocks Safe and rejects a concurrent mode change", async () => {
+ const f = fixture();
+ let finish!: () => void;
+ const waiting = new Promise<void>(resolve => { finish = resolve; });
+ f.launch.mockImplementationOnce(async () => { await waiting; return { browser: f.browser as unknown as WebBrowser, opened: { pid: window.pid, version: "", url: "", title: "" } }; });
+ const opening = f.session.openBrowser({ browser: "chrome", profile: "agent" });
+ await vi.waitFor(() => expect(f.launch).toHaveBeenCalled());
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(true);
+ f.setMode("safe");
+ finish();
+ expect((await opening).details.status).toBe("refused");
+ expect(f.browser.close).toHaveBeenCalledOnce();
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(false);
+ await f.session.close();
+});
+test("an uncertain YOLO launch remains unknown and blocks Safe", async () => {
+ const f = fixture();
+ f.launch.mockRejectedValueOnce(new WebError("cleanup unconfirmed", false, true));
+ const opened = await f.session.openBrowser({ browser: "chrome", profile: "agent" });
+ expect(opened.details.status).toBe("unknown");
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(true);
+ expect((await f.session.close()).details.status).toBe("unknown");
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(true);
+});
+
+test("an approved connection reports uncertain deferred navigation without losing the attachment", async () => {
+ const f = fixture();
+ f.setMode("safe");
+ const opened = await f.session.openBrowser({ browser: "chrome", profile: "agent", url: "https://example.invalid" });
+ f.browser.request.mockResolvedValueOnce({ pid: window.pid, version: "155", url: "about:blank", title: "", via: "toggle", navigation_error: "connection reset" });
+ const attached = await f.session.attachBrowser(opened.details.window_ref!);
+ expect(attached.details.status).toBe("unknown");
+ expect(attached.content[0]).toMatchObject({ type: "text", text: expect.stringContaining("navigation outcome is unknown") });
+ expect((await f.session.observeDom(opened.details.window_ref!)).details.status).toBe("observed");
+ await f.session.close();
+});
+test("a cancelled approval reports an unknown outcome and cleanup", async () => {
+ const f = fixture();
+ f.setMode("safe");
+ const opened = await f.session.openBrowser({ browser: "chrome", profile: "agent" });
+ f.browser.request.mockRejectedValueOnce(new WebError("cancelled", false, true));
+ const attached = await f.session.attachBrowser(opened.details.window_ref!);
+ expect(attached.details.status).toBe("unknown");
+ expect(attached.content[0]).toMatchObject({ type: "text", text: expect.stringContaining("cleanup confirmed") });
+ expect(f.browser.close).toHaveBeenCalledOnce();
+ await f.session.close();
+});
+test("a mode change stops native input to a pending Safe browser during a sequence", async () => {
+ const f = fixture();
+ f.setMode("safe");
+ const opened = await f.session.openBrowser({ browser: "msedge", profile: "agent" });
+ f.setMode("yolo");
+ const png = await sharp({ create: { width: 40, height: 30, channels: 3, background: "red" } }).png().toBuffer();
+ const image = { type: "image" as const, mimeType: "image/png", data: png.toString("base64") };
+ let inputs = 0;
+ f.call.mockImplementation(async name => {
+ if (name === "list_windows") return { content: [], structuredContent: { windows: [window] } };
+ if (name === "get_window_state") return { content: [image], structuredContent: { pid: window.pid, window_id: window.window_id,
+ window_bounds: window.bounds, screenshot_width: 40, screenshot_height: 30, elements: [] } };
+ if (name === "press_key") { inputs++; f.setMode("safe"); return { content: [], structuredContent: { effect: "confirmed" } }; }
+ throw new Error(`Unexpected native call ${name}`);
+ });
+ const ref = opened.details.window_ref!;
+ const observed = await f.session.observe(ref);
+ const result = await f.session.act({ window_ref: ref, observation_id: observed.details.observation_id!, action: "sequence",
+ sequence: [{ action: "key", key: "a" }, { action: "key", key: "b" }] });
+ expect(result.details.status).toBe("unknown");
+ expect(inputs).toBe(1);
+ await f.session.close();
+});
+test("pending browser input in flight blocks a switch to Safe", async () => {
+ const f = fixture();
+ f.setMode("safe");
+ const opened = await f.session.openBrowser({ browser: "msedge", profile: "agent" });
+ f.setMode("yolo");
+ const png = await sharp({ create: { width: 40, height: 30, channels: 3, background: "red" } }).png().toBuffer();
+ const image = { type: "image" as const, mimeType: "image/png", data: png.toString("base64") };
+ let release!: () => void;
+ const waiting = new Promise<void>(resolve => { release = resolve; });
+ f.call.mockImplementation(async name => {
+ if (name === "list_windows") return { content: [], structuredContent: { windows: [window] } };
+ if (name === "get_window_state") return { content: [image], structuredContent: { pid: window.pid, window_id: window.window_id,
+ window_bounds: window.bounds, screenshot_width: 40, screenshot_height: 30, elements: [] } };
+ if (name === "press_key") { await waiting; return { content: [], structuredContent: { effect: "confirmed" } }; }
+ throw new Error(`Unexpected native call ${name}`);
+ });
+ const ref = opened.details.window_ref!;
+ const observed = await f.session.observe(ref);
+ const action = f.session.act({ window_ref: ref, observation_id: observed.details.observation_id!, action: "key", key: "a" });
+ await vi.waitFor(() => expect(f.session.hasUnapprovedAgentBrowser()).toBe(true));
+ release(); await action;
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(false);
+ await f.session.close();
+});
+test("input to a sibling dialog blocks Safe until it completes", async () => {
+ const f = fixture();
+ f.setMode("safe"); await f.session.openBrowser({ browser: "msedge", profile: "agent" });
+ f.setMode("yolo");
+ const dialog = { ...window, window_id: 78, title: "Allow remote debugging?" };
+ const png = await sharp({ create: { width: 40, height: 30, channels: 3, background: "red" } }).png().toBuffer();
+ const image = { type: "image" as const, mimeType: "image/png", data: png.toString("base64") };
+ let release!: () => void;
+ const waiting = new Promise<void>(resolve => { release = resolve; });
+ f.call.mockImplementation(async name => {
+ if (name === "list_windows") return { content: [], structuredContent: { windows: [window, dialog] } };
+ if (name === "get_window_state") return { content: [image], structuredContent: { pid: dialog.pid, window_id: dialog.window_id,
+ window_bounds: dialog.bounds, screenshot_width: 40, screenshot_height: 30, elements: [] } };
+ if (name === "press_key") { await waiting; return { content: [], structuredContent: { effect: "confirmed" } }; }
+ throw new Error(`Unexpected native call ${name}`);
+ });
+ const windows = await f.session.windows();
+ const ref = (windows.details.state!.windows as { window_ref: string; window_id: number }[]).find(item => item.window_id === 78)!.window_ref;
+ const observed = await f.session.observe(ref);
+ const action = f.session.act({ window_ref: ref, observation_id: observed.details.observation_id!, action: "key", key: "a" });
+ await vi.waitFor(() => expect(f.session.hasUnapprovedAgentBrowser()).toBe(true));
+ release(); await action;
+ expect(f.session.hasUnapprovedAgentBrowser()).toBe(false);
+ await f.session.close();
+});
test("Safe mode refuses before any Playwright work", async () => {
const f = fixture();
const ref = await f.ref();
@@ -65,6 +232,21 @@ test("Safe mode refuses before any Playwright work", async () => {
expect(f.launch).not.toHaveBeenCalled();
});
+test("a YOLO attach completing after Safe was selected is detached without publishing browser data", async () => {
+ const f = fixture();
+ const ref = await f.ref();
+ let finish!: () => void;
+ const waiting = new Promise<void>(resolve => { finish = resolve; });
+ f.launch.mockImplementationOnce(async () => { await waiting; return { browser: f.browser as unknown as WebBrowser, opened: { pid: window.pid, version: "155", url: "https://private.invalid", title: "Private" } }; });
+ const attaching = f.session.attachBrowser(ref);
+ await vi.waitFor(() => expect(f.launch).toHaveBeenCalled());
+ f.setMode("safe"); finish();
+ const result = await attaching;
+ expect(result.details.status).toBe("refused");
+ expect(JSON.stringify(result)).not.toContain("private.invalid");
+ expect(f.browser.close).toHaveBeenCalledOnce();
+ await f.session.close();
+});
test("an attached window serves DOM reads, refuses a second attach, and the session close detaches", async () => {
const f = fixture();
const ref = await f.ref();
diff --git a/test/computer-resources.test.ts b/test/computer-resources.test.ts
index 98073c6..14c91cc 100644
--- a/test/computer-resources.test.ts
+++ b/test/computer-resources.test.ts
@@ -57,6 +57,14 @@ async function fixture() {
setBounds(value: typeof liveBounds) { liveBounds = value; } };
}
+test("uncertain YOLO profile cleanup remains a Safe-mode blocker after session release", async () => {
+ const f = await fixture();
+ await f.read();
+ const unsafe = vi.spyOn(f.session, "hasUnapprovedAgentBrowser").mockReturnValue(true);
+ await f.resources.closeAll();
+ unsafe.mockReturnValue(false);
+ expect(f.resources.hasUnapprovedAgentBrowser()).toBe(true);
+});
test("typed text is sent exactly and descriptor/UI reads do not refresh native grounding", async () => {
const f = await fixture(), view = await f.read(["ui"]);
const before = f.native().length;
diff --git a/test/live/agent-profile.live.ts b/test/live/agent-profile.live.ts
index bd9f731..381d4df 100644
--- a/test/live/agent-profile.live.ts
+++ b/test/live/agent-profile.live.ts
@@ -12,6 +12,66 @@ const evaluate = async (live: Awaited<ReturnType<typeof connectLive>>, opened: C
return text(result);
};
+test("an already-running agent profile is refused before Chromium is launched", async () => {
+ const first = await connectLive();
+ const second = await connectLive();
+ try {
+ const opened = await first.insert(first.machine, { action: "open_browser", browser: "msedge", profile: "agent", url: `${fixture.base}/` });
+ expect(opened.details.status, text(opened)).toBe("observed");
+ const duplicate = await second.insert(second.machine, { action: "open_browser", browser: "msedge", profile: "agent", url: `${fixture.base}/other` });
+ expect(duplicate.details.status).toBe("refused");
+ expect(text(duplicate)).toMatch(/profile is already in use/i);
+ expect(await evaluate(first, opened, "location.pathname")).not.toContain("/other");
+ } finally { await second.close(); await first.close(); }
+});
+test("agent Chromium uses a normal browser debugging connection", async () => {
+ const live = await connectLive();
+ try {
+ const opened = await live.insert(live.machine, { action: "open_browser", browser: "msedge", profile: "agent", url: `${fixture.base}/` });
+ expect(opened.details.status, text(opened)).toBe("observed");
+ const pid = opened.details.target!.pid;
+ const command = await live.powershell(`(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").CommandLine`);
+ expect(command).toMatch(/--remote-debugging-port=[1-9]\d*/);
+ expect(command).not.toContain("--remote-debugging-pipe");
+ expect(await evaluate(live, opened, "String(navigator.webdriver)")).toContain("false");
+ } finally { await live.close(); }
+});
+test("Safe opens its agent browser without a command-line debugging endpoint", async () => {
+ const live = await connectLive(process.cwd(), "safe");
+ try {
+ const before = (await fixture.journal()).filter(entry => entry.type === "download-served").length;
+ const url = `${fixture.base}/download/report.txt`;
+ const opened = await live.insert(live.machine, { action: "open_browser", browser: "msedge", profile: "agent", url });
+ expect(opened.details.status, text(opened)).toBe("observed");
+ const pid = opened.details.target!.pid;
+ const command = await live.powershell("(Get-CimInstance Win32_Process -Filter \"ProcessId=" + pid + "\").CommandLine");
+ expect(command).not.toContain(url);
+ expect((await fixture.journal()).filter(entry => entry.type === "download-served")).toHaveLength(before);
+ expect(command).not.toMatch(/--remote-debugging-(port|pipe)/);
+ const dom = await live.read("computer:window/" + opened.details.window_ref, ["dom"]);
+ expect(dom.details.status).toBe("refused");
+ const image = await live.read("computer:window/" + opened.details.window_ref, ["image"]);
+ expect(image.details.status, text(image)).toBe("observed");
+ const click = await live.insert(`computer:observation/${image.details.observation_id}`, { action: "click", x: 10, y: 10 });
+ expect(click.details.status).toBe("refused");
+ } finally { await live.close(); }
+});
+test("agent Chromium retains site data after its browser closes", async () => {
+ const marker = `pi-${Date.now()}`;
+ const first = await connectLive();
+ try {
+ const opened = await first.insert(first.machine, { action: "open_browser", browser: "msedge", profile: "agent", url: `${fixture.base}/` });
+ expect(opened.details.status, text(opened)).toBe("observed");
+ await evaluate(first, opened, `localStorage.setItem("pi-marker", "${marker}")`);
+ } finally { await first.close(); }
+ const second = await connectLive();
+ try {
+ const opened = await second.insert(second.machine, { action: "open_browser", browser: "msedge", profile: "agent", url: `${fixture.base}/` });
+ expect(opened.details.status, text(opened)).toBe("observed");
+ expect(await evaluate(second, opened, 'localStorage.getItem("pi-marker")')).toContain(marker);
+ await evaluate(second, opened, 'localStorage.removeItem("pi-marker")');
+ } finally { await second.close(); }
+});
test("site data written in the agent profile is still there in the next session", async () => {
const marker = `pi-${Date.now()}`;
const first = await connectLive();
diff --git a/test/live/remote.ts b/test/live/remote.ts
index 8d0d765..d014db1 100644
--- a/test/live/remote.ts
+++ b/test/live/remote.ts
@@ -18,17 +18,17 @@ import { WebBrowser } from "../../src/web-browser.ts";
* Live checks act on that machine's real desktop: use only new Notepad/Paint documents and synthetic pages.
* `machine` is where to Insert machine commands such as open; `windows` and `displays` are its discovery addresses.
*/
-export async function connectLive(cwd = process.cwd()) {
+export async function connectLive(cwd = process.cwd(), mode: "safe" | "yolo" = "yolo") {
const name = process.env.LIVE_MACHINE ?? "lab";
const images = new CuaImageSettings(() => "bilinear");
const config = await loadComputerConfig(cwd);
let local: ComputerSession | undefined;
const resources = new ComputerResources(async () => {
if (name !== "local") throw new Error("Live checks use only the remote machine.");
- return local ??= new ComputerSession(new McpDriver(config), () => "yolo", () => images.settings(), undefined,
+ return local ??= new ComputerSession(new McpDriver(config), () => mode, () => images.settings(), undefined,
(options, signal) => WebBrowser.launch({ ...options, interop: config.interop }, signal), new MachineHost(localRunner(config.interop)));
}, async () => local ? local.close() : { content: [], details: { status: "closed", mode: "yolo" } },
- sandboxFactory({ settings: () => images.settings() }), machineFactory({ getMode: () => "yolo", settings: () => images.settings() }));
+ sandboxFactory({ settings: () => images.settings() }), machineFactory({ getMode: () => mode, settings: () => images.settings() }));
// A machine starts on its first use; the live checks use the configured one unless LIVE_MACHINE=local.
const machine = computerSource("machine", name);
const runner = name === "local" ? localRunner(config.interop) : sshRunner((await machineConfig(cwd, name)).ssh);
diff --git a/test/mode.test.ts b/test/mode.test.ts
index d09df8e..e2582d9 100644
--- a/test/mode.test.ts
+++ b/test/mode.test.ts
@@ -5,7 +5,7 @@ import { registerComputerMode } from "../src/mode.ts";
import { registerComputerProvider } from "../src/provider.ts";
// Policy is independent of the IDE event bus; real-Pi provider tests cover that boundary.
-vi.mock("../src/provider.ts", () => ({ registerComputerProvider: vi.fn(async () => ({ resources: {}, guide: "", attached: () => true })) }));
+vi.mock("../src/provider.ts", () => ({ registerComputerProvider: vi.fn(async () => ({ resources: { hasUnapprovedAgentBrowser: () => false }, guide: "", attached: () => true })) }));
type Command = { handler(args: string, ctx: ExtensionCommandContext): Promise<void> };
async function fixture(branch: unknown[] = []) {
@@ -59,6 +59,20 @@ test("a user-selected Safe mode is restored on reload instead of silently fallin
expect(reloaded.ctx.ui.setStatus).toHaveBeenLastCalledWith("computer-use", "Computer: SAFE");
});
+test("Safe selection is refused while a YOLO agent browser is still open", async () => {
+ const f = await fixture();
+ let open = true;
+ const getMode = registerComputerMode({ registerCommand: (name: string, command: Command) => f.commands.set(name, command),
+ on: (name: string, handler: (event: unknown, ctx: ExtensionCommandContext) => unknown) => f.events.set(name, handler),
+ appendEntry: f.appendEntry } as unknown as ExtensionAPI, undefined, () => !open);
+ await f.commands.get("computer-mode")!.handler("safe", f.ctx);
+ expect(getMode()).toBe("yolo");
+ expect(f.appendEntry).not.toHaveBeenCalled();
+ expect(f.ctx.ui.notify).toHaveBeenCalledWith(expect.stringContaining("close"), "warning");
+ open = false;
+ await f.commands.get("computer-mode")!.handler("safe", f.ctx);
+ expect(getMode()).toBe("safe");
+});
test("user policy change and branch restore clear frames without exposing a model command", async () => {
const clear = vi.fn(async () => {}); const f = await fixture();
const getMode = registerComputerMode({ registerCommand: (name: string, command: Command) => f.commands.set(name, command),
diff --git a/test/remote-machine.test.ts b/test/remote-machine.test.ts
index 583808f..4d7f8e3 100644
--- a/test/remote-machine.test.ts
+++ b/test/remote-machine.test.ts
@@ -83,9 +83,22 @@ async function fixture() {
});
const resources = new ComputerResources(async () => host, async () => host.close(), openSandbox, start);
const names = (driver: Driver) => vi.mocked(driver.call).mock.calls.map(([name]) => name);
- return { resources, hostDriver, remoteDriver, openSandbox, start, machineClose, sandboxClose, names, machineSource: computerSource("machine", "lab") };
+ return { resources, remote, hostDriver, remoteDriver, openSandbox, start, machineClose, sandboxClose, names, machineSource: computerSource("machine", "lab") };
}
+test("Safe remains blocked while a remote YOLO browser is closing", async () => {
+ const f = await fixture();
+ await f.resources.search(address(`${f.machineSource}/windows`), cwd, "");
+ let release!: () => void;
+ const waiting = new Promise<void>(resolve => { release = resolve; });
+ const unsafe = vi.spyOn(f.remote, "hasUnapprovedAgentBrowser").mockReturnValue(true);
+ f.machineClose.mockImplementationOnce(async () => { await waiting; unsafe.mockReturnValue(false); return f.remote.close(); });
+ const closing = f.resources.delete(f.machineSource, cwd);
+ await vi.waitFor(() => expect(f.machineClose).toHaveBeenCalled());
+ expect(f.resources.hasUnapprovedAgentBrowser()).toBe(true);
+ release(); await closing;
+ expect(f.resources.hasUnapprovedAgentBrowser()).toBe(false);
+});
test("a machine starts on first use; its windows, apps and displays come only from its own driver", async () => {
const f = await fixture();
const listed = await f.resources.search(address(`${f.machineSource}/windows`), cwd, "window");
@@ -201,14 +214,14 @@ test("an address no machine issued is refused before anything is sent", async ()
});
test("a remote browser refuses before launch when that machine's worker copy is stale or missing", async () => {
- const local = execFileSync("sha256sum", ["src/web-worker.ts", "src/aria-match.ts", "src/web-geometry.ts", require.resolve("playwright-core/package.json")], { encoding: "utf8" });
+ const local = execFileSync("sha256sum", ["src/web-worker.ts", "src/agent-profile-lock.ts", "src/browser-command-line.ts", "src/aria-match.ts", "src/web-geometry.ts", require.resolve("playwright-core/package.json")], { encoding: "utf8" });
const runner = (output: string | Error): CommandRunner => ({ spawn: vi.fn(), run: vi.fn(async () => {
if (output instanceof Error) throw output;
return output;
}) });
const current = runner(local);
await checkRemoteWorker(current, "/pkg", "setup part machine");
- expect(current.run).toHaveBeenCalledWith("sha256sum", ["/pkg/src/web-worker.ts", "/pkg/src/aria-match.ts", "/pkg/src/web-geometry.ts", "/pkg/node_modules/playwright-core/package.json"], expect.anything());
+ expect(current.run).toHaveBeenCalledWith("sha256sum", ["/pkg/src/web-worker.ts", "/pkg/src/agent-profile-lock.ts", "/pkg/src/browser-command-line.ts", "/pkg/src/aria-match.ts", "/pkg/src/web-geometry.ts", "/pkg/node_modules/playwright-core/package.json"], expect.anything());
const stale = local.replace(/^[0-9a-f]{64}/, "0".repeat(64));
await expect(checkRemoteWorker(runner(stale), "/pkg", "setup part machine"))
.rejects.toThrow(/out of date \(src\/web-worker\.ts\); nothing was launched\. Refresh it from this package with setup part machine/);