feat(01-02): preserve clocks exclusive audio and complete review tails

This commit is contained in:
UnixNight committed 2026-11-12 19:46:04 -05:00
1 parent 75d7ca4279
commit 91da92f17d
6 files changed
+505 -47

No files matched your search

+58
View File
@@ -209,6 +209,64 @@ test('nonfinite elapsed or uncertainty is rejected before seeking', async () =>
await assert.rejects(controller.selectEvent({...marker, original: {...marker.original, ...patch}}));
assert.equal(original.currentTime, 0);
});
class Node {
children = []; textContent = '';
constructor(tag, ownerDocument) { this.tag = tag; this.ownerDocument = ownerDocument; }
append(...items) { this.children.push(...items); }
replaceChildren(...items) { this.children = items; }
get text() { return this.textContent + this.children.map(c => c.text).join(' '); }
}
test('capability renderer preserves facts, impact order, history and inert hostile text', () => {
const doc = {createElement: tag => new Node(tag, doc)};
const container = new Node('section', doc);
api.renderCapabilities(container, {capabilities: [{id: 'move', group: 'movement',
summary: '<script>malicious()</script>', requirement_ids: ['MOVE-01'],
verified_scope: 'bounded fixture', differences: ['unverified'], acceptance: {state: 'open'},
source_links: ['javascript:bad()'], scenario_ids: ['case-a'], current: ['native receipt'],
history: [{superseded: true, revision: 'old'}],
discrepancies: [{id: 'b', impact: 'subtle'}, {id: 'a', impact: 'blocking'}]}]});
assert.match(container.text, /<script>malicious\(\)<\/script>/);
assert.match(container.text, /MOVE-01/); assert.match(container.text, /superseded/);
assert.ok(container.text.indexOf('blocking') < container.text.indexOf('subtle'));
assert.ok(container.children.some(c => c.children?.some(n => n.tag === 'details')));
assert.equal(container.children.some(c => c.tag === 'script'), false);
});
test('empty capability export has an explicit open state', () => {
const doc = {createElement: tag => new Node(tag, doc)};
const container = new Node('section', doc);
api.renderCapabilities(container, {capabilities: []});
assert.match(container.text, /No capability ledger supplied.*open/);
});
test('percent-encoded local filenames remain inert and usable', () => {
assert.equal(api.safeLocalURL('sides/port/frame%20one%23.png'), 'sides/port/frame%20one%23.png');
assert.throws(() => api.safeLocalURL('sides/port/frame.png?redirect=http://host'));
});
test('difference frame must match its own observed source event and timestamp', () => {
const a = frame(), b = frame('c'.repeat(64));
const side = artifact => ({media: {path: 'video.webm', sha256: 'b'.repeat(64), duration_seconds: 10},
artifacts: [artifact], events: [{name: 'landing', artifact: 'video.webm', media_seconds: 2}]});
const model = {sides: {original: side(a), port: side(b)}};
assert.equal(api.framePair(model).port, b);
model.sides.port.events[0].media_seconds = 3;
assert.equal(api.framePair(model).port, undefined);
model.sides.port.events[0].media_seconds = 2;
model.sides.port.media.sha256 = 'd'.repeat(64);
assert.equal(api.framePair(model).port, undefined);
});
test('a newer event seek supersedes pending metadata without cancelling the newer action', async () => {
const original = new Media(), port = new Media(); original.readyState = port.readyState = 0;
const controller = api.createPairController({original, port, timeoutMs: 100});
const old = controller.selectEvent(marker).catch(error => error);
const next = {...marker, name: 'idle', original: {...marker.original, media_seconds: 4}, port: {...marker.port, media_seconds: 5}};
const recent = controller.selectEvent(next);
original.readyState = port.readyState = 4; original.emit('loadedmetadata'); port.emit('loadedmetadata');
assert.match((await old).message, /cancelled/);
await recent;
assert.equal(original.currentTime, 4); assert.equal(port.currentTime, 5);
assert.equal(controller.snapshot().selected.name, 'idle');
assert.equal(controller.snapshot().selecting, false);
assert.equal(await controller.play(), true);
});
test('suite executes at least sixteen registered behavior tests', () => {
assert.ok(declared >= 16, 'runner must register at least sixteen tests');
});