1/**
2 * Browser validation, in the environment the sandbox actually ships to:
3 * the same suite as `npm run test:node`, on the browser's own WebGPU.
4 * Results are posted to window.__RESULTS__ for the headless runner.
5 */
6import { requestSandboxDevice } from '../src/mgpu/session.ts';
7import { runCases } from './cases.ts';
9declare global {
10 interface Window {
11 __RESULTS__?: { ok: boolean; fatal?: string; lines: string[] };
12 }
13}
15const logEl = document.getElementById('log')!;
16const lines: string[] = [];
17const log = (line: string): void => {
18 lines.push(line);
19 logEl.textContent = lines.join('\n');
20};
22(async () => {
23 const { device, description } = await requestSandboxDevice();
24 log(`adapter: ${description}`);
25 const failures = await runCases(device, log);
26 log(failures ? `${failures} failure(s)` : 'all tests passed');
27 window.__RESULTS__ = { ok: failures === 0, lines };
28})().catch((e) => {
29 const fatal = e instanceof Error ? e.message : String(e);
30 log(`fatal: ${fatal}`);
31 window.__RESULTS__ = { ok: false, fatal, lines };
32});