16 lines
2.8 KiB
JavaScript
16 lines
2.8 KiB
JavaScript
import { isDeepStrictEqual } from 'node:util'
|
|
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-property-color-verification.json'), 'utf8'))
|
|
const fail = (message) => { throw new Error(`Chrome PropertyColor check failed: ${message}`) }
|
|
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.browserId !== 'chrome' || !/Chrome\//.test(report.userAgent || '') || report.crossOriginIsolated !== true) fail('browser boundary is invalid')
|
|
const requiredWorkerRequests = ['initialize', 'save-document', 'load-document', 'load-checkpoint', 'recovery-report', 'put-resource', 'get-resource', 'release-resource', 'dispose']
|
|
if (!report.worker?.constructed?.some(({ name }) => name === 'bitbybit-persistence') || !requiredWorkerRequests.every((type) => report.worker.requestTypes?.includes(type)) || report.worker.terminated?.includes('bitbybit-persistence') !== true) fail('persistence Worker lifecycle is incomplete')
|
|
const target = [0.2, 0.4, 0.6, 0.8]
|
|
if (report.ui?.rgbInputType !== 'color' || report.ui.alphaInputType !== 'number' || report.ui.rgbLabel !== 'Colour RGB' || report.ui.alphaLabel !== 'Colour alpha' || report.ui.beforeHex !== '#000000' || report.ui.afterHex !== '#336699' || report.ui.beforeAlpha !== '1' || report.ui.afterAlpha !== 0.8 || !isDeepStrictEqual(report.ui.beforeValue, [0, 0, 0, 1]) || !isDeepStrictEqual(report.ui.afterValue, target) || report.ui.documentVersion !== 3 || report.ui.dirty !== true || report.ui.objectState !== 'touched' || report.ui.errors?.length !== 0) fail('production UI edit evidence is incomplete')
|
|
if (report.persistence?.mode !== 'sqlite-opfs' || report.persistence.sqliteWasm !== true || report.persistence.opfs !== true || report.persistence.savedMode !== 'sqlite-opfs' || !isDeepStrictEqual(report.persistence.loadedValue, target) || report.persistence.loadedType !== 'App::PropertyColor' || report.persistence.checkpointVersion !== 3 || report.persistence.recoveryIntegrity !== 'ok' || report.persistence.fcstdElement !== 'PropertyColor' || report.persistence.fcstdValue !== '862362060') fail('OPFS/FCStd persistence evidence is incomplete')
|
|
if (!(report.resource?.byteLength > 0) || report.resource.roundTrip !== true || report.resource.released !== true || report.resource.markerRemoved !== true || report.release?.shapeCount !== 0 || report.release.kernelReferenceCount !== 0 || report.release.workerTerminated !== true) fail('resource release evidence is incomplete')
|
|
console.log(JSON.stringify({ status: 'chrome-property-color-pass', ui: report.ui, persistence: report.persistence, workerRequests: report.worker.requestTypes, resource: report.resource, release: report.release }, null, 2))
|