Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions bench/test/sandbox.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { delimiter, dirname, join } from "node:path";
import test from "node:test";
Expand Down Expand Up @@ -73,7 +73,9 @@ test("the paths checked hidden are the bench and the home entries that hold no m
assert.deepEqual(paths.sort(), [join(home, ".config"), join(home, "xwebmcp"), join(home, "xwebmcp/bench")]);
});

const bwrapWorks = spawnSync("bwrap", [...sandboxArgs(tmpdir()), "--", "true"]).status === 0;
// The host's bwrap: the sandboxed runs below pass an environment whose PATH holds only pi's and Node's directories.
const bwrap = (process.env.PATH ?? "").split(delimiter).map(dir => join(dir, "bwrap")).find(path => existsSync(path)) ?? "bwrap";
const bwrapWorks = spawnSync(bwrap, [...sandboxArgs(tmpdir()), "--", "true"]).status === 0;

test("in a real sandbox the agent sees its directory, not other files or processes", { skip: !bwrapWorks && "bwrap cannot create a sandbox here" }, () => {
const other = mkdtempSync(join(tmpdir(), "bench-other-"));
Expand All @@ -91,8 +93,8 @@ console.log(JSON.stringify({
const dir = sandboxDir({ mcpServers: { kernel: {} } });
try {
const { mounts, command } = piLauncher(env);
const result = spawnSync("bwrap", [...sandboxArgs(dir, mounts), "--", ...command], { encoding: "utf8", env: sandboxEnv("openai/gpt", dir, env) });
assert.equal(result.status, 0, result.stderr);
const result = spawnSync(bwrap, [...sandboxArgs(dir, mounts), "--", ...command], { encoding: "utf8", env: sandboxEnv("openai/gpt", dir, env) });
assert.equal(result.status, 0, `status ${result.status}, signal ${result.signal}, error ${result.error?.message}, stderr: ${result.stderr}`);
const seen = JSON.parse(result.stdout);
assert.deepEqual({ ...seen, processes: seen.processes <= 3 }, { secret: false, etc: false, prefix: false, mcp: { mcpServers: { kernel: {} } }, processes: true, cwd: dir });
assert.match(dir, /^\/tmp\/xwebmcp-agent-/);
Expand Down
2 changes: 1 addition & 1 deletion extension/tests/chromium.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function chromium(extension) {
const binary = process.env.XWEBMCP_CHROME_BIN || ['chromium', 'chromium-browser', 'google-chrome'].find(name => spawnSync('which', [name]).status === 0);
if (!binary) throw new Error('Chromium is required; set XWEBMCP_CHROME_BIN to a Chromium or Chrome for Testing binary');
const profile = await mkdtemp(join(tmpdir(), 'xwebmcp-browser-test-'));
const args = ['--headless=new', '--enable-features=WebMCPTesting', '--no-first-run', '--no-default-browser-check', '--disable-background-networking', '--disable-component-update', '--remote-debugging-port=0', `--user-data-dir=${profile}`];
const args = ['--headless=new', '--enable-features=WebMCP', '--no-first-run', '--no-default-browser-check', '--disable-background-networking', '--disable-component-update', '--remote-debugging-port=0', `--user-data-dir=${profile}`];
// The CI fixture uses only intercepted synthetic pages in a disposable profile.
if (process.env.XWEBMCP_SYNTHETIC_CI === '1') args.push('--no-sandbox');
if (extension) args.push(`--load-extension=${extension}`, `--disable-extensions-except=${extension}`);
Expand Down
2 changes: 1 addition & 1 deletion internal/chrome/chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// FlagEntry is the chrome://flags entry that enables document.modelContext
// (feature WebMCPTesting). The @1 suffix selects "Enabled".
// (feature WebMCP; WebMCPTesting before Chrome 157). The @1 suffix selects "Enabled".
const FlagEntry = "enable-webmcp-testing@1"

// Browser is a supported Chrome flavor.
Expand Down
Loading