Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions apps/desktop/src/preview/CdpRelay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ describe("CDP relay", () => {
});
});

it("resumes paused child frames, so cross-site iframes run", async () => {
const send = vi.fn(async () => ({}));
const relay = createCdpRelayConnection(makeTarget(send), () => {});
// The page's own session is already running; only its children wait.
relay.receive(
JSON.stringify({
id: 1,
method: "Runtime.runIfWaitingForDebugger",
sessionId: "t3-preview-page",
}),
);
relay.receive(
JSON.stringify({
id: 2,
method: "Runtime.runIfWaitingForDebugger",
sessionId: "iframe-session",
}),
);
await settle();
expect(send.mock.calls).toEqual([["Runtime.runIfWaitingForDebugger", {}, "iframe-session"]]);
});

it("routes tab events to the page session once the page is announced", async () => {
const written: Array<Record<string, unknown>> = [];
const relay = createCdpRelayConnection(makeTarget(vi.fn()), (raw) =>
Expand Down
9 changes: 7 additions & 2 deletions apps/desktop/src/preview/CdpRelay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,14 @@ export function createCdpRelayConnection(
};

const pageCommand = (command: CdpCommand): Promise<unknown> => {
// The page is already running; nothing waits for a debugger.
if (command.method === "Runtime.runIfWaitingForDebugger") return Promise.resolve({});
const child = sessions.get(command.sessionId!) === "page" ? undefined : command.sessionId;
// The page itself is already running, but its child frames are not:
// Playwright auto-attaches with waitForDebuggerOnStart, so Chromium pauses
// every new cross-site iframe and worker until this reaches it. Swallowing
// it left sign-in checks and captchas, which run in such frames, frozen.
if (command.method === "Runtime.runIfWaitingForDebugger" && child === undefined) {
return Promise.resolve({});
}
return target.send(command.method, command.params ?? {}, child);
};

Expand Down
Loading