(
page: import("puppeteer-core").Page,
samples: number[],
tolerance: number,
)
| 321 | } |
| 322 | |
| 323 | async function collectLayoutIssues( |
| 324 | page: import("puppeteer-core").Page, |
| 325 | samples: number[], |
| 326 | tolerance: number, |
| 327 | ): Promise<LayoutIssue[]> { |
| 328 | if (samples.length === 0) return []; |
| 329 | await page.addScriptTag({ content: loadLayoutAuditScript() }); |
| 330 | |
| 331 | const issues: LayoutIssue[] = []; |
| 332 | for (const time of samples) { |
| 333 | await seekTo(page, time); |
| 334 | const sampleIssues = await page.evaluate( |
| 335 | (auditOptions: { time: number; tolerance: number }) => { |
| 336 | const win = window as unknown as { |
| 337 | __hyperframesLayoutAudit?: (options: { time: number; tolerance: number }) => unknown[]; |
| 338 | }; |
| 339 | return win.__hyperframesLayoutAudit?.(auditOptions) ?? []; |
| 340 | }, |
| 341 | { time, tolerance }, |
| 342 | ); |
| 343 | issues.push(...(sampleIssues as LayoutIssue[])); |
| 344 | } |
| 345 | return issues; |
| 346 | } |
| 347 | |
| 348 | /** Reject selectors matching multiple elements — first-match-only sampling silently passes for siblings. */ |
| 349 | async function findAmbiguousSelectors( |
no test coverage detected