Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ npm run test:ui

同じフォルダの再読込では、「本のフォルダを開く」から原稿を3版に書き換えて読み、各版のタイトル・原稿・画像・保存結果を確認する。変更のない同じフォルダについても本文DOMの入れ替えを確認し、前回の完了表示だけを見て成功としない。WebKitではこのシナリオを追加で5回繰り返し、失敗時のスクリーンショットとトレースをActionsのartifactに7日間残す。

`npm run test:ui`は、固定したPlaywright 1.61.1のディレクトリ選択処理にテスト専用の補正を適用する(`scripts/prepare-browser-tests.mjs`)。元の処理は`input`監視の登録完了を待たずにネイティブ選択を開始するため、Ubuntu WebKitでイベントを取り逃がすことがある。保存トレースでは本が表示済みでも`setInputFiles`が30秒待機していた。補正は監視登録の完了を確認してから選択を実行する。タイムアウト延長・例外の握りつぶし・再試行・テスト省略は行わず、製品のparser/viewerには含めない。バージョンや対象コードが変わった場合は明示的に失敗するので、Playwright更新時に上流の修正を確認して削除または再評価する。2026-10-20時点の[公式v1.64.1実装](https://github.com/microsoft/playwright/blob/v1.64.1/packages/playwright-core/src/server/dom.ts#L770)にも同じ登録順序が残っている。

保存したスクリーンショットと`evidence/validation-summary.json`は上記macOSの初回記録であり、CIの毎回の結果へ自動で上書きコミットしない。CIが検証したコミットと実行結果はActionsで確認する。Ubuntu上のブラウザ検証が通っても、Linux全般の手動読書・フォント・支援技術の評価済みとは扱わない。

## 既知の制限
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lint": "eslint .",
"typecheck": "tsc --noEmit",
"test": "node --test tests/*.test.mjs",
"test:ui": "npm run build && playwright test",
"test:ui": "npm run build && node scripts/prepare-browser-tests.mjs && playwright test",
"validate": "node src/cli.mjs validate",
"ast": "node src/cli.mjs ast"
},
Expand Down
39 changes: 39 additions & 0 deletions scripts/prepare-browser-tests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Test infrastructure only. Playwright 1.61.1 starts an evaluate() that installs
// an input listener, then sends the native file-selection command without an
// acknowledgement that the listener exists. Linux WebKit can dispatch first:
// the book loads, but setInputFiles never resolves. Wait for a JSHandle to an
// object containing the event promise before selecting files, then await it.
// Keep this narrowly guarded and remove it once the upstream race is fixed.
import { readFile, writeFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';

const require = createRequire(import.meta.url);
const packagePath = require.resolve('playwright-core/package.json');
const { version } = JSON.parse(await readFile(packagePath, 'utf8'));
if (version !== '1.61.1') throw new Error('Reassess the directory-input race patch for this Playwright version.');
const bundlePath = join(dirname(packagePath), 'lib/coreBundle.js');
const source = await readFile(bundlePath, 'utf8');
const original = ` const waitForInputEvent = localDirectory ? this.evaluate((node) => new Promise((fulfill) => {
node.addEventListener("input", fulfill, { once: true });
})).catch(() => {
}) : Promise.resolve();
await this._page.delegate.setInputFilePaths(progress2, retargeted, localPathsOrDirectory);
await progress2.race(waitForInputEvent);`;
const replacement = ` // YomPUB test harness: acknowledge listener installation before selection.
const inputEvent = localDirectory ? await progress2.race(this.evaluateHandle((node) => ({
promise: new Promise((fulfill) => node.addEventListener("input", fulfill, { once: true }))
}))) : null;
try {
await this._page.delegate.setInputFilePaths(progress2, retargeted, localPathsOrDirectory);
if (inputEvent) await progress2.race(inputEvent.evaluate((event) => event.promise));
} finally {
await inputEvent?.dispose();
}`;
if (source.includes(replacement)) {
console.log('Playwright directory-input listener patch already applied.');
} else {
if (source.split(original).length !== 2) throw new Error('Playwright upload implementation changed; refusing an unverified patch.');
await writeFile(bundlePath, source.replace(original, replacement));
console.log('Applied test-only Playwright directory-input listener patch.');
}
Loading