Files
Web_FreeCAD_Bitbybit/public/chrome-sketcher-stress-harness.html

33 lines
2.1 KiB
HTML

<!doctype html>
<meta charset="utf-8">
<title>Chrome Sketcher golden stress harness</title>
<pre id="result">running</pre>
<script type="module">
import { runSketchStress } from '/src/facade/sketchStress.ts'
const output = document.querySelector('#result')
const report = { schemaVersion: 1, browserId: 'chrome', crossOriginIsolated: globalThis.crossOriginIsolated === true, status: 'running' }
try {
const stress = runSketchStress({ models: 500, seed: 0x20260803 })
const markerDirectory = await navigator.storage.getDirectory()
const markerName = 'sketcher-stress-chrome-marker.json'
const marker = await markerDirectory.getFileHandle(markerName, { create: true })
const writable = await marker.createWritable()
await writable.write(JSON.stringify({ suite: 'SK-12', models: stress.models, solves: stress.solves }))
await writable.close()
const markerPayload = JSON.parse(await (await marker.getFile()).text())
await markerDirectory.removeEntry(markerName)
let markerRemoved = false
try { await markerDirectory.getFileHandle(markerName) } catch (error) { markerRemoved = error?.name === 'NotFoundError' }
report.stress = stress
report.opfs = { markerSuite: markerPayload.suite, markerModels: markerPayload.models, markerSolves: markerPayload.solves, markerRemoved }
report.status = report.crossOriginIsolated && stress.models === 500 && stress.solves === 1000 && stress.deterministicMismatches === 0 && stress.unexpectedResults === 0 && stress.maxIterations <= 64 && stress.maxResidual <= 1e-12 && stress.digest === 'edac8aed' && stress.durationMs <= 2_000 && report.opfs.markerSuite === 'SK-12' && report.opfs.markerModels === 500 && report.opfs.markerSolves === 1000 && report.opfs.markerRemoved ? 'pass' : 'failed'
} catch (error) {
report.status = 'failed'
report.error = error instanceof Error ? error.message : String(error)
}
output.textContent = JSON.stringify(report, null, 2)
await fetch('/__chrome-sketcher-stress-report', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(report) })
if (report.status !== 'pass') throw new Error(report.error || 'Chrome Sketcher stress harness failed.')
</script>