From c524a21463a77fde3a200bdd7442721bd27041f5 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 16:32:04 +0900 Subject: [PATCH] =?UTF-8?q?test(browser):=20=EB=8B=A4=EC=9A=B4=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=8B=9C=ED=97=98=EC=9D=B4=20=EB=B8=8C=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=EC=A0=80=EA=B0=80=20=ED=8C=8C=EC=9D=BC=EC=9D=84=20?= =?UTF-8?q?=EB=B0=9B=EC=9D=80=20=EB=92=A4=20=EB=9F=B0=ED=83=80=EC=9E=84?= =?UTF-8?q?=EC=9D=84=20=EC=A0=95=EB=A6=AC=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이 시험은 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)다. --- tests/browser-capabilities/browser-files.spec.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/browser-capabilities/browser-files.spec.ts b/tests/browser-capabilities/browser-files.spec.ts index 14c2678..aa7ceb0 100644 --- a/tests/browser-capabilities/browser-files.spec.ts +++ b/tests/browser-capabilities/browser-files.spec.ts @@ -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; + __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; + __browserDownloadRuntime?: { dispose(): void }; }; - return await state.__browserDownloadResult; + const delivered = await state.__browserDownloadResult; + state.__browserDownloadRuntime?.dispose(); + return delivered; }); expect(download.suggestedFilename()).toBe("report.bin");