Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): Browser Screenshot saves fresh pixels while T3 Code is hidden #36671

MergedQuicksaver(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/36671/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 176 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
176 additions and 0 deletionsapps/desktop/src/preview/Manager.test.tsModified
View file
@@ -349,6 +349,47 @@
} as unknown as TestPreviewWebContents;
​
+const makeStillImage = (pixels = "fresh-png") => ({
+ toPNG: () => Buffer.from(pixels),
+ toJPEG: () => Buffer.from(pixels),
+ getSize: () => ({ width: 100, height: 80 }),
+});
+​
+const makeTestStillImageWebContents = (...args: Parameters<typeof makeTestPreviewWebContents>) => {
+ const wc = makeTestPreviewWebContents(...args);
+ Object.assign(wc, { isDevToolsOpened: () => false });
+ holdStillImagePaint(wc, Promise.resolve());
+ return wc;
+};
+​
+const holdStillImagePaint = (
+ wc: TestPreviewWebContents,
+ paint: Promise<void> | Array<Promise<void>>,
+) => {
+ vi.mocked(wc.debugger.sendCommand).mockImplementation(async (method) => {
+ if (method === "Page.getFrameTree") return { frameTree: { frame: { id: "main" } } };
+ if (method === "Page.createIsolatedWorld") return { executionContextId: 7 };
+ if (method === "Runtime.evaluate") {
+ await (Array.isArray(paint) ? paint.shift() : paint);
+ return { result: { value: true } };
+ }
+ return undefined;
+ });