From ac5aa83d12b1a3a5d070e65d22b9e737fc23a5a1 Mon Sep 17 00:00:00 2001 From: rgarcia <72655+rgarcia@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:37:14 +0000 Subject: [PATCH 1/3] Enable WebMCP in extension browser tests for Chrome 157 --- extension/tests/chromium.mjs | 2 +- internal/chrome/chrome.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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. From 9eafc962d0667c0d0e7037e04e02daca31c4556a Mon Sep 17 00:00:00 2001 From: rgarcia <72655+rgarcia@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:43:23 +0000 Subject: [PATCH 2/3] TEMP: sandbox diagnostics --- .github/workflows/validate.yml | 9 +++++++++ bench/test/sandbox.test.mjs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 80265c55..3b73e69e 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -35,6 +35,15 @@ jobs: run: node --test "extension/**/*.test.mjs" - name: Install bench dependencies run: npm ci --prefix bench + - name: TEMP sandbox diagnostics + run: | + uname -a; cat /etc/os-release | head -2; bwrap --version + cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns || true + cat /proc/sys/kernel/unprivileged_userns_clone || true + ls /etc/apparmor.d | grep -i bwrap || true + which node; readlink -f "$(which node)" + bwrap --unshare-all --share-net --die-with-parent --new-session --ro-bind /usr /usr --ro-bind-try /lib /lib --ro-bind-try /lib64 /lib64 --proc /proc --dev /dev --tmpfs /tmp --ro-bind "$(readlink -f "$(which node)")" "$(readlink -f "$(which node)")" -- "$(readlink -f "$(which node)")" -e 'console.log("node ok in bwrap")'; echo "exit=$?" + sudo dmesg | tail -20 || true - name: Run bench tests run: node --test "bench/**/*.test.mjs" diff --git a/bench/test/sandbox.test.mjs b/bench/test/sandbox.test.mjs index d95488ea..8c8eb677 100644 --- a/bench/test/sandbox.test.mjs +++ b/bench/test/sandbox.test.mjs @@ -92,7 +92,7 @@ console.log(JSON.stringify({ 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); + 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-/); From ffc4ae9fbfaef7a51353f9b43c1e188c7bf7b725 Mon Sep 17 00:00:00 2001 From: rgarcia <72655+rgarcia@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:49:59 +0000 Subject: [PATCH 3/3] Spawn the host's bwrap in the real-sandbox bench test --- .github/workflows/validate.yml | 9 --------- bench/test/sandbox.test.mjs | 8 +++++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 3b73e69e..80265c55 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -35,15 +35,6 @@ jobs: run: node --test "extension/**/*.test.mjs" - name: Install bench dependencies run: npm ci --prefix bench - - name: TEMP sandbox diagnostics - run: | - uname -a; cat /etc/os-release | head -2; bwrap --version - cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns || true - cat /proc/sys/kernel/unprivileged_userns_clone || true - ls /etc/apparmor.d | grep -i bwrap || true - which node; readlink -f "$(which node)" - bwrap --unshare-all --share-net --die-with-parent --new-session --ro-bind /usr /usr --ro-bind-try /lib /lib --ro-bind-try /lib64 /lib64 --proc /proc --dev /dev --tmpfs /tmp --ro-bind "$(readlink -f "$(which node)")" "$(readlink -f "$(which node)")" -- "$(readlink -f "$(which node)")" -e 'console.log("node ok in bwrap")'; echo "exit=$?" - sudo dmesg | tail -20 || true - name: Run bench tests run: node --test "bench/**/*.test.mjs" diff --git a/bench/test/sandbox.test.mjs b/bench/test/sandbox.test.mjs index 8c8eb677..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,7 +93,7 @@ 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) }); + 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 });