test(browser): 막힌 IndexedDB 업그레이드 시험이 지나간 BLOCKED 상태도 본다
이 시험은 다른 탭이 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건).
This commit is contained in:
@@ -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<unknown> {
|
||||
});
|
||||
}
|
||||
|
||||
async function lifecycleStatuses(page: Page): Promise<unknown[]> {
|
||||
return await page.evaluate(
|
||||
() =>
|
||||
(
|
||||
globalThis as unknown as {
|
||||
__indexedDbLifecycleStatuses?: unknown[];
|
||||
}
|
||||
).__indexedDbLifecycleStatuses ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
async function closeLifecycleRuntime(page: Page): Promise<void> {
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user