/** * Browser validation, in the environment the sandbox actually ships to: * the same suite as `npm run test:node`, on the browser's own WebGPU. * Results are posted to window.__RESULTS__ for the headless runner. */ import { requestSandboxDevice } from '../src/mgpu/session.ts'; import { runCases } from './cases.ts'; declare global { interface Window { __RESULTS__?: { ok: boolean; fatal?: string; lines: string[] }; } } const logEl = document.getElementById('log')!; const lines: string[] = []; const log = (line: string): void => { lines.push(line); logEl.textContent = lines.join('\n'); }; (async () => { const { device, description } = await requestSandboxDevice(); log(`adapter: ${description}`); const failures = await runCases(device, log); log(failures ? `${failures} failure(s)` : 'all tests passed'); window.__RESULTS__ = { ok: failures === 0, lines }; })().catch((e) => { const fatal = e instanceof Error ? e.message : String(e); log(`fatal: ${fatal}`); window.__RESULTS__ = { ok: false, fatal, lines }; });