fix: 修复桌面 DOCX 媒体捕获超时
This commit is contained in:
@@ -104,4 +104,52 @@ describe("Electron DOCX 媒体捕获", () => {
|
||||
);
|
||||
expect(detach).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("媒体布局永久不返回时报告局部超时", async () => {
|
||||
const webContents = {
|
||||
executeJavaScript: vi.fn(() => new Promise(() => undefined)),
|
||||
debugger: {
|
||||
isAttached: vi.fn(() => false)
|
||||
}
|
||||
} as unknown as WebContents;
|
||||
|
||||
await expect(
|
||||
captureDocxMediaWithElectronWebContents(
|
||||
webContents,
|
||||
request,
|
||||
undefined,
|
||||
{ renderMs: 10, screenshotMs: 10 }
|
||||
)
|
||||
).rejects.toThrow("桌面 DOCX 媒体布局超过 10ms");
|
||||
});
|
||||
|
||||
it("单个 PNG 永久不返回时报告媒体编号和类型", async () => {
|
||||
let attached = false;
|
||||
const detach = vi.fn(() => {
|
||||
attached = false;
|
||||
});
|
||||
const webContents = {
|
||||
executeJavaScript: vi.fn(async () => plan),
|
||||
debugger: {
|
||||
isAttached: vi.fn(() => attached),
|
||||
attach: vi.fn(() => {
|
||||
attached = true;
|
||||
}),
|
||||
detach,
|
||||
sendCommand: vi.fn(() => new Promise(() => undefined))
|
||||
}
|
||||
} as unknown as WebContents;
|
||||
|
||||
await expect(
|
||||
captureDocxMediaWithElectronWebContents(
|
||||
webContents,
|
||||
request,
|
||||
undefined,
|
||||
{ renderMs: 10, screenshotMs: 10 }
|
||||
)
|
||||
).rejects.toThrow(
|
||||
"桌面 DOCX 第 1/1 个媒体(image)PNG 捕获超过 10ms"
|
||||
);
|
||||
expect(detach).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user