





















@@ -7,7 +7,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
77import {
88clickChromeMcpCoords,
99clickChromeMcpElement,
10-buildChromeMcpArgs,
1110decodeChromeMcpStderrTail,
1211ensureChromeMcpAvailable,
1312evaluateChromeMcpScript,
@@ -212,114 +211,6 @@ describe("chrome MCP page parsing", () => {
212211).resolves.toEqual(Buffer.from("screenshot:jpeg"));
213212});
214213215-it("adds --userDataDir when an explicit Chromium profile path is configured", () => {
216-expect(buildChromeMcpArgs("/tmp/brave-profile")).toEqual([
217-"-y",
218-"chrome-devtools-mcp@latest",
219-"--autoConnect",
220-"--no-usage-statistics",
221-"--experimentalStructuredContent",
222-"--experimental-page-id-routing",
223-"--userDataDir",
224-"/tmp/brave-profile",
225-]);
226-});
227-228-it("uses browserUrl for existing-session cdpUrl without also passing userDataDir", () => {
229-expect(
230-buildChromeMcpArgs({
231-cdpUrl: "http://127.0.0.1:9222",
232-userDataDir: "/tmp/brave-profile",
233-}),
234-).toEqual([
235-"-y",
236-"chrome-devtools-mcp@latest",
237-"--browserUrl",
238-"http://127.0.0.1:9222",
239-"--no-usage-statistics",
240-"--experimentalStructuredContent",
241-"--experimental-page-id-routing",
242-]);
243-});
244-245-it("uses wsEndpoint for direct existing-session websocket cdpUrl", () => {
246-expect(
247-buildChromeMcpArgs({
248-cdpUrl: "ws://127.0.0.1:9222/devtools/browser/abc",
249-}),
250-).toEqual([
251-"-y",
252-"chrome-devtools-mcp@latest",
253-"--wsEndpoint",
254-"ws://127.0.0.1:9222/devtools/browser/abc",
255-"--no-usage-statistics",
256-"--experimentalStructuredContent",
257-"--experimental-page-id-routing",
258-]);
259-});
260-261-it("appends custom Chrome MCP args and lets explicit endpoint args override auto-connect", () => {
262-expect(
263-buildChromeMcpArgs({
264-userDataDir: "/tmp/brave-profile",
265-mcpArgs: ["--browserUrl", "http://127.0.0.1:9222", "--no-usage-statistics"],
266-}),
267-).toEqual([
268-"-y",
269-"chrome-devtools-mcp@latest",
270-"--experimentalStructuredContent",
271-"--experimental-page-id-routing",
272-"--browserUrl",
273-"http://127.0.0.1:9222",
274-"--no-usage-statistics",
275-]);
276-});
277-278-it("lets explicit Chrome MCP usage-statistics args override the default opt-out", () => {
279-expect(
280-buildChromeMcpArgs({
281-mcpArgs: ["--usage-statistics"],
282-}),
283-).toEqual([
284-"-y",
285-"chrome-devtools-mcp@latest",
286-"--autoConnect",
287-"--experimentalStructuredContent",
288-"--experimental-page-id-routing",
289-"--usage-statistics",
290-]);
291-});
292-293-it("does not duplicate an explicit Chrome MCP usage-statistics opt-out", () => {
294-expect(
295-buildChromeMcpArgs({
296-mcpArgs: ["--no-usage-statistics"],
297-}),
298-).toEqual([
299-"-y",
300-"chrome-devtools-mcp@latest",
301-"--autoConnect",
302-"--experimentalStructuredContent",
303-"--experimental-page-id-routing",
304-"--no-usage-statistics",
305-]);
306-});
307-308-it("omits the npx package prefix for a custom Chrome MCP command", () => {
309-expect(
310-buildChromeMcpArgs({
311-mcpCommand: "/usr/local/bin/chrome-devtools-mcp",
312-cdpUrl: "http://127.0.0.1:9222",
313-}),
314-).toEqual([
315-"--browserUrl",
316-"http://127.0.0.1:9222",
317-"--no-usage-statistics",
318-"--experimentalStructuredContent",
319-"--experimental-page-id-routing",
320-]);
321-});
322-323214it("terminates the owned Chrome MCP subprocess tree when closing temporary sessions", async () => {
324215const session = createFakeSession();
325216Object.assign(session, { ownsProcessTree: true });
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。