diff --git a/bench/test/sandbox.test.mjs b/bench/test/sandbox.test.mjs index d95488ea..9ce7a27e 100644 --- a/bench/test/sandbox.test.mjs +++ b/bench/test/sandbox.test.mjs @@ -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"; @@ -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-")); @@ -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-/); diff --git a/extension/tests/chromium.mjs b/extension/tests/chromium.mjs index 1970cc10..09c1e714 100644 --- a/extension/tests/chromium.mjs +++ b/extension/tests/chromium.mjs @@ -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}`); diff --git a/internal/chrome/chrome.go b/internal/chrome/chrome.go index eb92f250..dafb75a5 100644 --- a/internal/chrome/chrome.go +++ b/internal/chrome/chrome.go @@ -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.