























@@ -51,10 +51,11 @@ describe("pw-tools-core.snapshot navigate guard", () => {
51515252it("navigates valid network URLs with clamped timeout", async () => {
5353const goto = vi.fn(async () => {});
54-setPwToolsCoreCurrentPage({
54+const page = {
5555 goto,
5656url: vi.fn(() => "https://example.com"),
57-});
57+};
58+setPwToolsCoreCurrentPage(page);
58595960const result = await mod.navigateViaPlaywright({
6061cdpUrl: "http://127.0.0.1:18792",
@@ -66,15 +67,15 @@ describe("pw-tools-core.snapshot navigate guard", () => {
6667expect(goto).toHaveBeenCalledWith("https://example.com", { timeout: 1000 });
6768expect(getPwToolsCoreSessionMocks().gotoPageWithNavigationGuard).toHaveBeenCalledWith({
6869cdpUrl: "http://127.0.0.1:18792",
69-page: expect.anything(),
70+ page,
7071ssrfPolicy: { allowPrivateNetwork: true },
7172targetId: undefined,
7273timeoutMs: 1000,
7374url: "https://example.com",
7475});
7576expect(getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely).toHaveBeenCalledWith({
7677cdpUrl: "http://127.0.0.1:18792",
77-page: expect.anything(),
78+ page,
7879response: null,
7980ssrfPolicy: { allowPrivateNetwork: true },
8081targetId: undefined,
@@ -125,10 +126,11 @@ describe("pw-tools-core.snapshot navigate guard", () => {
125126}),
126127}),
127128}));
128-setPwToolsCoreCurrentPage({
129+const page = {
129130 goto,
130131url: vi.fn(() => "https://93.184.216.34/final"),
131-});
132+};
133+setPwToolsCoreCurrentPage(page);
132134getPwToolsCoreSessionMocks().assertPageNavigationCompletedSafely.mockRejectedValueOnce(
133135new SsrFBlockedError("Blocked hostname or private/internal/special-use IP address"),
134136);
@@ -152,7 +154,7 @@ describe("pw-tools-core.snapshot navigate guard", () => {
152154expect(getPwToolsCoreSessionMocks().closeBlockedNavigationTarget).toHaveBeenCalledTimes(1);
153155expect(getPwToolsCoreSessionMocks().closeBlockedNavigationTarget).toHaveBeenCalledWith({
154156cdpUrl: "http://127.0.0.1:18792",
155-page: expect.anything(),
157+ page,
156158targetId: undefined,
157159});
158160});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。