Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preview copy only forwards text from the viewer's copy keys #19561

Mergedmaria-rcksmerged 3 commits intomain fromrefs/pull/19561/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 96 additions and 16 deletions (loading 1).

x
0 of 2 viewed, 2 left
96 additions and 16 deletionsapps/server/src/preview/ServerBrowser.test.tsModified
View file
@@ -60,14 +60,43 @@
},
}));
​
-function makeSession() {
+/** A frame in its own process. Only its own session reaches the copy it holds. */
+function makeFrame() {
+ const frame = {
+ copy: "",
+ detached: false,
+ isDetached: () => frame.detached,
+ recording: Promise.withResolvers<void>(),
+ };
+ return frame;
+}
+​
+function makeSession(frame?: ReturnType<typeof makeFrame>) {
+ const events = new NodeEvents.EventEmitter();
return {
- on: vi.fn(),
+ on: vi.fn((name: string, listener: () => void) => events.on(name, listener)),
+ emit: (name: string) => events.emit(name),
detach: vi.fn(async () => {}),
- send: vi.fn(async (method: string, _input?: unknown): Promise<Record<string, unknown>> => {
+ send: vi.fn(async (method: string, input?: unknown): Promise<Record<string, unknown>> => {
if (method === "Page.getNavigationHistory") return { currentIndex: 0, entries: [{}] };
if (method === "Page.getLayoutMetrics") return { cssVisualViewport: { pageX: 0, pageY: 0 } };
if (method === "Page.captureScreenshot") return { data: "ZnJhbWU=" };
+ if (method === "Page.getFrameTree") return { frameTree: { frame: { id: "main" } } };
+ if (method === "Page.createIsolatedWorld") return { executionContextId: 7 };