Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): restore page contexts when the desktop relay reconnects #24804

Closedfredrikbernholm(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/24804/headopened View on GitHub

Showing 2 changed files with 43 additions and 1 deletion.

x
0 of 2 viewed, 2 left
37 additions and 1 deletionapps/desktop/src/preview/CdpRelay.test.tsModified
View file
@@ -1,6 +1,10 @@
import { describe, expect, it, vi } from "vite-plus/test";
​
-import { createCdpRelayConnection, type CdpRelayTarget } from "./CdpRelay.ts";
+import {
+ createCdpRelayConnection,
+ type CdpRelayConnection,
+ type CdpRelayTarget,
+} from "./CdpRelay.ts";
​
const makeTarget = (
send: CdpRelayTarget["send"],
@@ -19,6 +23,38 @@
const settle = () => new Promise<void>((resolve) => setImmediate(resolve));
​
describe("CDP relay", () => {
+ it("announces the main execution context when reconnecting to an existing guest", async () => {
+ let runtimeEnabled = false;
+ let active: CdpRelayConnection;
+ const context = { id: 1, name: "", auxData: { isDefault: true, frameId: "GUEST-TARGET" } };
+ const target = makeTarget(async (method) => {
+ if (method === "Runtime.disable") runtimeEnabled = false;
+ if (method === "Runtime.enable" && !runtimeEnabled) {
+ runtimeEnabled = true;
+ active.event("Runtime.executionContextCreated", { context }, undefined);
+ }
+ return {};
+ });
+ const connect = async () => {
+ const written: Array<Record<string, unknown>> = [];