MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / runContrastAudit

Function runContrastAudit

packages/cli/src/commands/validate.ts:144–168  ·  view source on GitHub ↗
(page: import("puppeteer-core").Page)

Source from the content-addressed store, hash-verified

142}
143
144async function runContrastAudit(page: import("puppeteer-core").Page): Promise<ContrastEntry[]> {
145 const duration = await getCompositionDuration(page);
146 if (duration <= 0) return [];
147
148 await page.addScriptTag({ content: loadContrastAuditScript() });
149
150 const results: ContrastEntry[] = [];
151 for (let i = 0; i < CONTRAST_SAMPLES; i++) {
152 const t = +(((i + 0.5) / CONTRAST_SAMPLES) * duration).toFixed(3);
153 await seekTo(page, t);
154
155 const screenshot = (await page.screenshot({ encoding: "base64", type: "png" })) as string;
156 const entries = await page.evaluate(
157 (b64: string, time: number) =>
158 typeof (window as unknown as Record<string, unknown>).__contrastAudit === "function"
159 ? ((window as unknown as Record<string, unknown>).__contrastAudit as Function)(b64, time)
160 : [],
161 screenshot,
162 t,
163 );
164 results.push(...(entries as ContrastEntry[]));
165 }
166
167 return results;
168}
169
170function loadContrastAuditScript(): string {
171 const candidates = [

Callers 1

validateInBrowserFunction · 0.70

Calls 4

loadContrastAuditScriptFunction · 0.85
evaluateMethod · 0.80
getCompositionDurationFunction · 0.70
seekToFunction · 0.70

Tested by

no test coverage detected