fix(browser): tighten WS3 status probes · openclaw/openclaw@ad8737a
steipete
·
2026-04-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -98,6 +98,7 @@ function createFakeSession(): ChromeMcpSession {
|
98 | 98 | describe("chrome MCP page parsing", () => { |
99 | 99 | beforeEach(async () => { |
100 | 100 | await resetChromeMcpSessionsForTest(); |
| 101 | +vi.useRealTimers(); |
101 | 102 | }); |
102 | 103 | |
103 | 104 | afterEach(() => { |
@@ -474,7 +475,6 @@ describe("chrome MCP page parsing", () => {
|
474 | 475 | expect(factoryCalls).toBe(2); |
475 | 476 | expect(tabs).toHaveLength(2); |
476 | 477 | }); |
477 | | - |
478 | 478 | it("reconnects and retries list_pages once when Chrome MCP reports a stale selected page", async () => { |
479 | 479 | let factoryCalls = 0; |
480 | 480 | const factory: ChromeMcpSessionFactory = async () => { |
@@ -613,4 +613,34 @@ describe("chrome MCP page parsing", () => {
|
613 | 613 | expect(factoryCalls).toBe(2); |
614 | 614 | expect(tabs).toHaveLength(2); |
615 | 615 | }); |
| 616 | + |
| 617 | +it("honors timeoutMs for ephemeral availability probes", async () => { |
| 618 | +vi.useFakeTimers(); |
| 619 | +const closeMock = vi.fn().mockResolvedValue(undefined); |
| 620 | +const factory: ChromeMcpSessionFactory = async () => |
| 621 | +({ |
| 622 | +client: { |
| 623 | +callTool: vi.fn(), |
| 624 | +listTools: vi.fn(), |
| 625 | +close: closeMock, |
| 626 | +connect: vi.fn(), |
| 627 | +}, |
| 628 | +transport: { |
| 629 | +pid: 123, |
| 630 | +}, |
| 631 | +ready: new Promise<void>(() => {}), |
| 632 | +}) as unknown as ChromeMcpSession; |
| 633 | +setChromeMcpSessionFactoryForTest(factory); |
| 634 | + |
| 635 | +const promise = ensureChromeMcpAvailable("chrome-live", undefined, { |
| 636 | +ephemeral: true, |
| 637 | +timeoutMs: 50, |
| 638 | +}); |
| 639 | +const expectation = expect(promise).rejects.toThrow(/timed out after 50ms/i); |
| 640 | + |
| 641 | +await vi.advanceTimersByTimeAsync(50); |
| 642 | + |
| 643 | +await expectation; |
| 644 | +expect(closeMock).toHaveBeenCalledTimes(1); |
| 645 | +}); |
616 | 646 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。