Files
Web_FreeCAD_Bitbybit/scripts/check-chrome-inspection.mjs

10 lines
2.0 KiB
JavaScript

import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'
const root = resolve(new URL('..', import.meta.url).pathname); const report = JSON.parse(await readFile(resolve(root, 'config/chrome-inspection-verification.json'), 'utf8'))
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.browserId !== 'chrome' || !/Chrome/i.test(report.browser?.product || '') || report.crossOriginIsolated !== true) throw new Error('Chrome Inspection verification is not passing.')
if (!report.shape?.valid || report.shape.solids !== 1 || report.measurements?.distance !== 5 || report.measurements.angle !== 90 || report.measurements.volume !== report.shape.volume || report.measurements.area !== report.shape.area || Math.abs(report.measurements.deviation - 0.01) > 1e-12 || report.measurements.deviationStatus !== 'resolved' || Math.abs(report.measurements.sectionArea - 24) > 1e-5 || report.measurements.topoRefs !== 2 || report.measurements.stableRefs !== 1 || JSON.stringify(report.measurements.unresolvedRefs) !== JSON.stringify(['Face2']) || report.measurements.csvRows !== 6) throw new Error('Inspection measurement/section/deviation/TopoRef evidence is incomplete.')
if (report.persistence?.mode !== 'sqlite-opfs' || report.persistence.byteLength <= 0 || !/^[0-9a-f]{64}$/.test(report.persistence.hash) || report.persistence.roundTrip !== true || report.persistence.released !== true) throw new Error('Inspection OPFS resource evidence is incomplete.')
if (report.opfs?.markerSuite !== 'INSP-ALL' || report.opfs.measurements !== 5 || report.opfs.markerRemoved !== true) throw new Error('Inspection OPFS marker evidence is incomplete.')
if (report.afterRelease?.shapeCount !== 0 || report.afterRelease.kernelReferenceCount !== 0) throw new Error('Inspection harness leaked ShapeHandles.')
console.log(JSON.stringify({ status: 'chrome-inspection-pass', browser: report.browser.product, shape: report.shape, measurements: report.measurements, persistence: report.persistence, opfs: report.opfs, afterRelease: report.afterRelease }, null, 2))