From ee37dd86a2fcc54205da7de22fe19e85dedaaffd Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 5 Nov 2026 09:50:59 +0900 Subject: [PATCH] =?UTF-8?q?fix(test):=20capability=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=C2=B7=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=9D=98=20=EB=B2=84=ED=8A=BC=EC=9D=84=20=EC=95=B1=20?= =?UTF-8?q?=EC=9C=84=20=EA=B3=A0=EC=A0=95=20=EC=B8=B5=EC=97=90=20=EB=91=94?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: FE-GATE-008의 test:browser-capabilities가 firefox에서 가끔 30초 시간 초과로 떨어졌다. browser-files.spec.ts의 두 test가 번갈아 걸렸다. 하나는 "filechooser"를, 다른 하나는 "download"를 기다리다 끝났다. desktop에서 firefox capability suite를 30회씩 돌리면 두 test 60건 중 3건이 떨어졌다(두 번 모두). 부하와는 상관없었다(1.05에서도 남). 리뷰 14.7절은 이것을 "알려진 flake"로 두었다(1103/11-10). 원인: 두 test는 `goto("/")` 직후 label·input·button을 `` 끝, 앱 root 뒤에 붙이고 그 button을 누른다. 그때 앱은 아직 그리는 중이다. 실패한 6건의 event 기록(진단 branch, 커밋 안 함)은 모두 같았다. - pointerdown·mousedown은 button("Choose test file"/"Download generated"). - 30~45 ms 뒤 pointerup·mouseup은 홈 화면 내용("프로젝트 시작점…"). - click은 둘의 공통 조상(앱 root)이라 button의 handler가 돌지 않았다 (`__browserFileResult` 없음). 그래서 picker도 download도 없었다. - 위치까지 적은 3건에서 그 사이 scrollY는 24로 같았다. body 높이는 744에서 756으로, button top은 696에서 708로 둘 다 12 px 늘었다. 앱 내용이 클릭 도중 12 px 자랐고, viewport 아래 끝의 button 중앙 좌표가 button 밖이 됐다. 통과한 run은 pointerdown 때 이미 756이었다. 고른 방법: 두 test가 붙이는 control을 `position: fixed` 층(왼쪽 위, 가장 높은 z-index)에 둔다. 앱의 흐름 밖이라 앱이 늦게 그려도 button이 움직이지 않는다. 제품 코드는 바꾸지 않는다. 버린 대안: - 앱이 다 그려질 때까지 기다린다. "다 그려짐"을 정할 신호가 없다. 늦게 오는 글꼴이나 내용이 생기면 다시 깨진다. - `dispatchEvent("click")`이나 `force` click. 신뢰된 사용자 입력이 아니어서 firefox가 file picker를 열지 않는다. test가 증명하려는 것을 지운다. - 재시도·timeout 늘리기·worker 줄이기. 금지된 우회이고 원인이 남는다. 위험·한계: 고정 층이 앱 header 왼쪽 위를 덮는다. 두 test는 앱 UI를 누르지 않는다. 다른 capability spec은 body에 control을 붙이지 않는다(grep). 검증 (desktop): - RED(커밋 안 한 재현): mousedown 때 앱 root에 400 px를 더하고 layout을 다시 계산한다(앱이 늦게 그리는 것과 같은 일). 수정 전 spec은 세 엔진 두 test 6/6 실패(filechooser·download 대기 시간 초과). - GREEN: 같은 재현에서 수정 뒤 6/6 통과. - 실제 조건 firefox capability suite ×30: 수정 전 두 번 다 3 failed / 657 passed, 수정 뒤 660 passed. --- .../browser-files.spec.ts | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/tests/browser-capabilities/browser-files.spec.ts b/tests/browser-capabilities/browser-files.spec.ts index 14c26786..ab48ffad 100644 --- a/tests/browser-capabilities/browser-files.spec.ts +++ b/tests/browser-capabilities/browser-files.spec.ts @@ -1,10 +1,21 @@ import { expect, test } from "../support/browser/strict-browser-test.ts"; +/** + * 1103/11-10. The controls these tests add sit in a fixed layer above the + * app. The app is still rendering when a test clicks; in the document flow, + * after its root, its content moved the button between mousedown and mouseup. + * The mouseup then landed on the app, the click went to their common ancestor + * and the button's handler never ran: no file chooser, no download, and the + * test waited 30 s for the event. + */ +const FIXED_CONTROLS = + "position: fixed; inset-block-start: 0; inset-inline-start: 0; z-index: 2147483647; background: Canvas;"; + test("selects, inspects, streams, and previews a real browser File", async ({ page, }) => { await page.goto("/"); - await page.evaluate(async () => { + await page.evaluate(async (fixedControls) => { const modulePath = "/src/adapters/browser-files/index.ts"; const { @@ -20,7 +31,10 @@ test("selects, inspects, streams, and previews a real browser File", async ({ const button = document.createElement("button"); button.type = "button"; button.textContent = "Choose test file"; - document.body.append(label, input, button); + const controls = document.createElement("div"); + controls.style.cssText = fixedControls; + controls.append(label, input, button); + document.body.append(controls); const filePolicy = browserFilePolicyReference( "avatar", @@ -166,7 +180,7 @@ test("selects, inspects, streams, and previews a real browser File", async ({ }; })(); }); - }); + }, FIXED_CONTROLS); const chooserPromise = page.waitForEvent("filechooser"); await page.getByRole("button", { name: "Choose test file" }).click(); @@ -212,7 +226,7 @@ test("hands a bounded generated Blob to the real browser download path", async ( page, }) => { await page.goto("/"); - await page.evaluate(async () => { + await page.evaluate(async (fixedControls) => { const modulePath = "/src/adapters/browser-files/index.ts"; const { createBrowserFileRuntime, @@ -228,7 +242,10 @@ test("hands a bounded generated Blob to the real browser download path", async ( const button = document.createElement("button"); button.type = "button"; button.textContent = "Download generated file"; - document.body.append(label, input, button); + const controls = document.createElement("div"); + controls.style.cssText = fixedControls; + controls.append(label, input, button); + document.body.append(controls); const downloadPolicy = browserFilePolicyReference( "generated-export", "bounded-object-url-bin", @@ -301,7 +318,7 @@ test("hands a bounded generated Blob to the real browser download path", async ( }) .finally(() => runtime.dispose()); }); - }); + }, FIXED_CONTROLS); const downloadPromise = page.waitForEvent("download"); await page