Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/scripts/test-home-floor-client.cjs # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / scripts / test-home-floor-client.cjs` 65 lines ยท 3282 bytes Raw Blame History 1 #!/usr/bin/env node 2 // Independent, verification-only schedule oracle for the Omega-emitted client. 3 const assert = require('node:assert/strict'); 4 const fs = require('node:fs'); 5 const vm = require('node:vm'); 6 const entire = fs.readFileSync(process.argv[2] || 'dist/js/site.js', 'utf8'); 7 const marker = '/* Home floor after paint. Generated by om/site/floor.om. */'; 8 assert.equal(entire.split(marker).length, 2, 'one floor controller in the emitted client'); 9 const code = entire.slice(entire.indexOf(marker)); 10 function fixture(options = {}) { 11 const callbacks = [], writes = []; 12 const attrs = new Map(options.shell === false ? [] : [['data-floor-srcdoc', 'public shell']]); 13 if (options.preinitialized) attrs.set('srcdoc', 'existing'); 14 const frame = { 15 hidden: true, isConnected: true, dataset: {}, 16 getAttribute: k => attrs.get(k) ?? null, 17 hasAttribute: k => attrs.has(k), 18 removeAttribute: k => attrs.delete(k), 19 set srcdoc(value) { writes.push(value); attrs.set('srcdoc', value); }, 20 }; 21 const waiting = { hidden: false, isConnected: true }; 22 const context = vm.createContext({ 23 document: { getElementById: id => options.absent ? null : id === 'factory-floor-frame' ? frame : waiting }, 24 requestAnimationFrame: fn => callbacks.push(fn), 25 }); 26 return { callbacks, writes, frame, waiting, context, attrs }; 27 } 28 function proveSchedule(source) { 29 const f = fixture(); 30 vm.runInContext(source, f.context); 31 assert.equal(f.writes.length, 0, 'must not start during deferred script execution'); 32 assert.equal(f.waiting.hidden, false, 'first-paint overview remains visible'); 33 assert.equal(f.callbacks.length, 1); 34 f.callbacks.shift()(); 35 assert.equal(f.writes.length, 0, 'must not start before the first paint opportunity'); 36 assert.equal(f.callbacks.length, 1); 37 f.callbacks.shift()(); 38 assert.equal(f.writes.length, 1, 'starts in the following frame'); 39 assert.equal(f.frame.hidden, false); 40 assert.equal(f.waiting.hidden, true); 41 assert.equal(f.attrs.has('data-floor-srcdoc'), false); 42 vm.runInContext(source, f.context); 43 assert.equal(f.callbacks.length, 0, 'never reload a running floor'); 44 } 45 proveSchedule(code); 46 for (const options of [{ absent: true }, { shell: false }, { preinitialized: true }]) { 47 const f = fixture(options); 48 vm.runInContext(code, f.context); 49 assert.equal(f.callbacks.length, 0, 'refuses incomplete or already-active markup'); 50 assert.equal(f.writes.length, 0); 51 } 52 const removed = fixture(); 53 vm.runInContext(code, removed.context); 54 removed.callbacks.shift()(); 55 removed.frame.isConnected = false; 56 removed.callbacks.shift()(); 57 assert.equal(removed.writes.length, 0, 'must not activate a removed frame'); 58 const duplicate = fixture(); 59 vm.runInContext(code, duplicate.context); 60 vm.runInContext(code, duplicate.context); 61 assert.equal(duplicate.callbacks.length, 1, 'one pending activation'); 62 const early = code.replace('requestAnimationFrame(() => {', '(callback => callback())(() => {'); 63 assert.notEqual(early, code, 'negative-control target exists'); 64 assert.throws(() => proveSchedule(early), 'oracle must reject activation one frame too early'); 65 console.log('HOME-FLOOR-CLIENT PASS: after-paint schedule, static overview, refusals, single activation, early-start negative control');