From 84afff4d7556fb4a851fb747583fe0378189fc17 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=A7=89=ED=9E=8C=20IndexedDB?= =?UTF-8?q?=20=EC=97=85=EA=B7=B8=EB=A0=88=EC=9D=B4=EB=93=9C=20=EC=8B=9C?= =?UTF-8?q?=ED=97=98=EC=9D=B4=20=EC=A7=80=EB=82=98=EA=B0=84=20BLOCKED=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EB=8F=84=20=EB=B3=B8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이 시험은 다른 탭이 v1을 연 채로 v2를 열게 하고, 런타임 상태가 BLOCKED가 되는지 본다. BLOCKED는 blockedTimeoutMs(500 ms) 동안만 있다가 CLOSED/NOT_OPENED로 바뀐다. 시험은 getStatus()를 바깥에서 expect.poll로 묻는데, poll 간격이 100·250·500·1000 ms로 벌어진다. blocked 이벤트가 늦게 오면 그 500 ms가 두 번의 물음 사이에 지나가고, 시험은 뒤따른 CLOSED만 보다가 5초 뒤 떨어진다. WebKit에서 이 시험 하나가 10회 중 1회 이렇게 떨어졌다. 런타임의 subscribeStatus로 페이지 안에서 상태가 바뀔 때마다 기록하고, 그 기록에 BLOCKED가 있는지 본다. 재시도나 timeout을 늘려 덮지 않는다. 나머지 검증(열기 실패의 BLOCKED 오류, 막은 탭이 닫힌 뒤 늦은 연결을 닫음, 삭제)은 그대로다. 검증: WebKit에서 --repeat-each로 고치기 전 10회 중 1회 실패. 고친 뒤 20회 모두 통과(같은 실행의 다운로드 시험 20회 포함 40건). --- .../indexeddb-runtime.spec.ts | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/browser-capabilities/indexeddb-runtime.spec.ts b/tests/browser-capabilities/indexeddb-runtime.spec.ts index e3fa690..84812c0 100644 --- a/tests/browser-capabilities/indexeddb-runtime.spec.ts +++ b/tests/browser-capabilities/indexeddb-runtime.spec.ts @@ -182,6 +182,15 @@ async function startLifecycleRuntime( __indexedDbLifecycleRuntime?: unknown; } ).__indexedDbLifecycleRuntime = runtime; + // Every status the runtime passes through, so a short-lived one (BLOCKED + // lasts blockedTimeoutMs) is seen however late the test looks. + const statuses: unknown[] = []; + runtime.subscribeStatus((status) => statuses.push(status)); + ( + globalThis as unknown as { + __indexedDbLifecycleStatuses?: unknown[]; + } + ).__indexedDbLifecycleStatuses = statuses; const opening = runtime.open(); ( globalThis as unknown as { @@ -240,6 +249,17 @@ async function lifecycleStatus(page: Page): Promise { }); } +async function lifecycleStatuses(page: Page): Promise { + return await page.evaluate( + () => + ( + globalThis as unknown as { + __indexedDbLifecycleStatuses?: unknown[]; + } + ).__indexedDbLifecycleStatuses ?? [], + ); +} + async function closeLifecycleRuntime(page: Page): Promise { await page.evaluate(() => { const runtime = ( @@ -1021,9 +1041,12 @@ test("fails a blocked v2 upgrade closed, then closes its late connection after t expect(blocker).toBe("OPEN"); await startLifecycleRuntime(page, name, 2, 500); + // BLOCKED lasts 500 ms. Polling getStatus() from the test (100, 250, 500, + // 1000 ms apart) missed it whenever the blocked event came late, as it + // sometimes does in WebKit, and then saw only the CLOSED that follows. await expect - .poll(async () => await lifecycleStatus(page)) - .toEqual({ + .poll(async () => await lifecycleStatuses(page)) + .toContainEqual({ kind: "BLOCKED", currentVersion: 1, targetVersion: 2,