test(browser): 다운로드 시험이 브라우저가 파일을 받은 뒤 런타임을 정리한다
이 시험은 BOUNDED_OBJECT_URL 다운로드로 Blob을 앵커에 넘기고, 브라우저의 download 이벤트를 기다린다. 그런데 deliver()가 handoff를 마치자마자 .finally(() => runtime.dispose())가 돈다. dispose()는 살아 있는 object URL을 즉시 해제한다(평소에는 30초 유예를 두지만 dispose는 정리라서 예외다). WebKit은 앵커 클릭 뒤 다운로드를 비동기로 시작하므로, URL이 먼저 해제되면 다운로드가 시작되지 않는다. 그러면 download 이벤트 없이 30초 시험 제한으로 떨어진다. 2026-11-12 capability 실행 4번 중 1번 WebKit에서 이렇게 떨어졌다. 런타임을 전역에 두고, 다운로드 내용을 다 읽은 뒤 페이지에서 dispose한다. 제품의 해제 규칙(30초 유예, dispose 즉시 해제)은 바꾸지 않는다. 실제 화면에서 런타임은 다운로드 직후 버려지지 않는다. 검증: WebKit에서 --repeat-each=20으로 20회 모두 통과. 고치기 전 같은 조건 10회에서는 이 시험이 실패하지 않아 재현율은 낮다. 근거는 위 실패 로그와 dispose의 즉시 해제 코드(download-delivery-adapter.ts)다.
This commit is contained in:
@@ -272,7 +272,9 @@ test("hands a bounded generated Blob to the real browser download path", async (
|
||||
});
|
||||
const state = globalThis as typeof globalThis & {
|
||||
__browserDownloadResult?: Promise<unknown>;
|
||||
__browserDownloadRuntime?: { dispose(): void };
|
||||
};
|
||||
state.__browserDownloadRuntime = runtime;
|
||||
button.addEventListener("click", () => {
|
||||
state.__browserDownloadResult = runtime.downloads
|
||||
.deliver({
|
||||
@@ -298,8 +300,7 @@ test("hands a bounded generated Blob to the real browser download path", async (
|
||||
maxBufferedBytes: 1024,
|
||||
signal: new AbortController().signal,
|
||||
onProgress() {},
|
||||
})
|
||||
.finally(() => runtime.dispose());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -313,11 +314,19 @@ test("hands a bounded generated Blob to the real browser download path", async (
|
||||
for await (const chunk of stream) {
|
||||
chunks.push(Buffer.from(chunk));
|
||||
}
|
||||
// dispose() revokes every live object URL at once. It used to run as soon
|
||||
// as deliver() handed the URL to the anchor; WebKit starts the download
|
||||
// after that, so it sometimes met a revoked URL and never started (no
|
||||
// "download" event within the test timeout). The runtime is disposed once
|
||||
// the browser has the file.
|
||||
const result = await page.evaluate(async () => {
|
||||
const state = globalThis as typeof globalThis & {
|
||||
__browserDownloadResult?: Promise<unknown>;
|
||||
__browserDownloadRuntime?: { dispose(): void };
|
||||
};
|
||||
return await state.__browserDownloadResult;
|
||||
const delivered = await state.__browserDownloadResult;
|
||||
state.__browserDownloadRuntime?.dispose();
|
||||
return delivered;
|
||||
});
|
||||
|
||||
expect(download.suggestedFilename()).toBe("report.bin");
|
||||
|
||||
Reference in New Issue
Block a user